-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Fix h264_v4l2m2m acceleration in Raspberry Pi 4 #7227
Conversation
Error when enabling v4l acceleration in Raspberry Pi 4 Logs: Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:/srv/dev-disk-by-uuid-17558f66-a74f-4416-b283-4c70bb44b6f8/MediaLibrary/Movie/test.mp4': Metadata: major_brand : isom minor_version : 1 compatible_brands: isomavc1 creation_time : 2015-04-23T22:01:41.000000Z Duration: 02:08:29.76, start: 0.000000, bitrate: 2173 kb/s Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/unknown), 1920x800 [SAR 1:1 DAR 12:5], 2075 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default) Metadata: creation_time : 2015-04-23T22:01:41.000000Z handler_name : video.264#trackID=1:fps=23.976 - Imported with GPAC 0.5.0-rev Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 93 kb/s (default) Metadata: creation_time : 2015-04-23T22:01:53.000000Z handler_name : GPAC ISO Audio Handler Stream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_v4l2m2m)) Stream #0:1 -> #0:1 (aac (native) -> aac (native)) Press [q] to stop, [?] for help [h264_v4l2m2m @ 0x559ce26380] Using device /dev/video11 [h264_v4l2m2m @ 0x559ce26380] driver 'bcm2835-codec' on card 'bcm2835-codec-encode' in mplane mode [h264_v4l2m2m @ 0x559ce26380] requesting formats: output=YU12 capture=H264 [h264_v4l2m2m @ 0x559ce26380] Encoder requires yuv420p pixel format. Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed! Fixed by replacing pixel format to yuv420p.
Related discussing jellyfin/jellyfin-ffmpeg#310 |
@@ -1283,7 +1283,7 @@ public string GetVideoQualityParam(EncodingJobInfo state, string videoEncoder, E | |||
|
|||
if (string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase)) | |||
{ | |||
param += " -pix_fmt nv21"; | |||
param += " -pix_fmt yuv420p"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this field and add a new case for V4L2 encoder after these lines?
jellyfin/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
Lines 2722 to 2725 in 939d96e
if (isVaapiEncoder) | |
{ | |
outFormat = "nv12"; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo? nv12 / nv21
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nyanmisaka I submitted a new PR (#7291) that moves this change down to that location, however I did not fix the potential issue that @Maxplosion pointed out? All credit to @MELSunny as this is more or less just an update on his PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for your PR @aolszowka.
nv12 is tested to work on raspberry pi 4 as well.
@Maxplosion nv21 is not a typo, it exists in pixel format in FFmpeg. But nv21 is not supported by raspberry pi encoder h264_v4l2m2m.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this field and add a new case for V4L2 encoder after these lines?
jellyfin/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs
Lines 2722 to 2725 in 939d96e
if (isVaapiEncoder) { outFormat = "nv12"; }
Many thanks for the contribution by @aolszowka,
I have updated the code according to @nyanmisaka advice
Does someone know why this particular pixel format was explicitly specified for |
@emgre As per the PR the hardware being targeted here is a Raspberry Pi 4 (https://www.raspberrypi.com/products/raspberry-pi-4-model-b/specifications/ a Broadcom BCM2711 SOC). I suspect that that pixel format is being specifically targeted due to
|
@aolszowka I understand the current change, my question was why |
@emgre Ah that is a different question, I suspect as you do that this was for support for an Android Device, as the original drop down for this used to read Exynos V4L2M2. The Exynos is a SoC similar to the Broadcom on the Pi, but on different boards, most likely a ODROID of some type. A search of the previous issues shows at least one user reporting an issue with it. At some point this text was modified to no loner reference this specific SoC (I am unable to find the PR/Commit this was done on) the original changes look to be done on #1369? |
Many thanks for the contribution by @aolszowka, jellyfin#7291 I have updated the code according to @nyanmisaka advice jellyfin#7227 (comment)
Closed in #7291 |
Changes
Fixed by replacing pixel format from NV21 to yuv420p.
Issues
Error when enabling v4l acceleration in Raspberry Pi 4
Logs:
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:/srv/dev-disk-by-uuid-17558f66-a74f-4416-b283-4c70bb44b6f8/MediaLibrary/Movie/test.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isomavc1
creation_time : 2015-04-23T22:01:41.000000Z
Duration: 02:08:29.76, start: 0.000000, bitrate: 2173 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709/bt709/unknown), 1920x800 [SAR 1:1 DAR 12:5], 2075 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2015-04-23T22:01:41.000000Z
handler_name : video.264#trackID=1:fps=23.976 - Imported with GPAC 0.5.0-rev
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 93 kb/s (default)
Metadata:
creation_time : 2015-04-23T22:01:53.000000Z
handler_name : GPAC ISO Audio Handler
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_v4l2m2m))
Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[h264_v4l2m2m @ 0x559ce26380] Using device /dev/video11
[h264_v4l2m2m @ 0x559ce26380] driver 'bcm2835-codec' on card 'bcm2835-codec-encode' in mplane mode
[h264_v4l2m2m @ 0x559ce26380] requesting formats: output=YU12 capture=H264
[h264_v4l2m2m @ 0x559ce26380] Encoder requires yuv420p pixel format.
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
Conversion failed!