Reputation: 702
I'm trying to merge multiple videos using ffmpeg but the output of concat is half the size of original videos. Below is the ffmpeg command,
ffmpeg -f concat -safe 0 -i input.txt -c copy video.mp4
All the videos in input file have been split from a big file and converted using the below command,
ffmpeg -i file1.mp4 -vcodec libx264 -filter_complex "[0:v]scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2[va]" -map "[va]" -strict experimental _file1.mp4
They do not have any audio stream to them, so when I try to concat these videos the output file duration is smaller than the original videos combined.
Below is the metadata for the input files,
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file1.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.26.100
comment : vid:v09044eb0000bhte9i09pog20dbdosn0
genre : aweme_6659292261320329989
Duration: 00:00:15.12, start: 0.000000, bitrate: 797 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 794 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
Metadata:
handler_name : VideoHandler
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.26.100
comment : vid:v09044a50000bjqkic7smmqi0mu76m20
genre : aweme_6697675734137228038
Duration: 00:00:14.60, start: 0.000000, bitrate: 718 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 715 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file3.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.26.100
comment : vid:v09044e50000bj0ajcqvfskris7ip2e0
Duration: 00:00:15.50, start: 0.000000, bitrate: 548 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 544 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
Metadata:
handler_name : VideoHandler
Upvotes: 0
Views: 1503
Reputation: 11
If you need to scale one video to match another without pre-defining the dimensions, see the scale2ref filter.
Two videos are provided for input and output. The 1st input is scaled and the 2nd input is unchanged, but used for reference. For example, to put 2 videos side-by-side and have the 2nd video scale to match the first:
ffmpeg -i vid1.mp4 -i vid2.mp4 -filter_complex "[1:v][0:v]scale2ref=oh*mdar:h=in_h:[v1][v0];[v0][v1]hstack[vo]" -map "[vo]" ./output-video.mp4
Upvotes: 1
Reputation: 92928
All inputs don't have the same timebase. First one has 30k tbn
whereas the others have 15360 tbn
.
Convert timebase using the following command and then concat with the new files:
ffmpeg -i file2.mp4 -c copy -video_track_timescale 30k file2-30k.mp4
Upvotes: 2