1

I try to concatenate two video files a.mov & b.mov on Win 10 using ffmpeg with the following command:

ffmpeg -safe 0 -f concat -i list.txt -vcodec copy -acodec copy c.mov

There are no errors displayed however when I open the resulting file c it has the same length as file a with the last frame appering to be a frame of b. File a is a longer video, file b are credits (couple of seconds) made with ffmpeg from an image file. Both files have the same aspect ratio, size and framerate.

I try to concatenate two video files a.mov & b.mov on Win 10 using ffmpeg with the following command:

ffmpeg -safe 0 -f concat -i list.txt -vcodec copy -acodec copy c.mov

There are no errors displayed however when I open the resulting file c it has the same length as file a with the last frame appering to be a frame of b. File a is a longer video, file b are credits (couple of seconds) made with ffmpeg from an image file. Both files have the same aspect ratio, size and framerate.

Here the log:

  ffmpeg -n -i a.mov -i b.mov 
    ffmpeg version 4.2.3 Copyright (c) 2000-2020 the FFmpeg developers   built with gcc 9.3.1 (GCC) 20200523  configuration: --enable-gpl --enable-version3 --enable-sdl2
    --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt   libavutil      56. 31.100 / 56. 31.100   libavcodec     58. 54.100 /
    58. 54.100   libavformat    58. 29.100 / 58. 29.100   libavdevice    58.  8.100 / 58.  8.100   libavfilter     7. 57.100 /  7. 57.100   libswscale      5.  5.100 /  5.  5.100   libswresample   3.  5.100 / 
    3.  5.100   libpostproc    55.  5.100 / 55.  5.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'a.mov':   Metadata:
        major_brand     : qt
        minor_version   : 512
        compatible_brands: qt
        encoder         : Lavf58.62.100   Duration: 00:31:50.04, start: 0.000000, bitrate: 5309 kb/s
        Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 4151 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
        Metadata:
          handler_name    : Core Media Video
          encoder         : Lavc58.54.100 libx264
        Stream #0:1: Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono, s32 (24 bit), 1152 kb/s (default)
        Metadata:
          handler_name    : SoundHandler Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'b.mov':   Metadata:
        major_brand     : qt
        minor_version   : 512
        compatible_brands: qt
        encoder         : Lavf58.29.100   Duration: 00:00:10.01, start: 0.000000, bitrate: 67 kb/s
        Stream #1:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080, 64 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
        Metadata:
          handler_name    : VideoHandler
          encoder         : Lavc58.54.100 libx264

Thank you.

CEr
  • 13
  • 4
  • The inputs must have some different attributes. They must be the same to concat properly. Show the complete output of: `ffmpeg -n -i a.mp4 -i b.mp4`. This command is only to get file info: its does not output a file. It will provide useful info about the inputs and your `ffmpeg` version. This info is required to provide an answer that you can copy and paste. Copy the **complete** log from that command. [Edit] your question and paste the complete log into your question. Ignore the `At least one output file must be specified error` in the log. – llogan Jan 26 '21 at 17:26
  • Thanks @llogan, did that. – CEr Jan 28 '21 at 17:14

1 Answers1

1

Problems

Your inputs have some different attributes, but they need to be the same to concatenate:

  • The timescales (30k vs 11988) are different. This is probably due to a.mov having 30000/1001 proper NTSC frame rate and b.mov is 29.97. ffprobe can confirm this. The ffmpeg output is for "entertainment purposes only" and reports an abbreviated frame rate.

  • a.mov has audio, but b.mov does not.

To fix it

  1. Re-mux b.mov and add silent audio:

    ffmpeg -i b.mov -f lavfi -i anullsrc=r=48000:cl=mono -c:v copy -c:a pcm_s24le -video_track_timescale 30k -shortest b2.mov
    
  2. Then update list.txt with the new file (b2.mov).

  3. Concatenate:

    ffmpeg -safe 0 -f concat -i list.txt -c copy c.mov
    

Options

  • -f lavfi -i anullsrc=r=48000:cl=mono makes silent audio with 48000 sample rate and mono channel layout. This matches the sample rate and channel layout of a.mov. You can't concatenate an input with audio with an input that has no audio, so this just creates silent filler/dummy audio.

  • -c:v copy stream copy the video.

  • -c:a pcm_s24le chooses the encoder pcm_s24le to create an audio format that matches a.mov.

  • -video_track_timescale 30k sets video timescale to match a.mov. See What is video timescale, timebase, or timestamp in ffmpeg?

  • -shortest ends the output whenever the shortest input ends. Needed because I did not set a duration for anullsrc (using -shortest is easier).

llogan
  • 121,796
  • 28
  • 232
  • 243
  • Thanks again llogan, that worked! I'd be very happy if you would take the time to enlighten me on timescale: I wasn't aware of more than framerate and samplingrate and have no idea what's with that. Looking at your code: - `-f lavfi -i anullsrc=r=48000:cl=mono` creates one channel silence - `-c:v copy` copies the video - `-c:a pcm_s24le -video_track_timescale 30k -shortest` does something witht the audio stream (I suppose). This bit has something to do with my uper question: Timescale is obviously acting on a video's audio? – CEr Feb 02 '21 at 16:44