My text file list_of_fragments
contains the list of video files to be concatenated.
I assumed they have the same streams (shot from the same smartphone, with the same settings)
file barbell-home.mp4
file before.mp4
file before-otherview.mp4
file rotated.tr.mp4
file squatting-rack.mp4
I attempted to concatenate them all with: ffmpeg -loglevel warning -hide_banner -f concat -safe 0 -i list_of_fragments -c copy conc-output.mp4
Sadly, the video corresponding to the files before.mp4
, before-otherview.mp4
, rotated.tr.mp4
, squatting-rack.mp4
was flipped upside down, i.e. rotated 180 degrees (the part corresponding to barbell-home.mp4
was not rotated).
ffprobe
returns (for the sake of brevity I've not included audio streams):
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'barbell-home.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2022-10-30T15:11:45.000000Z
com.android.version: 11
Duration: 00:00:02.05, start: 0.000000, bitrate: 21155 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20059 kb/s, SAR 1:1 DAR 16:9, 29.92 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
Metadata:
rotate : 180
creation_time : 2022-10-30T15:11:45.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Side data:
displaymatrix: rotation of -180.00 degrees
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'before.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2022-10-26T11:50:04.000000Z
com.android.version: 11
Duration: 00:00:04.22, start: 0.000000, bitrate: 21335 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20384 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2022-10-26T11:50:04.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'before-otherview.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: isommp42
creation_time : 2022-10-26T11:50:15.000000Z
com.android.version: 11
Duration: 00:00:02.47, start: 0.000000, bitrate: 21370 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20377 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
Metadata:
creation_time : 2022-10-26T11:50:15.000000Z
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'rotated.tr.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:00:04.85, start: 0.000000, bitrate: 25889 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 25605 kb/s, 29.92 fps, 29.92 tbr, 11488 tbn, 59.83 tbc (default)
Metadata:
handler_name : VideoHandle
vendor_id : [0][0][0][0]
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'squatting-rack.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:00:01.77, start: 0.021000, bitrate: 19986 kb/s
Stream #0:0(eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 20105 kb/s, SAR 1:1 DAR 16:9, 29.94 fps, 29.92 tbr, 90k tbn, 180k tbc (default)
Metadata:
handler_name : VideoHandle
vendor_id : [0][0][0][0]
After taking a closer look at ffprobe
's output I realized:
- The files differ in their bitrate.
- Only the first file does
rotate : 180
in the metadata of its video stream.
My questions:
- Why does only
barbell-home.mp4
haverotate : 180
in the metadata of its video stream and what is the significance of it when concatenating withffmpeg
? - Adding
-noautorotate
to the command,ffmpeg -loglevel warning -hide_banner -f concat -safe 0 -noautorotate -i list_of_fragments -c copy conc-output.mp4
, does not change the output? Why so? - Should I add
rotate : 180
to the rest of the files or should I removerotate : 180
frombarbell-home.mp4
before proceeding to concatenate them all? If so, how might I accomplish this? - How might I concatenate the files in question without flipping the video upside-down?