Jump to content

HW transcode on Rpi4 OpenMax and V4L2


aptalca
Go to solution Solved by aptalca,

Recommended Posts

aptalca

Hi there,

 

Just wanted to report some findings. I have openmax hw encode working on a raspberry pi 4 with emby stable (in a docker container, and on libreelec). That part works great.

 

I also tested v4l2. Although emby has access to the necessary devices, because of a missing patch in ffmpeg, v4l2 encode results in an all green image (can still see video, but in shades of green).

 

The helpful folks over at libreelec (especially 6by9 from raspberry pi) pointed me towards an ffmpeg commit (merged to master a long time ago but not pulled into the 4.2 release) that would fix that.

 

Here's the commit if you're interested in applying this patch to your ffmpeg build on arm32/64: https://github.com/FFmpeg/FFmpeg/commit/d61cf1b1ebc2477749d7d7825a072400ed24af9f#diff-bec5e20dbf17e1c989823fa841c2f8b3

 

Hw decode does not work for either, as expected (missing licence I believe).

Link to comment
Share on other sites

aptalca

@@softworkz

 

I tried v4l2 encode on emby beta and it falls back to software. Here's the error I get: 

17:48:35.953 [h264_v4l2m2m @ 0x1d6eb30] [Eval @ 0xbefd5b38] Undefined constant or missing '(' in 'high'
17:48:35.953 [h264_v4l2m2m @ 0x1d6eb30] Unable to parse option value "high"
17:48:35.953 [h264_v4l2m2m @ 0x1d6eb30] Error setting option profile to value high.

Full log: https://pastebin.com/H5essUfH

 

EDIT:

 

Unfortunately OpenMax also does not work, Here's the log: https://pastebin.com/rFngLuyW

 

In the same environment, the stable works with both omx and v4l2 (except for the green screen issue on v4l2)

Edited by aptalca
Link to comment
Share on other sites

aptalca

@@softworkz I just tried beta 4.4.0.25 with both v4l2 and omx

 

V4L2 plays, but the picture has weird lines all over and the color is off: https://pastebin.com/ExntiWre

 

emby_beta_v4l2.txt

 

Here's the v4l2 encoded image: 

post-90124-0-22565800-1584229390_thumb.png

 

And here's the direct play image:

post-90124-0-36961200-1584229530_thumb.png

 

OMX on the other hand no longer works: https://pastebin.com/01YkMJjQ

 

emby_beta_omx.txt

Edited by softworkz
Added attachments
Link to comment
Share on other sites

Thanks a lot for reporting. 

 

For OMX we'll have an additional adjustment in the next beta.

 

For the V4L2 encoder, I'm not sure what the issue could be, but I read somewhere that it would be required to update the RPI to the latest kernel version.

Link to comment
Share on other sites

  • Solution
aptalca

@@Luke @@softworkz

 

I just tested 4.4.0.30 and OpenMax works great  :D

 

For vl42, I'll try with raspbian first and then 3rd party ubuntu (much newer kernel)

  • Like 2
Link to comment
Share on other sites

neik

I just tested 4.4.0.30 and OpenMax works great  :D

 

I am wondering what you are transcoding (h264 / h265) and how many concurrent streams it is capable to serve before it starts struggeling?

Link to comment
Share on other sites

aptalca

Decode is sw, this is only hw encoding whatever emby serves (h264, various bitrates). I was testing an encode of 1.5Mbps (reduced bitrate to force transcode)

  • Like 1
Link to comment
Share on other sites

neik

SW decoding is expected, we don't support HW decoding on the RPI.

 

May I ask why?

According to what I found it should be able to decode h264 up to 1080p60 and h265 up to 2160p60, so should be sufficient for the vast majority I guess.

Link to comment
Share on other sites

The decoding api is meant to work with a video surface, which the server doesn't have because the rendering is happening on another device.

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...
aptalca

Thanks a lot for reporting. 

 

For OMX we'll have an additional adjustment in the next beta.

 

For the V4L2 encoder, I'm not sure what the issue could be, but I read somewhere that it would be required to update the RPI to the latest kernel version.

 

@@softworkz

 

Finally got a chance to try v4l2 with a more recent kernel. Had some challenges as the ubuntu images for the rpi, which come with 5.3 kernels, did not have v4l2 enabled (no video devices) and couldn't figure out how to enable them. But I was able to get libreelec working with the 5.4.29 kernel.

 

I get the same result with v4l2 as I did before, the diagonal jagged lines overlayed.

 

Here's the log: https://pastebin.com/CGBSRuSR

 

On another note, I just wanted to give you a heads up that I have mmal decoding working with omx encode on the rpi4 in a docker container. I just had to expose `/dev/vc-mem` into the container and ffmpeg with mmal can hw decode.

Link to comment
Share on other sites

@@aptalca - Thanks for reporting!

 

So it's good to know that the "diagonal jagged lines" is not a problem specific to Emby :-)

 

 

On another note, I just wanted to give you a heads up that I have mmal decoding working with omx encode on the rpi4 in a docker container. I just had to expose `/dev/vc-mem` into the container and ffmpeg with mmal can hw decode.

 

According to the docs, ffmpeg cannot use MMAL when run from the command line. Could you please post an ffmpeg log for this?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...