Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Defer wrapping output stream into Python object #390

Merged
merged 1 commit into from
Sep 26, 2018

Conversation

jlaine
Copy link
Member

@jlaine jlaine commented Sep 25, 2018

OutputContainer.add_stream() nicely initialises some default options
both for audio and video streams. Unfortunately, we wrap the low-level
AVCodecContext and AVStream into Python objects before we finish
initialising them.

For video streams this results in the crucial "pix_fmt" being cleared
inside VideoCodecContext._init, which leads to a crash during encoding
if the user does not set "pix_fmt" (again) themselves:

Assertion desc failed at libswscale/swscale_internal.h:674

With this PR we finish the CodecContext initialization before we start
wrapping the stream into a Python object.

As a result of this fix, all video encoding examples can be simplified
to remove this:

stream.pix_fmt = 'yuv420p'

OutputContainer.add_stream() nicely initialises some default options
both for audio and video streams. Unfortunately, we wrap the low-level
AVCodecContext and AVStream into Python objects before we finish
initialising them.

For video streams this results in the crucial "pix_fmt" being cleared
inside VideoCodecContext._init, which leads to a crash during encoding
if the user does not set "pix_fmt" (again) themselves:

    Assertion desc failed at libswscale/swscale_internal.h:674

With this PR we finish the CodecContext initialization *before* we start
wrapping the stream into a Python object.

As a result of this fix, all video encoding examples can be simplified
to remove this:

   stream.pix_fmt = 'yuv420p'
@mikeboers mikeboers merged commit b8954bf into PyAV-Org:develop Sep 26, 2018
@jlaine jlaine deleted the defer-stream-wrap branch September 26, 2018 06:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants