
If in doubt about which method to use, try the concat demuxer. This method does not work for many formats, including MP4, due to the nature of these formats and the simplistic concatenation performed by this method. Do not use with MP4.įfmpeg -i "concat:input1|input2" -codec copy output.mkv Use this method with formats that support file-level concatenation (MPEG-1, MPEG-2 PS, DV). (echo file 'first file.mp4' & echo file 'second file.mp4' )>list.txtįfmpeg -safe 0 -f concat -i list.txt -c copy output.mp4 $ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4 Use this method when you want to avoid a re-encode and your format does not support file-level concatenation (most files used by general users do not support file-level concatenation). If you want to avoid the re-encode, you could re-encode just the inputs that don't match so they share the same codec and other parameters, then use the concat demuxer to avoid re-encoding everything.įfmpeg -i opening.mkv -i episode.mkv -i ending.mkv \ Note that this method performs a re-encode of all inputs. Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 9313 kb/s, 29.75 fps, 29.97 tbr, 16k tbn, 59.Use this method if your inputs do not have the same parameters (width, height, etc), or are not the same formats/codecs, or if you want to perform any filtering.

concat Virtual concatenation script demuxer. Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'concat.mp4':ĭuration: 00:41:23.73, start: 0.000000, bitrate: 9392 kb/s Demuxers are configured elements in FFmpeg that can read the multimedia. Resulting video: ffprobe version 4.0-static Copyright (c) 2007-2018 the FFmpeg developers Second file: ffprobe version 4.0-static Copyright (c) 2007-2018 the FFmpeg developers You can specify different durations for each image: file 'happy1. We specify a duration (2 seconds) that each image will be displayed for. Below, we create a file labelled input.txt and add a list of images for the slideshow.

Stream #0:1: Audio: vorbis, 48000 Hz, mono, fltp You can use the concat demuxer to concatenate images listed in a file. List file 'lst' contains: file test_000.mkvįfprobe for the first two files, they all differ by duration only: ffprobe version 4.0-static Ĭopyright (c) 2007-2018 the FFmpeg developersīuilt with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516Ĭonfiguration: -enable-gpl -enable-version3 -enable-static -disable-debug -disable-ffplay -disable-indev=sndio -disable-outdev=sndio -cc=gcc-6 -enable-libxml2 -enable-fontconfig -enable-frei0r -enable-gnutls -enable-gray -enable-libaom -enable-libfribidi -enable-libass -enable-libfreetype -enable-libmp3lame -enable-libopencore-amrnb -enable-libopencore-amrwb -enable-libopenjpeg -enable-librubberband -enable-libsoxr -enable-libspeex -enable-libvorbis -enable-libopus -enable-libtheora -enable-libvidstab -enable-libvo-amrwbenc -enable-libvpx -enable-libwebp -enable-libx264 -enable-libx265 -enable-libxml2 -enable-libxvid -enable-libzimg Here is my original concat command: ffmpeg -f concat -safe 0 -i lst -c copy -y concat.mp4

I counted frames of all input files and frames of the resulting video and the number of frames is the same, so the problem is in fps.Īlso I tried to re-encode instead of copy and get proper 29.95 fps but the duration is still longer than the original, number of frames also increased. How can I concatenate the files and get the expected duration without frame rate change? I concatenate them all back into one long video and this video gets longer duration than the sum of durations of the small files.Īll small files have 29.95 fps but the concatenated video has 29.75 fps and I do the -c copy, why does it change? I have 239 small MKV video files with identical characteristics (they were cut from the original video with the same command but different -ss -t parameters).
