-
Notifications
You must be signed in to change notification settings - Fork 5.2k
ffmpeg h264_v4lm2m encoding from jpgs fails. "Encoder requires yuv420p pixel format." #5191
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
Comments
Me too. How to resolve it? when I run:
I got these:
|
@JooJooBee666 Looking at the definition for them https://github.com/FFmpeg/FFmpeg/blob/master/libavutil/pixfmt.h#L78-L79
Using AV_PIX_FMT_YUV420P with color_range would probably work on v4l2_m2m, but they appear not to have converted the code over in the nearly 13 years since they deprecated the format (FFmpeg/FFmpeg@98aea87). Force the format on the input to the codec and it works but invokes a software conversion.
@MaoJianwei The codec doesn't support yuvj422p or yuv422p.
It also seems to be trying to pass mjpeg directly to the H264 encoder, and that certainly isn't supported. You may be able to do a similar |
@6by9 That's amazing! It works, thank you!
Cheers~ |
I’m running into a CPU bottleneck when converting MJPEG to YUV420p for hardware-accelerated H.264 encoding using h264_v4l2m2m. The issue is that h264_v4l2m2m only accepts YUV420p input, but the conversion from MJPEG to YUV420p is CPU-bound, even though the actual H.264 encoding is handled by the GPU. This creates a significant performance hit, especially on devices with limited CPU resources like the Raspberry Pi. Is there any way to offload the MJPEG to YUV420p conversion to the GPU, or another method to bypass this CPU bottleneck? Any suggestions for optimizing this workflow would be appreciated. |
Closing as the original issue is fixed. @Peterkal2112 your comment is unrelated. Please open a new thread on the forums as you are asking for assistance rather than reporting a bug - https://forums.raspberrypi.com/viewforum.php?f=38 |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Let me preface by saying this is a patched version of ffmpeg from [https://github.com/jc-kynesim/rpi-ffmpeg.git branch test/4.3.4/rpi_main](https://github.com/jc-kynesim/rpi-ffmpeg.git branch test/4.3.4/rpi_main)
Given a set of numbered jpgs, one would expect the following command to create a playable video:
ffmpeg -r 5 -i ./frame%d.jpg -c:v h264_v4l2m2m temp.mp4
However, this is the output:
I then tried the following:
ffmpeg -pix_fmt yuv420p -r 5 -i ./frame%d.jpg -c:v h264_v4l2m2m temp.mp4
but again this failed, but with another error (though functionally the same):However, using the libx264 encoder works just fine:
Steps to reproduce the behaviour
See above
Device (s)
Raspberry Pi 4 Mod. B
System
Raspberry Pi reference 2022-09-06
Generated using pi-gen, https://github.com/RPi-Distro/pi-gen, 827affcc11aaf7aa577d15daf02fb40b64392380, stage4
Aug 26 2022 14:03:16
Copyright (c) 2012 Broadcom
version 102f1e848393c2112206fadffaaf86db04e98326 (clean) (release) (start)
Linux pi5 5.15.61-v8+ #1579 SMP PREEMPT Fri Aug 26 11:16:44 BST 2022 aarch64 GNU/Linux
4b with 8GB RAM
Logs
No response
Additional context
I am ultimately trying to use an ffmpeg pipe to encode a stream of jpeg frames in a Python application. However, when I do that ffmpeg throws nasty messages at me. I decided to just simplify and target encoding some already created jpeg images to narrow down the issues. Clearly, this is a problem with the h264_v4l2m2m encoder as the SAME exact command works fine when the encoder is switched to libx264. Also, specifying additional parameters such as width, height and bitrate get rid of those specific errors, but the root "Encoder requires yuv420p pixel format" error is still the issue here.
The text was updated successfully, but these errors were encountered: