0

I copied this command ffmpeg -framerate 1/5 -i img%03d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4 from https://trac.ffmpeg.org/wiki/Slideshow but everytime I run it I get the error of:

"Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height"

And if I move the output like this: ffmpeg -framerate 1/5 -i img%03d.png out.mp4 -c:v libx264 -r 30 -pix_fmt yuv420p then a video is created, it say 5-10 seconds, but the progress bar does not move and it is just black.

I've also looked at How to create a video from images with FFmpeg? but I basically get the same results.

Is there anything that I'm missing? Any feedback would be appreciated, thanks.

Full message:

int(1) array(21) { [0]=> string(79) "ffmpeg version 4.3.1-0york0~18.04 Copyright
 (c) 2000-2020 the FFmpeg developers" [1]=> string(48) " built with gcc 7 (Ubuntu 
7.5.0-3ubuntu1~18.04)" [2]=> string(1280) " configuration: --prefix=/usr --extra-
version='0york0~18.04' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --
incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-
stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-
ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --
enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-
libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-
libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-
libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-
librabbitmq --enable-librsvg --enable-librubberband --enable-libshine --enable-
libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --
enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --
enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-
libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-
omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-
libzimg --enable-pocketsphinx --enable-libdc1394 --enable-libdrm --enable-
libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-
shared" [3]=> string(40) " libavutil 56. 51.100 / 56. 51.100" [4]=> string(40) "
 libavcodec 58. 91.100 / 58. 91.100" [5]=> string(40) " libavformat 58. 45.100 / 
58. 45.100" [6]=> string(40) " libavdevice 58. 10.100 / 58. 10.100" [7]=> 
string(40) " libavfilter 7. 85.100 / 7. 85.100" [8]=> string(40) " libavresample 
4. 0. 0 / 4. 0. 0" [9]=> string(40) " libswscale 5. 7.100 / 5. 7.100" [10]=>
 string(40) " libswresample 3. 7.100 / 3. 7.100" [11]=> string(40) " libpostproc 
55. 7.100 / 55. 7.100" [12]=> string(37) "Input #0, image2, from 'img%03d.png':" 
[13]=> string(54) " Duration: 00:00:10.00, start: 0.000000, bitrate: N/A" [14]=> 
string(76) " Stream #0:0: Video: png, rgba(pc), 361x363, 0.20 tbr, 0.20 tbn, 0.20 
tbc" [15]=> string(15) "Stream mapping:" [16]=> string(54) " Stream #0:0 -> #0:0 
(png (native) -> h264 (libx264))" [17]=> string(31) "Press [q] to stop, [?] for 
help" [18]=> string(61) "[libx264 @ 0x55b5d0189c80] width not divisible by 2 
(361x363)" [19]=> string(159) "Error initializing output stream 0:0 -- Error 
while opening encoder for output stream #0:0 - maybe incorrect parameters such as 
bit_rate, rate, width or height" [20]=> string(18) "Conversion failed!" }

Ted Bed
  • 57
  • 7
  • Okay thanks I'll edit my question. – Ted Bed Nov 23 '20 at 20:23
  • 1
    `width not divisible by 2`. New command as shown in duplicate question [FFMPEG (libx264) “height not divisible by 2”](https://stackoverflow.com/a/29582287/): `ffmpeg -framerate 1/5 -i img%03d.png -c:v libx264 -r 30 -vf "crop=trunc(iw/2)*2:trunc(ih/2)*2,format=yuv420p" out.mp4` – llogan Nov 23 '20 at 20:37
  • Okay thanks, just now if I use a command like this: `ffmpeg -framerate 30 -i img%03d.png -vcodec libx264 -y -an -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" -pix_fmt yuv420p video.mp4` it only uses and show the last image in the series. Could you help me with this? Also is there a forum like slack so I could ask more informal questions like this? – Ted Bed Nov 23 '20 at 21:37
  • I heard of an unofficial ffmpeg Discord (I think that's the platform) channel but I've never used Discord. If you use IRC see #ffmpeg which is official. As for only last image showing, do all of your images have the same attributes? Width, height, format, etc? – llogan Nov 23 '20 at 23:11
  • All of the images are pngs but they have different heights and widths. – Ted Bed Nov 24 '20 at 00:50
  • They all have to be the same. You can do this by using filters in ffmpeg. See example *Using input images that each vary in size* in answer to [Resizing videos with ffmpeg to fit into specific size](https://superuser.com/a/1136305/). – llogan Nov 24 '20 at 02:53
  • I tried `ffmpeg -framerate 30 -i img%03d.png -vcodec libx264 -y -an -vf "scale=1280:720:force_original_aspect_ratio=decrease:eval=frame,pad=1280:720:-1:-1:color=black" -pix_fmt yuv420p video.mp4 2>&1` and it somewhat worked 1 time, but I can't seem to replicate the result anymore. Now it again only shows the last image. – Ted Bed Nov 24 '20 at 06:18
  • It's a new problem than your original question. You can ask a new question (at [su] so it doesn't get closed here at [so] which is for programming questions). Make sure to show your command and the complete log. – llogan Nov 26 '20 at 03:39
  • Okay thanks I'll look there for future questions. Luckily I found a solution to my problem, thanks for helping me get there. – Ted Bed Nov 27 '20 at 04:37

0 Answers0