Ffmpeg concat makes video longer

I have 2 video files that I want to execute with ffmpeg

initial.mp4 Video: h264 (high) (avc1 / 0x31637661), yuv420p (tv), 720x720, 1077 kb / s, 15.98 fps, 16 tbr, 600 tbn, 1200 tbc (default)

ending.mp4 Video: h264 (high) (avc1 / 0x31637661), yuv420p (tv, bt470bg), 720x720 [SAR 1: 1 DAR 1: 1], 1287 kb / s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default

video_instructions_with_ending.txt

file initial.mp4
file initial.mp4
file initial.mp4
file ending.mp4

      

FFmpeg Team

ffmpeg -f concat -i video_instructions_with_ending.txt -c copy output.mp4 -y

      

output.mp4 Video: h264 (high) (avc1 / 0x31637661), yuv420p (tv), 720x720, 27 kb / s, 0.43 fps, 48 โ€‹โ€‹tbr, 19200 tbn, 38400 tbc (default)

The output file should be 6 seconds long. But the output file is 3min and 32 seconds.

Any help would be appreciated

For the files I used, you can get them from: HERE

+3


source to share


2 answers


I tried the following command and it worked for me

ffmpeg -i initial.mp4 -i initial.mp4 -i initial.mp4 -i ending.mp4 -filter_complex concat=n=4:v=1:a=0 -f MOV output.mp4 -y

      

Explanation: FFmpeg has three concat methods



  • concat protocol (ffmpeg -i 'concat: input1 | input2' -cocec copy output). - use it for binary compatible files like avi, mpeg-ts
  • concat demuxer (method you explained) - use when you want to avoid re-encoding and your format does not support file level concatenation.
  • concat filter: (above answer) - use if you need to recode, for example when applying filters.

3 options are suitable for the scenario, since we need to recode the files.

+1


source


Run this command in ending.mp4

and then compare with the new file:

ffmpeg -i ending.mp4 -c copy -video_track_timescale 600 newending.mp4

      



In short, the time bases are different, so the final video is extended. See fooobar.com/questions/845729 / ... for context on timestamps and basics.

+1


source







All Articles