I have a large video file (2.2 GB) and one part of the video is not oriented in the correct way: the first part is fine, but the second part is rotated by 180 degrees (480*1066 pixels). To solve the problem I used FFmpeg.
I used this command to split the video file into two parts
ffmpeg -i input.mp4 -t 00:14:36 -c copy 1.mp4 -ss 00:14:36 -c copy 2.mp4
I changed the metadata of the second video file so that it matches the orientation of the first one when read:
ffmpeg -i 2.mp4 metadata:v:s:0 "rotate=180" -c copy 20.mp4
I merged the 2 files together with this command:
ffmpeg -f concat -i merge.txt -c copy OUTPUT-MERGED.mkv
Where merge.txt lists the two files, 1.mp4 and 20.mp4.
The problem is, this does not work ; changing the metadata of the second video file does not seem to be taken into account when ffmpeg merges the two files at the end, the result is strictly the same as the input video file.
Is there a way to do what I want without encoding one of the two files?
The input file has these infos:
Metadata:
rotate : 90
creation_time : 2021-05-07T09:26:43.000000Z
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
And the two separate files have these infos:
1.mp4
Metadata:
rotate : 90
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -90.00 degrees
20.mp4
Metadata:
rotate : 180
handler_name : VideoHandle
Side data:
displaymatrix: rotation of -180.00 degrees