Ich möchte nur das Rotationsflag in einer MP4-Videodatei ändern. Es gibt viele ähnliche Fragen, die meisten Antworten schlagen vor, sie zu verwenden
ffmpeg -i input.mp4 -map_metadata 0 -metadata:s:v rotate=90 -codec copy output.mp4
Mein Problem mit diesen Lösungen ist, dass, obwohl die meisten Metadaten kopiert werden, einige Teile verloren gehen und die Datei 700 KB kleiner ist . Beigefügt ist vor und nach Metadaten von ffprobe und exifer.
Ein weiterer seltsamer Befund ist, dass der Befehl ffmpeg rotate = 90 eine ccw-Drehung ausführt, die in ffprobe (cw) 270 ° in Metadaten, aber (ccw) 90 ° in Displaymatrix-Seitendaten beträgt.
= equal attributes
* altered attributes
- removed attributes
+ added attributes
ffprobe input.mp4
*Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\input.mp4':
= Metadata:
* major_brand : avc1
* minor_version : 0
* compatible_brands: avc1isom
= creation_time : 2016-10-29T12:10:41.000000Z
- firmware : HD3.11.03.03
* Duration: 00:00:06.01, start: 0.000000, bitrate: 32072 kb/s
= Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1440 [SAR 1:1 DAR 4:3], 30945 kb/s, 47.95 fps, 47.95 tbr, 720k tbn, 95.90 tbc (default)
= Metadata:
= creation_time : 2016-10-29T12:10:41.000000Z
* handler_name : GoPro AVC
- encoder : GoPro AVC encoder
- Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 127 kb/s (default)
- Metadata:
- creation_time : 2016-10-29T12:10:41.000000Z
- handler_name : GoPro AAC
ffprobe output.mp4
*Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '.\output.mp4':
= Metadata:
* major_brand : isom
* minor_version : 512
* compatible_brands: isomiso2avc1mp41
= creation_time : 2016-10-29T12:10:41.000000Z
+ encoder : Lavf58.10.100
* Duration: 00:00:06.01, start: 0.000000, bitrate: 30948 kb/s
= Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, bt709), 1920x1440 [SAR 1:1 DAR 4:3], 30945 kb/s, 47.95 fps, 47.95 tbr, 720k tbn, 95.90 tbc (default)
= Metadata:
+ rotate : 270
= creation_time : 2016-10-29T12:10:41.000000Z
* handler_name : VideoHandler
+ Side data:
+ displaymatrix: rotation of 90.00 degrees
exiftool input.mp4
=ExifTool Version Number : 10.87
*File Name : input.mp4
=Directory : C:/
*File Size : 23 MB
*File Modification Date/Time : 2016:10:29 13:10:48+02:00
*File Access Date/Time : 2018:03:22 22:51:11+01:00
*File Creation Date/Time : 2018:03:22 22:51:11+01:00
=File Permissions : rw-rw-rw-
=File Type : MP4
=File Type Extension : mp4
=MIME Type : video/mp4
*Major Brand : MP4 Base w/ AVC ext [ISO 14496-12:2005]
*Minor Version : 0.0.0
*Compatible Brands : avc1, isom
=Movie Header Version : 0
=Create Date : 2016:10:29 12:10:41
=Modify Date : 2016:10:29 12:10:41
*Time Scale : 90000
=Duration : 6.01 s
=Preferred Rate : 1
=Preferred Volume : 100.00%
=Preview Time : 0 s
=Preview Duration : 0 s
=Poster Time : 0 s
=Selection Time : 0 s
=Selection Duration : 0 s
=Current Time : 0 s
*Next Track ID : 3
-Firmware Version : HD3.11.03.03
-Lens Serial Number : LW13121003000141
-Camera Serial Number Hash : 4833422b363033313530636432356400
=Track Header Version : 0
=Track Create Date : 2016:10:29 12:10:41
=Track Modify Date : 2016:10:29 12:10:41
=Track ID : 1
=Track Duration : 6.01 s
=Track Layer : 0
=Track Volume : 0.00%
=Image Width : 1920
=Image Height : 1440
=Graphics Mode : srcCopy
=Op Color : 0 0 0
=Compressor ID : avc1
=Source Image Width : 1920
=Source Image Height : 1440
=X Resolution : 72
=Y Resolution : 72
-Compressor Name : .GoPro AVC encoder
=Bit Depth : 24
-Color Representation : nclc 1 1 1
-Gamma : 2.2
=Video Frame Rate : 47.952
-Matrix Structure : 1 0 0 0 1 0 0 0 1
=Media Header Version : 0
=Media Create Date : 2016:10:29 12:10:41
=Media Modify Date : 2016:10:29 12:10:41
-Media Time Scale : 48000
-Media Duration : 5.99 s
*Handler Type : Audio Track
-Handler Description : .GoPro AAC
-Balance : 0
-Audio Format : mp4a
-Audio Channels : 2
-Audio Bits Per Sample : 16
-Audio Sample Rate : 48000
-Movie Data Size : 24045320
-Movie Data Offset : 32768
*Avg Bitrate : 32 Mbps
=Image Size : 1920x1440
=Megapixels : 2.8
*Rotation : 0
exiftool output.mp4
=ExifTool Version Number : 10.87
*File Name : output.mp4
=Directory : C:/
*File Size : 22 MB
*File Modification Date/Time : 2018:03:23 12:29:19+01:00
*File Access Date/Time : 2018:03:23 12:28:18+01:00
*File Creation Date/Time : 2018:03:23 12:28:18+01:00
=File Permissions : rw-rw-rw-
=File Type : MP4
=File Type Extension : mp4
=MIME Type : video/mp4
*Major Brand : MP4 Base Media v1 [IS0 14496-12:2003]
*Minor Version : 0.2.0
*Compatible Brands : isom, iso2, avc1, mp41
+Movie Data Size : 23232544
+Movie Data Offset : 48
=Movie Header Version : 0
=Create Date : 2016:10:29 12:10:41
=Modify Date : 2016:10:29 12:10:41
*Time Scale : 1000
=Duration : 6.01 s
=Preferred Rate : 1
=Preferred Volume : 100.00%
=Preview Time : 0 s
=Preview Duration : 0 s
=Poster Time : 0 s
=Selection Time : 0 s
=Selection Duration : 0 s
=Current Time : 0 s
*Next Track ID : 2
=Track Header Version : 0
=Track Create Date : 2016:10:29 12:10:41
=Track Modify Date : 2016:10:29 12:10:41
=Track ID : 1
=Track Duration : 6.01 s
=Track Layer : 0
=Track Volume : 0.00%
+Matrix Structure : 0 1 0 -1 0 0 0 0 1
=Image Width : 1920
=Image Height : 1440
=Media Header Version : 0
=Media Create Date : 2016:10:29 12:10:41
=Media Modify Date : 2016:10:29 12:10:41
+Media Time Scale : 720000
+Media Duration : 6.01 s
+Media Language Code : eng
+Handler Description : VideoHandler
=Graphics Mode : srcCopy
=Op Color : 0 0 0
=Compressor ID : avc1
=Source Image Width : 1920
=Source Image Height : 1440
=X Resolution : 72
=Y Resolution : 72
=Bit Depth : 24
+Pixel Aspect Ratio : 1:1
=Video Frame Rate : 47.952
*Handler Type : Metadata
+Handler Vendor ID : Apple
+Encoder : Lavf58.10.100
*Avg Bitrate : 30.9 Mbps
=Image Size : 1920x1440
=Megapixels : 2.8
*Rotation : 270
Ich habe ffmpeg rotate = 0 und rotate = 90 .mp4-Dateien in Notepad ++ verglichen, um das Rotate-Flag / die Matrix zu identifizieren, aber ohne Glück nur Quatsch. Ich würde es vorziehen, nur das Flag zu bearbeiten (wie es exiftool für alle Arten von Metadaten tut, aber nicht in Videos drehen kann), anstatt den Inhalt in einen neuen Container zu streamen, auch für eine schnellere Verarbeitung (alle Videos sind auf NAS) .