How to successfully use ffmpeg to convert images into videos

ffmpeg

Solution

Your console output shows that you are writing 4:4:4 H.264 output, which very few players support. (Newer versions of FFmpeg warn about that.) Add `-pix_fmt yuv420p` before the output file to convert to the widely supported 4:2:0 pixel format. You could additionally include `-profile:v baseline` to make it work on even more players. (These options apply to encoding, so don't use them on the command that specifies `-codec copy`.) You could also try playing your output file with `ffplay`, which is one of the few players that support 4:4:4 H.264 in mp4 files.

If you want the same duration for each image and they are consecutively numbered, you only need a single command such as:

ffmpeg -framerate 0.2 -i %3d.jpg -vf fps=10 -pix_fmt yuv420p output.mp4

The `-framerate 0.2` sets the input frame rate to 0.2 frames per second (1 frame every 5 seconds). `%3d` is replaced by 3 digits `000`, `001`, etc. for each frame. `-vf fps=10` will change the frame rate to 10 frames per second, in this case by duplicating input frames; it is not strictly necessary but can be helpful with low frame rates to make seeking smoother and ensure the full duration for the first and last images, and should not increase the output size by much since frames that are identical to the previous frame can be encoded in a small size.

If you want to continue using the `concat` demuxer, or want different file names or durations for each image, you can specify the image directly with a duration for each one in your `inputs.txt`. There is no need to create a separate movie file for each image. For example:

file 000.jpg
duration 5
file 001.jpg
duration 5
...

Then use the concat demuxer to concatenate them and perform the encoding at the same time:

ffmpeg -f concat -i inputs.txt -vf fps=10 -pix_fmt yuv420p output.mp4

If any of these things don't work, upgrade your FFmpeg to the latest version.

Problem

Currently I'm trying to make 5 second videos for each image and then combining them using concat, but I'm having a lot of issues doing this. Here is my code: ffmpeg -loop 1 -i 000.jpg -t 5 000.mp4 ffmpeg -loop 1 -i 001.jpg -t 5 001.mp4 ffmpeg -f concat -i inputs.txt -codec copy output.mp4 inputs.txt lists the following file '000.mp4' file '001.mp4' Now when I try all of this, I run the output mp4 file and the first part of it works fine, but then once it starts displaying the 001 part of the video, it switches to a gray screen. It doesn't even do that in the stand-alone file 001.mp4. Any suggestions on what's going on or what I could do fix this? I've tried so many other things too. Like switching all the files over to png instead, which gave the same issue. I also tried using different output file types like wmv, avi, etc. I'm still very new though so I don't know what else to try. This is what shows up in my command prompt after running the command. ``` C:\xampp\htdocs\images>ffmpeg -f concat -i inputs.txt -codec copy output.mp4 ffmpeg version N-50911-g9efcfbe Copyright (c) 2000-2013 the FFmpeg developers built on Mar 13 2013 21:26:48 with gcc 4.7.2 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libg sm --enable-libilbc --enable-libmp3lame --enable-libopencore-amrnb --enable-libo pencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-li bschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-lib twolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enabl e-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 19.100 / 52. 19.100 libavcodec 55. 0.100 / 55. 0.100 libavformat 55. 0.100 / 55. 0.100 libavdevice 54. 4.100 / 54. 4.100 libavfilter 3. 45.103 / 3. 45.103 libswscale 2. 2.100 / 2. 2.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 2.100 / 52. 2.100 [concat @ 003b9660] Estimating duration from bitrate, this may be inaccurate Input #0, concat, from 'inputs.txt': Duration: 00:00:00.01, start: 0.000000, bitrate: 28 kb/s Stream #0:0: Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444 p, 800x600 [SAR 1:1 DAR 4:3], 28 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc Output #0, mp4, to 'output.mp4': Metadata: encoder : Lavf55.0.100 Stream #0:0: Video: h264 ([33][0][0][0] / 0x0021), yuv444p, 800x600 [SAR 1:1 DAR 4:3], q=2-31, 28 kb/s, 25 fps, 12800 tbn, 12800 tbc Stream mapping: Stream #0:0 -> #0:0 (copy) Press [q] to stop, [?] for help frame= 250 fps=0.0 q=-1.0 Lsize= 31kB time=00:00:09.88 bitrate= 26.1kbits /s video:28kB audio:0kB subtitle:0 global headers:0kB muxing overhead 13.534948% C:\xampp\htdocs\images> ```

Original source