Skip to content

use yuvj420 (pyav jpeg full range) #1249

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

Draft
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

mgineer85
Copy link

YUVJ420 is full range jpeg in terms of PyAV.

Executing the example capture_pyav.py gives following output with this change:

<av.VideoStream #0 mjpeg, yuvj420p 1280x720 at 0x7fff7d4a58f0>

<av.VideoStream #0 mjpeg, yuv420p 640x480 at 0x7fff7d4a5b20>
<av.VideoStream #0 mjpeg, yuvj420p 1280x720 at 0x7fff7d4a5b20>

It means, the codec_context is not copied from the encoder, but at least the width/height/pix_fmt seem to be relevant for the output stream to write correct output.

The output file is created with this change as before but not using the range setting but the pix_fmt.

@davidplowman
Copy link
Collaborator

Hi, thanks for submitting the PR.

Just one thing we still need to look at. For the legacy platform codecs (so that's the V4L2 hardware encoders on Pi 4s and earlier), the add_stream method doesn't get a codec_context object (because there isn't one), just a string "video" or "audio". So we need to do something a little different there. I think I still have the problem where if the color_range isn't 2, then I don't get an output file at all!

Trying MJPEG out on a Pi 4 again I'm also not convinced that I'm getting full range YUV. I can't make the Y channel (when decoded) go below about 14, whereas I can get zero on a Pi 5. I haven't found out how I can stop that, so there's another mystery there.

And finally (and trivially), we'd need to remove some of those print statements that crept in.

But any ideas on those other points? Thanks!

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