1

My input file and output files have different durations even though I am only adding rotation metadata to my file. Why is ffmpeg creating a different duration for the file?

ffprobe output of input file:

   {
    "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
            }
        },
     }

I then run an ffmpeg command of

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

which produces a file with this ffprobe output

{
    "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
                }
            ]
        },
}
  • The average framerate for your output file is 953068009/31769997 (which equates to approx. 29.99) while the input file average framerate is 30. Perhaps the origin file has corrupted metadata/timeline data? – Ulincsys May 4 at 4:17
  • 1
    @Ulincsys I'm not sure if it is corrupted. The duration for the original matches the actual duration. The output file shows a longer duration in vlc, but actually plays for the same duration as the original. So that makes me think ffmpeg is corrupting the metadata/timeline data. – mattyb May 6 at 13:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.