meta-pytorch / meta-pytorch/torchcodec

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

Open
#836 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
1.2k
Forks
125
Avg merge
22h 47m
Merged PRs (30d)
54

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with test/test_encoders.py at test_bad_input() and test_bad_input_parametrized(), then inspect src/torchcodec/_core/Encoder.cpp around the avcodec_open2() call. Reproduce the failures with FFmpeg 5 and compare behavior with FFmpeg 4, 6, and 7; done means the bad-parameter tests no longer crash on supported Windows configurations.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
audio-video-rtc
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.