PHP-FFMpeg Error while opening encoder for output stream





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ height:90px;width:728px;box-sizing:border-box;
}







1















I'm trying to use this PHP-FFMpeg library, but I'm keep getting errors like



Error while opening encoder for output stream #0:0


This is my PHP code



private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'timeout' => 0,
]);

$ffmpeg->getFFMpegDriver()->listen(new AlchemyBinaryDriverListenersDebugListener());
$ffmpeg->getFFMpegDriver()->on('debug', function ($message) {
var_dump($message);
});

// Create teaser_video_thumb
$videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
$video = $ffmpeg->open($fullVideoPath);
$video
->filters()
->resize(new FFMpegCoordinateDimension(400, 280))
->synchronize();
$video->save(new FFMpegFormatVideoX264('aac', 'libx264'), $uploadPath . $videoNameThumb);
}


So what I'm trying to do here. User uploads his video and I'm trying to resize it and create one smaller video for the preview. The problem that I'm keep getting it is



ffmpeg version 2.8.15-0ubuntu0.16.04.1' (length=46)
Copyright (c) 2000-2018 the FFmpeg developers' (length=54)
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609' (length=72)
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv' (length=1135)
WARNING: library configuration mismatch' (length=49)
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc' (length=1413)
libavutil 54. 31.100 / 54. 31.100' (length=48)
libavcodec 56. 60.100 / 56. 60.100' (length=48)
libavformat 56. 40.101 / 56. 40.101' (length=48)
libavdevice 56. 4.100 / 56. 4.100' (length=48)
libavfilter 5. 40.101 / 5. 40.101' (length=48)
libavresample 2. 1. 0 / 2. 1. 0' (length=48)
libswscale 3. 1.101 / 3. 1.101' (length=48)
libswresample 1. 2.101 / 1. 2.101' (length=48)
libpostproc 53. 3.100 / 53. 3.100' (length=48)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vagrant/workspace/spot-scouting-adminpage/static/locations/MjY5MjI2Y2E0NDExOWNmZmQwN/teaser/f4095e9eeb364fe187bf1ed42eedc198.mp4':' (length=185)
Metadata:' (length=19)
major_brand : mp42' (length=34)
minor_version : 0' (length=31)
compatible_brands: mp42mp41' (length=39)
creation_time : 2019-01-04 12:46:43' (length=49)
Duration: 00:00:08.41, start: 0.000000, bitrate: 10261 kb/s' (length=69)
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 9982 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)' (length=153)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
encoder : AVC Coding' (length=42)
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)' (length=109)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
-async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000:first_pts=0.' (length=107)
[libx264 @ 0x136f620] height not divisible by 2 (400x225)' (length=65)
Output #0, mp4, to '/home/vagrant/workspace/spot-scouting-adminpage/static/locations/MjY5MjI2Y2E0NDExOWNmZmQwN/teaser/gY0RfV9c0y06592770015466174550YfY9-thumb.mp4':' (length=172)
Metadata:' (length=19)
major_brand : mp42' (length=34)
minor_version : 0' (length=31)
compatible_brands: mp42mp41' (length=39)
Stream #0:0(eng): Video: h264, none, q=2-31, 128 kb/s, 25 fps (default)' (length=83)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
start_time : 0' (length=33)
encoder : Lavc56.60.100 libx264' (length=53)
Stream #0:1(eng): Audio: aac, 0 channels, 128 kb/s (default)' (length=72)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
encoder : Lavc56.60.100 aac' (length=49)
Stream mapping:' (length=23)
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))' (length=63)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))' (length=60)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height' (length=127)
' (length=8)


I can't figure out what is the problem or how to solve it. Can someone please help me out? I'm using Ubuntu 16 and I have installed ffmpeg via apt-get install ffmpeg.
If you need any additional infomations, please let me know and I will provide. Thank you










share|improve this question























  • 1. Please show the actual ffmpeg command being executed by your script. 2. Your ffmpeg is ancient. Download a build from the git master branch and try again. 3. Refer to FFMPEG (libx264) “height not divisible by 2”.

    – llogan
    Jan 4 at 19:28




















1















I'm trying to use this PHP-FFMpeg library, but I'm keep getting errors like



Error while opening encoder for output stream #0:0


This is my PHP code



private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'timeout' => 0,
]);

$ffmpeg->getFFMpegDriver()->listen(new AlchemyBinaryDriverListenersDebugListener());
$ffmpeg->getFFMpegDriver()->on('debug', function ($message) {
var_dump($message);
});

// Create teaser_video_thumb
$videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
$video = $ffmpeg->open($fullVideoPath);
$video
->filters()
->resize(new FFMpegCoordinateDimension(400, 280))
->synchronize();
$video->save(new FFMpegFormatVideoX264('aac', 'libx264'), $uploadPath . $videoNameThumb);
}


So what I'm trying to do here. User uploads his video and I'm trying to resize it and create one smaller video for the preview. The problem that I'm keep getting it is



ffmpeg version 2.8.15-0ubuntu0.16.04.1' (length=46)
Copyright (c) 2000-2018 the FFmpeg developers' (length=54)
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609' (length=72)
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv' (length=1135)
WARNING: library configuration mismatch' (length=49)
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc' (length=1413)
libavutil 54. 31.100 / 54. 31.100' (length=48)
libavcodec 56. 60.100 / 56. 60.100' (length=48)
libavformat 56. 40.101 / 56. 40.101' (length=48)
libavdevice 56. 4.100 / 56. 4.100' (length=48)
libavfilter 5. 40.101 / 5. 40.101' (length=48)
libavresample 2. 1. 0 / 2. 1. 0' (length=48)
libswscale 3. 1.101 / 3. 1.101' (length=48)
libswresample 1. 2.101 / 1. 2.101' (length=48)
libpostproc 53. 3.100 / 53. 3.100' (length=48)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vagrant/workspace/spot-scouting-adminpage/static/locations/MjY5MjI2Y2E0NDExOWNmZmQwN/teaser/f4095e9eeb364fe187bf1ed42eedc198.mp4':' (length=185)
Metadata:' (length=19)
major_brand : mp42' (length=34)
minor_version : 0' (length=31)
compatible_brands: mp42mp41' (length=39)
creation_time : 2019-01-04 12:46:43' (length=49)
Duration: 00:00:08.41, start: 0.000000, bitrate: 10261 kb/s' (length=69)
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 9982 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)' (length=153)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
encoder : AVC Coding' (length=42)
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)' (length=109)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
-async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000:first_pts=0.' (length=107)
[libx264 @ 0x136f620] height not divisible by 2 (400x225)' (length=65)
Output #0, mp4, to '/home/vagrant/workspace/spot-scouting-adminpage/static/locations/MjY5MjI2Y2E0NDExOWNmZmQwN/teaser/gY0RfV9c0y06592770015466174550YfY9-thumb.mp4':' (length=172)
Metadata:' (length=19)
major_brand : mp42' (length=34)
minor_version : 0' (length=31)
compatible_brands: mp42mp41' (length=39)
Stream #0:0(eng): Video: h264, none, q=2-31, 128 kb/s, 25 fps (default)' (length=83)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
start_time : 0' (length=33)
encoder : Lavc56.60.100 libx264' (length=53)
Stream #0:1(eng): Audio: aac, 0 channels, 128 kb/s (default)' (length=72)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
encoder : Lavc56.60.100 aac' (length=49)
Stream mapping:' (length=23)
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))' (length=63)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))' (length=60)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height' (length=127)
' (length=8)


I can't figure out what is the problem or how to solve it. Can someone please help me out? I'm using Ubuntu 16 and I have installed ffmpeg via apt-get install ffmpeg.
If you need any additional infomations, please let me know and I will provide. Thank you










share|improve this question























  • 1. Please show the actual ffmpeg command being executed by your script. 2. Your ffmpeg is ancient. Download a build from the git master branch and try again. 3. Refer to FFMPEG (libx264) “height not divisible by 2”.

    – llogan
    Jan 4 at 19:28
















1












1








1








I'm trying to use this PHP-FFMpeg library, but I'm keep getting errors like



Error while opening encoder for output stream #0:0


This is my PHP code



private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'timeout' => 0,
]);

$ffmpeg->getFFMpegDriver()->listen(new AlchemyBinaryDriverListenersDebugListener());
$ffmpeg->getFFMpegDriver()->on('debug', function ($message) {
var_dump($message);
});

// Create teaser_video_thumb
$videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
$video = $ffmpeg->open($fullVideoPath);
$video
->filters()
->resize(new FFMpegCoordinateDimension(400, 280))
->synchronize();
$video->save(new FFMpegFormatVideoX264('aac', 'libx264'), $uploadPath . $videoNameThumb);
}


So what I'm trying to do here. User uploads his video and I'm trying to resize it and create one smaller video for the preview. The problem that I'm keep getting it is



ffmpeg version 2.8.15-0ubuntu0.16.04.1' (length=46)
Copyright (c) 2000-2018 the FFmpeg developers' (length=54)
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609' (length=72)
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv' (length=1135)
WARNING: library configuration mismatch' (length=49)
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc' (length=1413)
libavutil 54. 31.100 / 54. 31.100' (length=48)
libavcodec 56. 60.100 / 56. 60.100' (length=48)
libavformat 56. 40.101 / 56. 40.101' (length=48)
libavdevice 56. 4.100 / 56. 4.100' (length=48)
libavfilter 5. 40.101 / 5. 40.101' (length=48)
libavresample 2. 1. 0 / 2. 1. 0' (length=48)
libswscale 3. 1.101 / 3. 1.101' (length=48)
libswresample 1. 2.101 / 1. 2.101' (length=48)
libpostproc 53. 3.100 / 53. 3.100' (length=48)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vagrant/workspace/spot-scouting-adminpage/static/locations/MjY5MjI2Y2E0NDExOWNmZmQwN/teaser/f4095e9eeb364fe187bf1ed42eedc198.mp4':' (length=185)
Metadata:' (length=19)
major_brand : mp42' (length=34)
minor_version : 0' (length=31)
compatible_brands: mp42mp41' (length=39)
creation_time : 2019-01-04 12:46:43' (length=49)
Duration: 00:00:08.41, start: 0.000000, bitrate: 10261 kb/s' (length=69)
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 9982 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)' (length=153)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
encoder : AVC Coding' (length=42)
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)' (length=109)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
-async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000:first_pts=0.' (length=107)
[libx264 @ 0x136f620] height not divisible by 2 (400x225)' (length=65)
Output #0, mp4, to '/home/vagrant/workspace/spot-scouting-adminpage/static/locations/MjY5MjI2Y2E0NDExOWNmZmQwN/teaser/gY0RfV9c0y06592770015466174550YfY9-thumb.mp4':' (length=172)
Metadata:' (length=19)
major_brand : mp42' (length=34)
minor_version : 0' (length=31)
compatible_brands: mp42mp41' (length=39)
Stream #0:0(eng): Video: h264, none, q=2-31, 128 kb/s, 25 fps (default)' (length=83)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
start_time : 0' (length=33)
encoder : Lavc56.60.100 libx264' (length=53)
Stream #0:1(eng): Audio: aac, 0 channels, 128 kb/s (default)' (length=72)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
encoder : Lavc56.60.100 aac' (length=49)
Stream mapping:' (length=23)
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))' (length=63)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))' (length=60)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height' (length=127)
' (length=8)


I can't figure out what is the problem or how to solve it. Can someone please help me out? I'm using Ubuntu 16 and I have installed ffmpeg via apt-get install ffmpeg.
If you need any additional infomations, please let me know and I will provide. Thank you










share|improve this question














I'm trying to use this PHP-FFMpeg library, but I'm keep getting errors like



Error while opening encoder for output stream #0:0


This is my PHP code



private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'timeout' => 0,
]);

$ffmpeg->getFFMpegDriver()->listen(new AlchemyBinaryDriverListenersDebugListener());
$ffmpeg->getFFMpegDriver()->on('debug', function ($message) {
var_dump($message);
});

// Create teaser_video_thumb
$videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
$video = $ffmpeg->open($fullVideoPath);
$video
->filters()
->resize(new FFMpegCoordinateDimension(400, 280))
->synchronize();
$video->save(new FFMpegFormatVideoX264('aac', 'libx264'), $uploadPath . $videoNameThumb);
}


So what I'm trying to do here. User uploads his video and I'm trying to resize it and create one smaller video for the preview. The problem that I'm keep getting it is



ffmpeg version 2.8.15-0ubuntu0.16.04.1' (length=46)
Copyright (c) 2000-2018 the FFmpeg developers' (length=54)
built with gcc 5.4.0 (Ubuntu 5.4.0-6ubuntu1~16.04.10) 20160609' (length=72)
configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv' (length=1135)
WARNING: library configuration mismatch' (length=49)
avcodec configuration: --prefix=/usr --extra-version=0ubuntu0.16.04.1 --build-suffix=-ffmpeg --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --cc=cc --cxx=g++ --enable-gpl --enable-shared --disable-stripping --disable-decoder=libopenjpeg --disable-decoder=libschroedinger --enable-avresample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-librtmp --enable-libschroedinger --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxvid --enable-libzvbi --enable-openal --enable-opengl --enable-x11grab --enable-libdc1394 --enable-libiec61883 --enable-libzmq --enable-frei0r --enable-libx264 --enable-libopencv --enable-version3 --disable-doc --disable-programs --disable-avdevice --disable-avfilter --disable-avformat --disable-avresample --disable-postproc --disable-swscale --enable-libopencore_amrnb --enable-libopencore_amrwb --enable-libvo_aacenc --enable-libvo_amrwbenc' (length=1413)
libavutil 54. 31.100 / 54. 31.100' (length=48)
libavcodec 56. 60.100 / 56. 60.100' (length=48)
libavformat 56. 40.101 / 56. 40.101' (length=48)
libavdevice 56. 4.100 / 56. 4.100' (length=48)
libavfilter 5. 40.101 / 5. 40.101' (length=48)
libavresample 2. 1. 0 / 2. 1. 0' (length=48)
libswscale 3. 1.101 / 3. 1.101' (length=48)
libswresample 1. 2.101 / 1. 2.101' (length=48)
libpostproc 53. 3.100 / 53. 3.100' (length=48)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/home/vagrant/workspace/spot-scouting-adminpage/static/locations/MjY5MjI2Y2E0NDExOWNmZmQwN/teaser/f4095e9eeb364fe187bf1ed42eedc198.mp4':' (length=185)
Metadata:' (length=19)
major_brand : mp42' (length=34)
minor_version : 0' (length=31)
compatible_brands: mp42mp41' (length=39)
creation_time : 2019-01-04 12:46:43' (length=49)
Duration: 00:00:08.41, start: 0.000000, bitrate: 10261 kb/s' (length=69)
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 9982 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)' (length=153)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
encoder : AVC Coding' (length=42)
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 317 kb/s (default)' (length=109)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
-async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.100000:first_pts=0.' (length=107)
[libx264 @ 0x136f620] height not divisible by 2 (400x225)' (length=65)
Output #0, mp4, to '/home/vagrant/workspace/spot-scouting-adminpage/static/locations/MjY5MjI2Y2E0NDExOWNmZmQwN/teaser/gY0RfV9c0y06592770015466174550YfY9-thumb.mp4':' (length=172)
Metadata:' (length=19)
major_brand : mp42' (length=34)
minor_version : 0' (length=31)
compatible_brands: mp42mp41' (length=39)
Stream #0:0(eng): Video: h264, none, q=2-31, 128 kb/s, 25 fps (default)' (length=83)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
start_time : 0' (length=33)
encoder : Lavc56.60.100 libx264' (length=53)
Stream #0:1(eng): Audio: aac, 0 channels, 128 kb/s (default)' (length=72)
Metadata:' (length=21)
creation_time : 2019-01-04 12:46:43' (length=51)
handler_name : Alias Data Handler' (length=50)
encoder : Lavc56.60.100 aac' (length=49)
Stream mapping:' (length=23)
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))' (length=63)
Stream #0:1 -> #0:1 (aac (native) -> aac (native))' (length=60)
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height' (length=127)
' (length=8)


I can't figure out what is the problem or how to solve it. Can someone please help me out? I'm using Ubuntu 16 and I have installed ffmpeg via apt-get install ffmpeg.
If you need any additional infomations, please let me know and I will provide. Thank you







php ffmpeg






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Jan 4 at 16:03









Valor_Valor_

1,17742662




1,17742662













  • 1. Please show the actual ffmpeg command being executed by your script. 2. Your ffmpeg is ancient. Download a build from the git master branch and try again. 3. Refer to FFMPEG (libx264) “height not divisible by 2”.

    – llogan
    Jan 4 at 19:28





















  • 1. Please show the actual ffmpeg command being executed by your script. 2. Your ffmpeg is ancient. Download a build from the git master branch and try again. 3. Refer to FFMPEG (libx264) “height not divisible by 2”.

    – llogan
    Jan 4 at 19:28



















1. Please show the actual ffmpeg command being executed by your script. 2. Your ffmpeg is ancient. Download a build from the git master branch and try again. 3. Refer to FFMPEG (libx264) “height not divisible by 2”.

– llogan
Jan 4 at 19:28







1. Please show the actual ffmpeg command being executed by your script. 2. Your ffmpeg is ancient. Download a build from the git master branch and try again. 3. Refer to FFMPEG (libx264) “height not divisible by 2”.

– llogan
Jan 4 at 19:28














1 Answer
1






active

oldest

votes


















0














The solution for me was following. First i have reinstalled my ffmpeg with more latest version.
I did a following



cd
wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
tar xvf ffmpeg-git-amd64-static.tar.xz
sudo mv ffmpeg-git-20190101-amd64-static/ffmpeg ffmpeg-git-20190101-amd64-static/ffprobe /usr/local/bin/
whereis ffmpeg
rm -f ffmpeg-git-amd64-static.tar.xz


Then I have changed the code, to look like following



private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
'ffprobe.binaries' => '/usr/local/bin/ffprobe',
'timeout' => 0,
]);

// Create teaser_video_thumb
$videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
$video = $ffmpeg->open($fullVideoPath);
$video
->filters()
->resize(new FFMpegCoordinateDimension(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT))
->synchronize();

$format = new FFMpegFormatVideoX264();
$format->setVideoCodec('libx264');
$format->setAudioCodec('aac');
$format->setAdditionalParameters( [ '-crf', '10'] );

$video->save($format, $uploadPath . $videoNameThumb);

return [
'thumb' => $databasePath . $videoNameThumb,
];
}


Another problem that I had, was my new video height was not dividable by / 2. So it looks like, ffmpeg needs to have height which can be divided by 2.






share|improve this answer
























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54042386%2fphp-ffmpeg-error-while-opening-encoder-for-output-stream%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The solution for me was following. First i have reinstalled my ffmpeg with more latest version.
    I did a following



    cd
    wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
    tar xvf ffmpeg-git-amd64-static.tar.xz
    sudo mv ffmpeg-git-20190101-amd64-static/ffmpeg ffmpeg-git-20190101-amd64-static/ffprobe /usr/local/bin/
    whereis ffmpeg
    rm -f ffmpeg-git-amd64-static.tar.xz


    Then I have changed the code, to look like following



    private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
    $ffmpeg = FFMpeg::create([
    'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
    'ffprobe.binaries' => '/usr/local/bin/ffprobe',
    'timeout' => 0,
    ]);

    // Create teaser_video_thumb
    $videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
    $video = $ffmpeg->open($fullVideoPath);
    $video
    ->filters()
    ->resize(new FFMpegCoordinateDimension(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT))
    ->synchronize();

    $format = new FFMpegFormatVideoX264();
    $format->setVideoCodec('libx264');
    $format->setAudioCodec('aac');
    $format->setAdditionalParameters( [ '-crf', '10'] );

    $video->save($format, $uploadPath . $videoNameThumb);

    return [
    'thumb' => $databasePath . $videoNameThumb,
    ];
    }


    Another problem that I had, was my new video height was not dividable by / 2. So it looks like, ffmpeg needs to have height which can be divided by 2.






    share|improve this answer




























      0














      The solution for me was following. First i have reinstalled my ffmpeg with more latest version.
      I did a following



      cd
      wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
      tar xvf ffmpeg-git-amd64-static.tar.xz
      sudo mv ffmpeg-git-20190101-amd64-static/ffmpeg ffmpeg-git-20190101-amd64-static/ffprobe /usr/local/bin/
      whereis ffmpeg
      rm -f ffmpeg-git-amd64-static.tar.xz


      Then I have changed the code, to look like following



      private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
      $ffmpeg = FFMpeg::create([
      'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
      'ffprobe.binaries' => '/usr/local/bin/ffprobe',
      'timeout' => 0,
      ]);

      // Create teaser_video_thumb
      $videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
      $video = $ffmpeg->open($fullVideoPath);
      $video
      ->filters()
      ->resize(new FFMpegCoordinateDimension(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT))
      ->synchronize();

      $format = new FFMpegFormatVideoX264();
      $format->setVideoCodec('libx264');
      $format->setAudioCodec('aac');
      $format->setAdditionalParameters( [ '-crf', '10'] );

      $video->save($format, $uploadPath . $videoNameThumb);

      return [
      'thumb' => $databasePath . $videoNameThumb,
      ];
      }


      Another problem that I had, was my new video height was not dividable by / 2. So it looks like, ffmpeg needs to have height which can be divided by 2.






      share|improve this answer


























        0












        0








        0







        The solution for me was following. First i have reinstalled my ffmpeg with more latest version.
        I did a following



        cd
        wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
        tar xvf ffmpeg-git-amd64-static.tar.xz
        sudo mv ffmpeg-git-20190101-amd64-static/ffmpeg ffmpeg-git-20190101-amd64-static/ffprobe /usr/local/bin/
        whereis ffmpeg
        rm -f ffmpeg-git-amd64-static.tar.xz


        Then I have changed the code, to look like following



        private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
        $ffmpeg = FFMpeg::create([
        'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
        'ffprobe.binaries' => '/usr/local/bin/ffprobe',
        'timeout' => 0,
        ]);

        // Create teaser_video_thumb
        $videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
        $video = $ffmpeg->open($fullVideoPath);
        $video
        ->filters()
        ->resize(new FFMpegCoordinateDimension(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT))
        ->synchronize();

        $format = new FFMpegFormatVideoX264();
        $format->setVideoCodec('libx264');
        $format->setAudioCodec('aac');
        $format->setAdditionalParameters( [ '-crf', '10'] );

        $video->save($format, $uploadPath . $videoNameThumb);

        return [
        'thumb' => $databasePath . $videoNameThumb,
        ];
        }


        Another problem that I had, was my new video height was not dividable by / 2. So it looks like, ffmpeg needs to have height which can be divided by 2.






        share|improve this answer













        The solution for me was following. First i have reinstalled my ffmpeg with more latest version.
        I did a following



        cd
        wget https://johnvansickle.com/ffmpeg/builds/ffmpeg-git-amd64-static.tar.xz
        tar xvf ffmpeg-git-amd64-static.tar.xz
        sudo mv ffmpeg-git-20190101-amd64-static/ffmpeg ffmpeg-git-20190101-amd64-static/ffprobe /usr/local/bin/
        whereis ffmpeg
        rm -f ffmpeg-git-amd64-static.tar.xz


        Then I have changed the code, to look like following



        private function createTeaserVideos($fullVideoPath, $databasePath, $uploadPath) {
        $ffmpeg = FFMpeg::create([
        'ffmpeg.binaries' => '/usr/local/bin/ffmpeg',
        'ffprobe.binaries' => '/usr/local/bin/ffprobe',
        'timeout' => 0,
        ]);

        // Create teaser_video_thumb
        $videoNameThumb = $this->randomTimeString() . '-thumb.mp4';
        $video = $ffmpeg->open($fullVideoPath);
        $video
        ->filters()
        ->resize(new FFMpegCoordinateDimension(THUMBNAIL_WIDTH, THUMBNAIL_HEIGHT))
        ->synchronize();

        $format = new FFMpegFormatVideoX264();
        $format->setVideoCodec('libx264');
        $format->setAudioCodec('aac');
        $format->setAdditionalParameters( [ '-crf', '10'] );

        $video->save($format, $uploadPath . $videoNameThumb);

        return [
        'thumb' => $databasePath . $videoNameThumb,
        ];
        }


        Another problem that I had, was my new video height was not dividable by / 2. So it looks like, ffmpeg needs to have height which can be divided by 2.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 5 at 8:01









        Valor_Valor_

        1,17742662




        1,17742662
































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f54042386%2fphp-ffmpeg-error-while-opening-encoder-for-output-stream%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Monofisismo

            Angular Downloading a file using contenturl with Basic Authentication

            Olmecas