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

Workaround to improve support of AVIF with alpha #635

Open
clsid2 opened this issue Jan 31, 2025 · 0 comments
Open

Workaround to improve support of AVIF with alpha #635

clsid2 opened this issue Jan 31, 2025 · 0 comments

Comments

@clsid2
Copy link
Contributor

clsid2 commented Jan 31, 2025

Example file:
example_with_alpha.zip

AVIF image with alpha data is currently being demuxed by FFmpeg as two separate streams. Unfortunately, the first stream may be the alpha layer, with default disposition. Selecting the non-alpha stream by default should give better output.

So as a workaround, I propose a small addition in CLAVFDemuxer::SelectVideoStream():

// workaround for AVIF images where alpha layer is a separate stream
if (m_avFormat->streams[best->pid]->codecpar->codec_id == AV_CODEC_ID_AV1 && m_avFormat->streams[check->pid]->codecpar->codec_id == AV_CODEC_ID_AV1)
{
    if (m_avFormat->streams[best->pid]->codecpar->format == AV_PIX_FMT_GRAY8 && m_avFormat->streams[check->pid]->codecpar->format != AV_PIX_FMT_GRAY8)
    {
        best = check;
        continue;
    }
}

// prefer default streams
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

No branches or pull requests

1 participant