Ffmpeg 创建时长不正确的视频

Ffmpeg 创建时长不正确的视频

尽管我只向文件添加了旋转元数据,但我的输入文件和输出文件的持续时间却不同。为什么 ffmpeg 会为文件创建不同的持续时间?

输入文件的 ffprobe 输出:

   {
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_time_base": "1/60",
            "codec_tag_string": "[27][0][0][0]",
            "codec_tag": "0x001b",
            "width": 1920,
            "height": 1088,
            "coded_width": 1920,
            "coded_height": 1088,
            "has_b_frames": 1,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "30:17",
            "pix_fmt": "yuv420p",
            "level": 41,
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "false",
            "nal_length_size": "0",
            "id": "0x102",
            "r_frame_rate": "30/1",
            "avg_frame_rate": "30/1",
            "time_base": "1/90000",
            "start_pts": 10356033,
            "start_time": "115.067033",
            "duration_ts": 540171000,
            "duration": "6001.900000",
            "bits_per_raw_sample": "8",
            "disposition": {
                "default": 0,
                "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
            }
        },
     }

然后我运行 ffmpeg 命令

.\ffmpeg.exe -i "in.mp4" -map_metadata 0  -metadata:s:v rotate="90" -codec copy "out.mp4"

它会生成一个包含以下 ffprobe 输出的文件

{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "High",
            "codec_type": "video",
            "codec_time_base": "31769997/1906136018",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 1920,
            "height": 1088,
            "coded_width": 1920,
            "coded_height": 1088,
            "has_b_frames": 1,
            "sample_aspect_ratio": "1:1",
            "display_aspect_ratio": "30:17",
            "pix_fmt": "yuv420p",
            "level": 41,
            "chroma_location": "left",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "r_frame_rate": "30/1",
            "avg_frame_rate": "953068009/31769997",
            "time_base": "1/90000",
            "start_pts": 42480,
            "start_time": "0.472000",
            "duration_ts": 1045760490,
            "duration": "11619.561000",
            "bit_rate": "4376790",
            "bits_per_raw_sample": "8",
            "nb_frames": "348561",
            "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": "270",
                "language": "und",
                "handler_name": "VideoHandler"
            },
            "side_data_list": [
                {
                    "side_data_type": "Display Matrix",
                    "displaymatrix": "\n00000000:            0      -65536           0\n00000001:        65536           0           0\n00000002:            0           0  1073741824\n",
                    "rotation": 90
                }
            ]
        },
}

相关内容