2017-05-02 39 views
1

當我手動運行腳本時,我可以成功將mp3 +音頻轉換爲mp4。ffmpeg手動工作,但不與cron?

exec("/usr/bin/ffmpeg -loop 1 -i $destination_thumbnail -i $input_file -c:a copy -c:v libx264 -shortest $videoPath 2>&1",$output); 

當我通過cron執行腳本中的上述代碼時,它不會轉換。我得到這個錯誤。

Array 
(
    [0] => ffmpeg version 2.6.8 Copyright (c) 2000-2016 the FFmpeg developers 
    [1] => built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-4) 
    [2] => configuration: --prefix=/usr --bindir=/usr/bin --datadir=/usr/share/ffmpeg --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --optflags='-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches -m64 -mtune=generic' --enable-bzlib --disable-crystalhd --enable-gnutls --enable-ladspa --enable-libass --enable-libcdio --enable-libdc1394 --enable-libfaac --enable-nonfree --enable-libfdk-aac --enable-nonfree --disable-indev=jack --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-openal --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libvorbis --enable-libv4l2 --enable-libx264 --enable-libx265 --enable-libxvid --enable-x11grab --enable-avfilter --enable-avresample --enable-postproc --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-stripping --shlibdir=/usr/lib64 --enable-runtime-cpudetect 
    [3] => libavutil  54. 20.100/54. 20.100 
    [4] => libavcodec  56. 26.100/56. 26.100 
    [5] => libavformat 56. 25.101/56. 25.101 
    [6] => libavdevice 56. 4.100/56. 4.100 
    [7] => libavfilter  5. 11.102/5. 11.102 
    [8] => libavresample 2. 1. 0/2. 1. 0 
    [9] => libswscale  3. 1.101/3. 1.101 
    [10] => libswresample 1. 1.100/1. 1.100 
    [11] => libpostproc 53. 3.100/53. 3.100 
    [12] => [mp3 @ 0x1d62bc0] Estimating duration from bitrate, this may be inaccurate 
    [13] => Input #0, mp3, from '/home/example/public_html/wp-content/channels/videos/temp_1473937603.mp3': 
    [14] => Duration: 00:06:51.05, start: 0.000000, bitrate: 64 kb/s 
    [15] =>  Stream #0:0: Audio: mp3, 16000 Hz, stereo, s16p, 64 kb/s 
    [16] => [mjpeg @ 0x1d73de0] Changeing bps to 8 
    [17] => Input #1, image2, from '/home/examples/public_html/wp-content/channels/thumbnails/thumbnail_516919517.jpg': 
    [18] => Duration: 00:00:00.50, start: 0.000000, bitrate: N/A 
    [19] =>  Stream #1:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 250x135 [SAR 1:1 DAR 50:27], 2 fps, 2 tbr, 2 tbn, 2 tbc 
    [20] => No pixel format specified, yuvj420p for H.264 encoding chosen. 
    [21] => Use -pix_fmt yuv420p for compatibility with outdated media players. 
    [22] => [libx264 @ 0x1d75240] height not divisible by 2 (250x135) 
    [23] => Output #0, mp4, to '/home/example/public_html/wp-content/channels/videos/temp_1473937603.mp4': 
    [24] =>  Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 2 fps 
    [25] =>  Metadata: 
    [26] =>  encoder   : Lavc56.26.100 libx264 
    [27] =>  Stream #0:1: Audio: none, 0 channels, 128 kb/s 
    [28] => Stream mapping: 
    [29] => Stream #1:0 -> #0:0 (mjpeg (native) -> h264 (libx264)) 
    [30] => Stream #0:0 -> #0:1 (copy) 
    [31] => Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height 
) 

爲什麼這個工作時,我手動conversion.php執行腳本,但是當我通過cron運行conversion.php我得到上述錯誤?

+0

請把完整的腳本文件conversion.php –

+0

@AMitGuad文件過大後,但它的工作原理手動。 – mdnba50

回答

1

,因爲它說,在控制檯:[libx264 @ 0x1d75240] height not divisible by 2 (250x135)

添加-vf "scale='2*trunc(iw/2)':'2*trunc(ih/2)'"

+0

我在哪裏把這個放在我的命令?我是一個ffmpeg的新手。 – mdnba50

+0

上次輸入'-i $ input_file'之後和輸出名稱'$ videoPath'之前的任何位置 – Mulvya

相關問題