Skip to content

VideoStreamInfo: Incorrect total frame count #646

Open
@smartnet-club

Description

@smartnet-club

Executing ffprobe -loglevel error -show_format -show_streams -print_format json -i video.mkv

Found format info: {
    "filename": "video.mkv",
    "nb_streams": 1,
    "nb_programs": 0,
    "format_name": "matroska,webm",
    "format_long_name": "Matroska / WebM",
    "start_time": "0.000000",
    "duration": "299.960000",
    "size": "80968390",
    "bit_rate": "2159444",
    "probe_score": 100,
    "tags": {
        "title": "Media Server",
        "ENCODER": "Lavf58.76.100"
    }
}
Found video stream: {
    "index": 0,
    "codec_name": "h264",
    "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
    "profile": "Main",
    "codec_type": "video",
    "codec_tag_string": "[0][0][0][0]",
    "codec_tag": "0x0000",
    "width": 4096,
    "height": 2160,
    "coded_width": 4096,
    "coded_height": 2160,
    "closed_captions": 0,
    "has_b_frames": 2,
    "sample_aspect_ratio": "1:1",
    "display_aspect_ratio": "256:135",
    "pix_fmt": "yuv420p",
    "level": 51,
    "color_range": "tv",
    "color_space": "bt709",
    "color_transfer": "bt709",
    "color_primaries": "bt709",
    "chroma_location": "left",
    "field_order": "progressive",
    "refs": 1,
    "is_avc": "true",
    "nal_length_size": "4",
    "r_frame_rate": "25/1",
    "avg_frame_rate": "25/1",
    "time_base": "1/1000",
    "start_pts": 0,
    "start_time": "0.000000",
    "bits_per_raw_sample": "8",
    "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": {
        "ENCODER": "Lavc58.134.100 h264_nvenc",
        "DURATION": "00:04:59.960000000"
    }
}

total_frame_count using int(round(self.duration * self.frame_rate)) returns 7499 (299.96*25)

But ffprobe -v error -count_packets -show_streams -print_format json video.mkv returns

{
    "streams": [
        {
...
            "nb_read_packets": "7483",
...
        }
    ]
}

i.e. we have only 7483 frames

frame count calculation will be more accurate if you add -count_packets to _get_stream_info and parse nb_read_packets in total_frame_count

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions