Reputation:
con.txt
file one.mp4
file two.mp4
The command
ffmpeg -f concat -safe 0 -i con.txt out.mp4
produces a video that doesn't contain the first second of two.mp4
.
ffprobe two.mp4
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'two.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
Duration: 00:00:15.20, start: 0.000000, bitrate: 1644 kb/s
Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p, 428x640, 1644 kb/s, 10 fps, 10 tbr, 10240 tbn, 20 tbc (default)
Metadata:
handler_name : VideoHandler
vendor_id : [0][0][0][0]
I get an interesting error attempting another concatenation method (neither video has audio btw)
ffmpeg -i one.mp4 -i two.mp4 -filter_complex "[0:v] [1:v] concat=n=2:v=1:a=0 [v]" -map "[v]" out.mp4
Input link in0:v0 parameters (size 428x640, SAR 0:1) do not match the corresponding output link in0:v0 parameters (428x640, SAR 1576:1575)
How can I join these two videos together sequentially without losing any frames from either?
Upvotes: 0
Views: 315
Reputation: 5463
The concat
filter expects the streams to be concatenated to have the identical properties (size, sample aspect ratio (SAR), pix_fmt, etc.). The error message is saying that SARs are not matching up. You can insert setsar
filters upstream of concat
filter to resolve this. Assuming these videos have square pixels (1576:1575 is pretty darn close to 1:1), we can do this:
ffmpeg -i one.mp4 -i two.mp4 \
-filter_complex "[0:v]setsar=1:1[L0]; \
[1:v]setsar=1:1,fps=30[L1]; \
[L0][L1]concat=n=2:v=1:a=0 [v] " \
-map "[v]" out.mp4
If you get other errors, you need to prepend more filters to condition your streams to match each other.
Edit: Added fps
filter to the second video (10 fps) to match the first (30 fps)
Upvotes: 1