我有一个在 Quicktime 中播放良好的视频。当通过 FFMPEG 运行时,ffmpeg 会垂直翻转它。但是,我的命令不包含翻转命令:
/usr/local/bin/ffmpeg -safe 0 -f concat -i concat.txt -i videogettingflipped.MOV
-filter_complex "[1]scale=1280:-2,pad=1280:1280:0:280[1v];[1v][0]overlay=0:0 "
-aspect 1:1 -c:v libx264 -profile:v baseline -pix_fmt yuv420p -level 3.1
-map 1:a -c:a aac -b:a 128k -r 30 -y finalvideo.mp4
这是来自 ffprobe 的 JSON,旋转显示 0,我假设没有旋转。此数据中还有其他内容告诉 FFMPEG 翻转此视频吗?
{
"streams": [
{
"index": 0,
"codec_name": "aac",
"codec_long_name": "AAC (Advanced Audio Coding)",
"profile": "LC",
"codec_type": "audio",
"codec_time_base": "1/44100",
"codec_tag_string": "mp4a",
"codec_tag": "0x6134706d",
"sample_fmt": "fltp",
"sample_rate": "44100",
"channels": 2,
"channel_layout": "stereo",
"bits_per_sample": 0,
"r_frame_rate": "0/0",
"avg_frame_rate": "0/0",
"time_base": "1/44100",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 10168505,
"duration": "230.578345",
"bit_rate": "200216",
"max_bit_rate": "192000",
"nb_frames": "9933",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"rotate": "0",
"creation_time": "2020-03-25T02:06:14.000000Z",
"language": "und",
"handler_name": "Core Media Audio"
}
},
{
"index": 1,
"codec_name": "h264",
"codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
"profile": "High",
"codec_type": "video",
"codec_time_base": "138347/8300400",
"codec_tag_string": "avc1",
"codec_tag": "0x31637661",
"width": 1280,
"height": 720,
"coded_width": 1280,
"coded_height": 720,
"has_b_frames": 1,
"pix_fmt": "yuv420p",
"level": 31,
"color_range": "tv",
"color_space": "bt709",
"color_transfer": "bt709",
"color_primaries": "bt709",
"chroma_location": "left",
"refs": 1,
"is_avc": "true",
"nal_length_size": "4",
"r_frame_rate": "30/1",
"avg_frame_rate": "4150200/138347",
"time_base": "1/600",
"start_pts": 0,
"start_time": "0.000000",
"duration_ts": 138347,
"duration": "230.578333",
"bit_rate": "2518518",
"bits_per_raw_sample": "8",
"nb_frames": "6917",
"disposition": {
"default": 1,
"dub": 0,
"original": 0,
"comment": 0,
"lyrics": 0,
"karaoke": 0,
"forced": 0,
"hearing_impaired": 0,
"visual_impaired": 0,
"clean_effects": 0,
"attached_pic": 0,
"timed_thumbnails": 0
},
"tags": {
"rotate": "0",
"creation_time": "2020-03-25T02:06:14.000000Z",
"language": "und",
"handler_name": "Core Media Video",
"encoder": "H.264"
},
"side_data_list": [
{
"side_data_type": "Display Matrix",
"displaymatrix": "\n00000000: 65536 0 0\n00000001: 0 -65536 0\n00000002: 0 47185920 1073741824\n",
"rotation": 0
}
]
}
],
"format": {
"filename": "video.MOV",
"nb_streams": 2,
"nb_programs": 0,
"format_name": "mov,mp4,m4a,3gp,3g2,mj2",
"format_long_name": "QuickTime / MOV",
"start_time": "0.000000",
"duration": "230.578333",
"size": "78501353",
"bit_rate": "2723633",
"probe_score": 100,
"tags": {
"major_brand": "qt ",
"minor_version": "0",
"compatible_brands": "qt ",
"creation_time": "2020-03-25T02:06:14.000000Z",
"com.apple.quicktime.make": "Apple",
"com.apple.quicktime.model": "iPhone 11",
"com.apple.quicktime.software": "13.3.1",
"com.apple.quicktime.creationdate": "2020-03-17T15:06:47-0400"
}
}
}
答案1
用于方向的新 API 是 displaymatrix 侧数据。您可以-noautorotate
在之前添加-i videogettingflipped.MOV
以抑制任何校正。