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

Allow bits_per_coded_sample to codec context. #1162

Closed
rvanlaar opened this issue Sep 9, 2023 · 1 comment · Fixed by #1203
Closed

Allow bits_per_coded_sample to codec context. #1162

rvanlaar opened this issue Sep 9, 2023 · 1 comment · Fixed by #1203

Comments

@rvanlaar
Copy link
Contributor

rvanlaar commented Sep 9, 2023

Overview

Add the option to set bits_per_coded_sample on the codec context.

import av
codec = av.codec.Codec("qtrle", "r").create()
p =  av.Packet()
codec.decode(p)

Results in:

Unsupported colorspace: 0 bits/sample?
---------------------------------------------------------------------------
InvalidDataError                          Traceback (most recent call last)
Cell In[4], line 1
----> 1 codec.decode(p)

File av/codec/context.pyx:509, in av.codec.context.CodecContext.decode()

File av/codec/context.pyx:521, in av.codec.context.CodecContext.decode()

File av/codec/context.pyx:291, in av.codec.context.CodecContext.open()

File av/error.pyx:336, in av.error.err_check()

InvalidDataError: [Errno 1094995529] Invalid data found when processing input; last error log: [qtrle] Unsupported colorspace: 0 bits/sample?

Desired Behavior

codec = av.codec.Codec("qtrle", "r").create()
codec.bits_per_coded_sample = 24

Example API

codec = av.codec.Codec("qtrle", "r").create()
codec.width = 200
codec.height = 200    
codec.bits_per_coded_sample = 24

Additional context

For QuickTime VR movies I want to decode single frames.
This works for RPZA which needs the width and height of a frame.
As shown in #1161 (comment)

The QTRLE decoder also needs to the bits_per_coded_sample. Which is here in the ffmpeg code:
https://github.com/FFmpeg/FFmpeg/blob/5f8c113b75de9c2a7f49e337cd332abbf8adbb6e/libavcodec/qtrle.c#L409

rvanlaar added a commit to rvanlaar/QTVR that referenced this issue Sep 13, 2023
With PyAV's bindings to FFMPEG it's trivial to offload decoding to
FFMPEG.

While fun, it wasn't feasible to write a decoder for every format used
in QTVR files. The self writter decoders also had slight color
differences with respect to FFMPEG.

Note:
    PyAV needs to be installed by hand, see the README for more
information.

Long story short, there are two issues:

1. Regular PyAV from PyPI doesn't expose `bits_per_coded_sample` on codecs.
    PR 1162 resolves the issue:
    PyAV-Org/PyAV#1162

2. PyAV can't be build easily.
    Missing is Cython 3 support from the source.
    Apply this PR PyAV-Org/PyAV#1145
@WyattBlue WyattBlue linked a pull request Nov 13, 2023 that will close this issue
Copy link

github-actions bot commented Jan 8, 2024

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants