I would like to create a new movie from a JPG image and some movie file using ffmpeg. The image should be displayed for some seconds at the beginning of the movie. This can be achieved using the command
ffmpeg -loop 1 -framerate 60 -t 8 -i image.jpg -t 8 -f lavfi -i aevalsrc=0 -i movie.mp4 -filter_complex '[0:0] [1:0] [2:0] [2:1] concat=n=2:v=1:a=1' output.mp4
Here the framerate is 60fps and the image is shown for 8 seconds. This all works fine, but takes a lot of time as everything is encoded again. Instead I tried to create a movie from the image first using
ffmpeg -loop 1 -framerate 60 -i image.jpg -c:v libx264 -t 8 -pix_fmt yuv420p intro.mp4
and then concatenating the intro to the movie file as described here https://trac.ffmpeg.org/wiki/Concatenate. The second method is significantly faster, but the resulting movie file has no audio. Does anyone know a fast method to do this?
As per the request below, I post ffmpeg -i movie.mp4
, it gives
ffmpeg -i movie.mp4
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
built with Apple clang version 12.0.0 (clang-1200.0.32.2)
configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_1 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
libavutil 56. 51.100 / 56. 51.100
libavcodec 58. 91.100 / 58. 91.100
libavformat 58. 45.100 / 58. 45.100
libavdevice 58. 10.100 / 58. 10.100
libavfilter 7. 85.100 / 7. 85.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 7.100 / 5. 7.100
libswresample 3. 7.100 / 3. 7.100
libpostproc 55. 7.100 / 55. 7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'movie.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.45.100
Duration: 00:01:36.55, start: 0.000000, bitrate: 445 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc), 1488x1116, 301 kb/s, 60 fps, 60 tbr, 15360 tbn, 120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 131 kb/s (default)
Metadata:
handler_name : SoundHandler