Skip to content

Frame Loss in Encoded MP4 with x264 in Encapp #234

@mrezabayat

Description

@mrezabayat

When encoding a YUV file using x264, frames are missing from the final muxed MP4 output.

Steps to Reproduce:

  1. Use the following test configuration:
    test {
        input {
            filepath: "Cactus_1920x1080_50.yuv"
            resolution: "1920x1080"
            framerate: 50
        }
        common {
            id: "bitrate_buffer"
            description: "Verify encoding bitrate - buffer"
        }
        configure {
            codec: "libnativeencoder_master.so"
            bitrate: "3000 kbps"
            i_frame_interval: 100
        }
    }
    
  2. Run the test with a 200-frame input file.
  3. Check the output MP4 file and count the frames.

Note: number of frames can be check via this command:

ffprobe -select_streams v -count_frames -show_entries stream=nb_read_frames -of default=nokey=1:noprint_wrappers=1 output.mp4

Expected Behavior:
The output MP4 file should contain all 200 frames.

Observed Behavior:
The output MP4 file contains only 159 frames, meaning some frames are missing.

Workaround:
Adding the following parameter to the encoder configuration prevents the issue:

parameter {
    key: "tune"
    type: stringType
    value: "zerolatency"
}

After adding this parameter, no frames are missing.

Additional Notes:

  • The issue may be related to buffering or delayed frame output in x264.
  • It would be helpful to investigate if the encoder is not flushing frames correctly without the "zerolatency" option.

Please let me know if further details or logs are needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions