OMX Hardware Transcoding on Raspberry PI

Great, 720p4mpbs runs about 4-5mbps for either 30 or 60fps content now. And CPU is always below 150%, sometimes below 100%. Clearly no overclocking is needed. This is really fantastic progress in such a short time. Did you end up figuring out how to keep the scaled frame in the GPU for encoding?

I think with a bit more testing (including h264 content, which I don't have in my setup), the Pi4 would be an easy recommend for a highly affordable Channels DVR server.

1 Like

Playing with TVE on my Pi4. I was surprised to see ffmpeg occasionally pushing up to 200% in the web client on lower bitrates (<=4mbps), dropping to ~0% if you up the bitrate to 6mbps (720p in and out). Presumably that's because it has to decode and reencode at lower than native bitrate.

Couple questions:

  1. Does a channels client (e.g. on iOS) used remotely actually take the trouble to downlink/uplink a given video through the DVR at home? If so, it would seem more sensible to just go directly to the TVE source and skip the middleman.
  2. Is TVE h.264 decoding being hardware accelerated? I think omx supports that.

Yes it does. The reason is that the source stream is authenticated by the DVR server, and so that is the original "consumer" of the TVE stream. Also, TVE streams are always retrieved at full resolution, so downscaling only occurs at the DVR.

I believe I remember hearing somewhere that the Pi4 only has hardware decoding for H.265/HEVC, hardware decoding for H.264 and MPEG-2 are no longer supported, as the processor can now handle that in software.

Hi tmm1...
Do you plan to merge your v4l2 hw scaler to ffmpeg mainline?. I think it would be quite useful having available a hw implementation working now that looks v4l2 drivers will be the new standard in linux.
Regards,

Any idea what this is about? RPi 4 transcoding is not working for me.

2020/06/21 14:28:21.586324 [HLS] ffmpeg: file2-ip192.168.2.1:  [mpegts @ 0xfae810] Dropped corrupted packet (stream = 1)
2020/06/21 14:28:21.586406 [HLS] ffmpeg: file2-ip192.168.2.1:  [mpegts @ 0xfae810] Dropped corrupted packet (stream = 2)
2020/06/21 14:28:21.587729 [HLS] ffmpeg: file2-ip192.168.2.1:  [mpegts @ 0xfae810] stream 1 : no PTS found at end of file, duration not set
2020/06/21 14:28:21.587819 [HLS] ffmpeg: file2-ip192.168.2.1:  [mpegts @ 0xfae810] stream 2 : no PTS found at end of file, duration not set
2020/06/21 14:28:21.591105 [HLS] ffmpeg: file2-ip192.168.2.1:  [mpegts @ 0xfae810] Dropped corrupted packet (stream = 2)
2020/06/21 14:28:21.604267 [HLS] ffmpeg: file2-ip192.168.2.1:  [mpegts @ 0xfae810] Dropped corrupted packet (stream = 1)
2020/06/21 14:28:21.604342 [HLS] ffmpeg: file2-ip192.168.2.1:  [mpegts @ 0xfae810] Dropped corrupted packet (stream = 2)
2020/06/21 14:28:21.725134 [HLS] ffmpeg: file2-ip192.168.2.1:  [scale_v4l2m2m @ 0x10e1720] Could not find a valid device
2020/06/21 14:28:21.725278 [HLS] ffmpeg: file2-ip192.168.2.1:  [Parsed_scale_v4l2m2m_1 @ 0x10e1680] can't configure encoder
2020/06/21 14:28:21.725318 [HLS] ffmpeg: file2-ip192.168.2.1:  [Parsed_scale_v4l2m2m_1 @ 0x10e1680] Failed to configure output pad on Parsed_scale_v4l2m2m_1
2020/06/21 14:28:21.725341 [HLS] ffmpeg: file2-ip192.168.2.1:  [scale_v4l2m2m @ 0x10e1720] VIDIOC_STREAMOFF (null)
2020/06/21 14:28:21.725625 [HLS] ffmpeg: file2-ip192.168.2.1:      Last message repeated 1 times
2020/06/21 14:28:21.725704 [HLS] ffmpeg: file2-ip192.168.2.1:  Error reinitializing filters!
2020/06/21 14:28:21.725750 [HLS] ffmpeg: file2-ip192.168.2.1:  Failed to inject frame into filter network: Permission denied
2020/06/21 14:28:21.725773 [HLS] ffmpeg: file2-ip192.168.2.1:  Error while processing the decoded data for stream #0:0
2020/06/21 14:28:21.754477 [ENC] Encoder stopped for Young Sheldon S03E03 2019-10-10 An Entrepreneurialist and a Swat on the Bottom 2020-06-18-1959.mpg in /mnt/media/dvr/Streaming/file2-ip192.168.2.1-095906896/encoder-66-996543236 after starting from 66 without encoding any segments
2020/06/21 14:28:21.763631 [ENC] Starting encoder for Young Sheldon S03E03 2019-10-10 An Entrepreneurialist and a Swat on the Bottom 2020-06-18-1959.mpg in /mnt/media/dvr/Streaming/file2-ip192.168.2.1-095906896/encoder-66-234484371 at 66 (77.177100) (encoder=h264_omx, resolution=720, deinterlacer=blend, bitrate=4000 segment_size=0.01)

Probably need firmware update with sudo rpi-update

Have run rpi-update multiple times, and through a few updates of Channels DVR. Same bug. Any more suggestions?

What's uname -a and v4l2-status say

4 posts were split to a new topic: Commercial detection issue on RPI4

Sorry this is the right command:

v4l2-ctl --list-devices

Can you also click Support > Submit Diagnostics at the top right of the web UI

Sorry for the slow response. Here you are...

m@raspberrypi : ~ $ sudo v4l2-ctl --list-devices
[sudo] password for m:
bcm2835-codec-decode (platform:bcm2835-codec):
/dev/video10
/dev/video11
/dev/video12

bcm2835-isp (platform:bcm2835-isp):
/dev/video13
/dev/video14
/dev/video15
/dev/video16

Cannot open device /dev/video0, exiting.

m@raspberrypi : ~ $ uname -a
Linux raspberrypi 5.4.61-v7l+ #1339 SMP Tue Sep 1 18:51:27 BST 2020 armv7l GNU/Linux

The video scaler is part of the ISP device iirc. That's showing up on the list, though I'm not sure why there are four of them.

There is a v4l2 command to list details about each of the devices including codecs and operations supported. Maybe this:

v4l2-ctl -D -d 11

Thanks for the fast response. Here's what you asked for.

m@raspberrypi:~ $ sudo v4l2-ctl -D -d 11
[sudo] password for m: 
Driver Info:
	Driver name      : bcm2835-codec
	Card type        : bcm2835-codec-encode
	Bus info         : platform:bcm2835-codec
	Driver version   : 5.4.61
	Capabilities     : 0x84204000
		Video Memory-to-Memory Multiplanar
		Streaming
		Extended Pix Format
		Device Capabilities
	Device Caps      : 0x04204000
		Video Memory-to-Memory Multiplanar
		Streaming
		Extended Pix Format
Media Driver Info:
	Driver name      : bcm2835-codec
	Model            : bcm2835-codec
	Serial           : 0000
	Bus info         : platform:bcm2835-codec
	Media version    : 5.4.61
	Hardware revision: 0x00000001 (1)
	Driver version   : 5.4.61
Interface Info:
	ID               : 0x0300001a
	Type             : V4L Video
Entity Info:
	ID               : 0x0000000f (15)
	Name             : bcm2835-codec-encode-source
	Function         : V4L2 I/O
	Pad 0x01000010   : 0: Source
	  Link 0x02000016: to remote pad 0x1000012 of entity 'bcm2835-codec-encode-proc': Data, Enabled, Immutable

@jdts can you share the output of this command so we can compare the results?

here is mine, with working transcoding, at least that i can tell...

bcm2835-codec-decode (platform:bcm2835-codec):
/dev/video10
/dev/video11
/dev/video12

bcm2835-isp (platform:bcm2835-isp):
/dev/video13
/dev/video14
/dev/video15
/dev/video16

Cannot open device /dev/video0, exiting.

Mine's identical:

bcm2835-codec-decode (platform:bcm2835-codec):
	/dev/video10
	/dev/video11
	/dev/video12

bcm2835-isp (platform:bcm2835-isp):
	/dev/video13
	/dev/video14
	/dev/video15
	/dev/video16

Cannot open device /dev/video0, exiting.

Transcoding works well. One difference from Karl:

Driver version : 5.4.51

Iā€™m unsure when it happened, but when I checked today transcoding had started working. I guess some update fixed the problem!

1 Like