gpt4 book ai didi

php - ffmpeg 手动工作,但不能与 cron 一起工作?

转载 作者:行者123 更新时间:2023-12-04 22:59:55 26 4
gpt4 key购买 nike

当我手动运行脚本时,我可以成功地将 mp3 + 音频转换为 mp4。

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 中的脚本时,为什么会这样?但是当我运行 conversion.php通过cron我得到上述错误?

最佳答案

正如它所说,在控制台中:[libx264 @ 0x1d75240] height not divisible by 2 (250x135)
添加 -vf "scale='2*trunc(iw/2)':'2*trunc(ih/2)'"

关于php - ffmpeg 手动工作,但不能与 cron 一起工作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43736860/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com