When I concat videos in this command:
ffmpeg -f concat -safe 0 -i filelist.txt -c copy -y new.mp4
And filelist.txt
is:
file 'video1_new.mp4'
file 'new3.mp4'
file 'video2_new.mp4'
I got
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7fe0eec052c0] Auto-inserting h264_mp4toannexb bitstream filter
[mp4 @ 0x7fe0eea04380] Non-monotonic DTS in output stream 0:1; previous: 9188352, current: 9187776; changing to 9188353. This may result in incorrect timestamps in the output file.
This warning results in unpredictable things while being played in certain players, so I can’t the result video directly.
I have converted my videos to the same attributes by:
ffmpeg -i video1.mp4 -r 25 -c:v libx264 -c:a aac -vf setpts=PTS-STARTPTS video1_new.mp4
ffmpeg -i video2.mp4 -r 25 -c:v libx264 -c:a aac -vf setpts=PTS-STARTPTS video2_new.mp4
ffmpeg -i output.mp4 -r 25 -c:v libx264 -c:a aac -map "0:v" -map "0:a" -vf setpts=PTS-STARTPTS -y new3.mp4
The results of ffprobe are:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video1_new.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf60.16.100
Duration: 00:03:11.41, start: 0.000000, bitrate: 349 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1900x810, 271 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Metadata:
handler_name : Core Media Video
vendor_id : [0][0][0][0]
encoder : Lavc60.31.102 libx264
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 71 kb/s (default)
Metadata:
handler_name : Core Media Audio
vendor_id : [0][0][0][0]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video2_new.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf60.16.100
Duration: 00:03:11.41, start: 0.000000, bitrate: 349 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1900x810, 271 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Metadata:
handler_name : Core Media Video
vendor_id : [0][0][0][0]
encoder : Lavc60.31.102 libx264
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 71 kb/s (default)
Metadata:
handler_name : Core Media Audio
vendor_id : [0][0][0][0]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'new3.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf60.16.100
Duration: 00:00:30.02, start: 0.000000, bitrate: 19 kb/s
Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1900x810 [SAR 1:1 DAR 190:81], 11 kb/s, 25 fps, 25 tbr, 12800 tbn (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
encoder : Lavc60.31.102 libx264
Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 1 kb/s (default)
Metadata:
handler_name : SoundHandler
vendor_id : [0][0][0][0]
I have solved this by re-encoding while concatting by:
ffmpeg -f concat -safe 0 -i filelist.txt -c:v libx264 -c:a aac -r 25 -y new.mp4
But it cost too much time and too many CPU resources.
Could you tell me how can I solve this problem without re-encoding while concating?
ukkkkkk is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.