Skip to content

FFmpeg 5 on Windows errors in AudioEncoder's avcodec_open2 when passing bad parameters #836

@NicolasHug

Description

@NicolasHug

We're getting segfaults or Windows fatal exception: access violation errors on Windows, with FFmpeg5, on the test_bad_input() abd test_bad_input_parametrized() tests of the AudioEncoder.

These tests purposefuly pass wrong parameter values for e.g. sample_rate or bit_rate. The error happens internally within the call to avcodec_open2():

https://github.com/pytorch/torchcodec/blob/05a6ff59baf7bf1ab7e44ca79b923c2a4474ca96/src/torchcodec/_core/Encoder.cpp#L213

I can validate that avCodecContext_, avCodecContext_.get() and avCodec are all non-null pointers before calling this. The error really seems to be within avcodec_open2() and not later, and not in the destructor either.

I'm not sure what's going on but I can reproduce the problem on different FFmpeg 5 versions. However, all of 4, 6, and 7 work fine.

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