- RedMarsBlueMoon
- Posts: 501
- Joined: Mon Apr 06, 2020 3:49 am
Does Anyone Know of a example capturing a networked h264 stream with omx?
Hi, I'm trying to understand how a hardware decoder using mmal/omx would need to be set up and am looking for an example that does that.
I have a bunch of other examples which are really useful but it would be great to have an example pipeline for recieving and decoding a network h264 stream. Does anyone know of any?
Cheers, Fred
I have a bunch of other examples which are really useful but it would be great to have an example pipeline for recieving and decoding a network h264 stream. Does anyone know of any?
Cheers, Fred
- 6by9
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 18476
- Joined: Wed Dec 04, 2013 11:27 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
It depends what the stream is, but simplest to use Gstreamer.
Generally use v4l2h264dec instead of the omx libraries. IL will not be supported on 64bit OSes, whereas V4L2 is and will be.
Generally use v4l2h264dec instead of the omx libraries. IL will not be supported on 64bit OSes, whereas V4L2 is and will be.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
- RedMarsBlueMoon
- Posts: 501
- Joined: Mon Apr 06, 2020 3:49 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
I did start looking at Gstreamer yesterday as I hadn't come across it before.
Would Gstreamer be good for 'zero latency' streaming Ie not zero as such but for game streaming?
When you say 'v4l2h264dec' would that be equivalent to this one listed out of ffmpeg/ffplay:
h264_v4l2m2m ?
I tried encoding screen capture with that and it seemed to do it but the resulting file was unplayable with ffplay, vlc and omxplayer.
(edit: i fixed the h264_omx typo - that was another one I tried)
The same command but using the libx264 codec produces a playable file.
Similarly I haven't be able to get any ffplay command with any codec option Iv'e tried to play with hw decoding.
Would Gstreamer be good for 'zero latency' streaming Ie not zero as such but for game streaming?
When you say 'v4l2h264dec' would that be equivalent to this one listed out of ffmpeg/ffplay:
h264_v4l2m2m ?
Code: Select all
DEV.LS h264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
(decoders: h264 h264_v4l2m2m h264_mmal )
(encoders: libx264 libx264rgb h264_omx h264_v4l2m2m h264_vaapi Code: Select all
ffmpeg -f x11grab -y -framerate 60 -s 1360x768 -i :0.0 -pix_fmt yuv420p -c:v h264_v4l2m2m -crf 18 out.mp4The same command but using the libx264 codec produces a playable file.
Similarly I haven't be able to get any ffplay command with any codec option Iv'e tried to play with hw decoding.
- 6by9
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 18476
- Joined: Wed Dec 04, 2013 11:27 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
So are you playing a network stream, or streaming to the network? Your original post refers to decoders, but this latest post is using x11grab.
Yes, Gstreamer's v4l2h264dec is equivalent to FFmpeg's decoder h264_v4l2m2m.
Yes, Gstreamer's v4l2h264dec is equivalent to FFmpeg's decoder h264_v4l2m2m.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
- RedMarsBlueMoon
- Posts: 501
- Joined: Mon Apr 06, 2020 3:49 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
My goal is to decode a network h264 stream and I would love to be able to use avcodec for that.
Testing on the files is me trying to verify that the hardware decoding in ffmpeg (which I believe is using avcodec?) is actually working. Otherwise I won't spend time going down that route.
I had read that ffmpeg hw support was down to the _omx h264 variants but that not being available for decode I tried _omx and h264_v4l2m2m for encode to see if that worked. (which it didn't)
The thinking being if I could verify something that did hardware decode OR encode, than that would be a good clue for what might be missing in the decode side.
Testing on the files is me trying to verify that the hardware decoding in ffmpeg (which I believe is using avcodec?) is actually working. Otherwise I won't spend time going down that route.
I had read that ffmpeg hw support was down to the _omx h264 variants but that not being available for decode I tried _omx and h264_v4l2m2m for encode to see if that worked. (which it didn't)
The thinking being if I could verify something that did hardware decode OR encode, than that would be a good clue for what might be missing in the decode side.
- 6by9
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 18476
- Joined: Wed Dec 04, 2013 11:27 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
FFmpeg has MMAL for decode (h264_mmal, mpeg4_mmal, mpeg2_mmal, vc1_mmal) and OMX for encode (h264_omx). Don't ask why, that's just the way they developed it.
V4L2 is the main API if you want it to work on 64bit systems, but it will also work on 32bit systems.
GStreamer is slightly better behaved with the V4L2 devices than FFmpeg.
V4L2 is the main API if you want it to work on 64bit systems, but it will also work on 32bit systems.
GStreamer is slightly better behaved with the V4L2 devices than FFmpeg.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
- RedMarsBlueMoon
- Posts: 501
- Joined: Mon Apr 06, 2020 3:49 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
I don't see any of that working like I expect though. When I play the same video files (a Mulan mp4 trailer and a mulan demuxed h264 video file) with omxplayer I get full playback speed at ~15% CPU useage. VLC is the same as omxplayer.
With ffplay I get a stuttery ~15fps and ~45% CPU useage.
ffplay version says this:
and has amongst other things:
--enable-omx-rpi --enable-mmal --enable-neon --enable-rpi --enable-omx
I also built ffmpeg myself with instructions that were made to enable the hw decode on the pi but that version behaves exactly like the above apt installed version.
If someone really has this working and is able to decode h264 with the above good specs, 1080p at full speed and 15% CPU use, please I'd love to hear exactly what ffmpeg/ffplay version you are using and what data you are playing!?
With ffplay I get a stuttery ~15fps and ~45% CPU useage.
ffplay version says this:
Code: Select all
ffplay version 4.1.6-1~deb10u1+rpt1 Copyright (c) 2003-2020 the FFmpeg developers
built with gcc 8 (Raspbian 8.3.0-6+rpi1)--enable-omx-rpi --enable-mmal --enable-neon --enable-rpi --enable-omx
I also built ffmpeg myself with instructions that were made to enable the hw decode on the pi but that version behaves exactly like the above apt installed version.
If someone really has this working and is able to decode h264 with the above good specs, 1080p at full speed and 15% CPU use, please I'd love to hear exactly what ffmpeg/ffplay version you are using and what data you are playing!?
- 6by9
- Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator - Posts: 18476
- Joined: Wed Dec 04, 2013 11:27 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
That is ffplay's fault for not rendering through any efficient path.
Omxplayer only parses the container on the arm, everything else is on the gpu. There is no way directly in ffmpeg to do that as it is a generic playback library for multiple platforms, and no others offer the near full offload the pi does.
You wanted to use ffmpeg, so your choice to investigate rendering paths.
Omxplayer only parses the container on the arm, everything else is on the gpu. There is no way directly in ffmpeg to do that as it is a generic playback library for multiple platforms, and no others offer the near full offload the pi does.
You wanted to use ffmpeg, so your choice to investigate rendering paths.
Software Engineer at Raspberry Pi Ltd. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
I'm not interested in doing contracts for bespoke functionality - please don't ask.
- RedMarsBlueMoon
- Posts: 501
- Joined: Mon Apr 06, 2020 3:49 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
So the implication then is that avcodec is not able to do the decoding as that's what ffplay is using. Which would align with the observations I had that prompted me to investigate this.
You mention Gstreamer but also said that "Gstreamer's v4l2h264dec is equivalent to FFmpeg's decoder h264_v4l2m2m."
When you say equivalent is that they are both based on avcodec? And therefore Gstreamer would have the same problems doing this?
Or is it just the spec of the codec that is the same and Gstreamers implementation and use of mmal/omx is different and should work?
EDIT: I will look more at Gstreamer, as you suggest.
You mention Gstreamer but also said that "Gstreamer's v4l2h264dec is equivalent to FFmpeg's decoder h264_v4l2m2m."
When you say equivalent is that they are both based on avcodec? And therefore Gstreamer would have the same problems doing this?
Or is it just the spec of the codec that is the same and Gstreamers implementation and use of mmal/omx is different and should work?
EDIT: I will look more at Gstreamer, as you suggest.
- RedMarsBlueMoon
- Posts: 501
- Joined: Mon Apr 06, 2020 3:49 am
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
For anyone reading I ended up going with some code that was derived from the Raspberry OpenMax example 'hello_video'. (Was that yours @6by9 ? :) )
I tried with Gstreamer for a bit and I got my raspberry camera working well just doing a command line pipeline, but after a day and a half of trying to play a h264 video file and failing I gave up and went back to the original plan. Maybe Gstreamer would have worked but I wasn't having luck with it.
Here's what I ended up with.
https://youtu.be/xsVvuWcEPC4
Cheers
Fred
I tried with Gstreamer for a bit and I got my raspberry camera working well just doing a command line pipeline, but after a day and a half of trying to play a h264 video file and failing I gave up and went back to the original plan. Maybe Gstreamer would have worked but I wasn't having luck with it.
Here's what I ended up with.
https://youtu.be/xsVvuWcEPC4
Cheers
Fred
Re: Does Anyone Know of a example capturing a networked h264 stream with omx?
Try this https://github.com/SynAckFin/CCTVplexer
The render.c file contains all the code necessary for rendering a H264 stream.
The render.c file contains all the code necessary for rendering a H264 stream.
Jump to
- Community
- General discussion
- Announcements
- Other languages
- Deutsch
- Español
- Français
- Italiano
- Nederlands
- 日本語
- Polski
- Português
- Русский
- Türkçe
- User groups and events
- Raspberry Pi Official Magazine
- Using the Raspberry Pi
- Beginners
- Troubleshooting
- Advanced users
- Assistive technology and accessibility
- Education
- Picademy
- Teaching and learning resources
- Staffroom, classroom and projects
- Astro Pi
- Mathematica
- High Altitude Balloon
- Weather station
- Programming
- C/C++
- Java
- Python
- Scratch
- Other programming languages
- Windows 10 for IoT
- Wolfram Language
- Bare metal, Assembly language
- Graphics programming
- OpenGLES
- OpenVG
- OpenMAX
- General programming discussion
- Projects
- Networking and servers
- Automation, sensing and robotics
- Graphics, sound and multimedia
- Other projects
- Media centres
- Gaming
- AIY Projects
- Hardware and peripherals
- Camera board
- Compute Module
- Official Display
- HATs and other add-ons
- Device Tree
- Interfacing (DSI, CSI, I2C, etc.)
- Keyboard computers (400, 500, 500+)
- Raspberry Pi Pico
- General
- SDK
- MicroPython
- Other RP2040 boards
- Zephyr
- Rust
- AI Accelerator
- AI Camera - IMX500
- Hailo
- Software
- Raspberry Pi OS
- Raspberry Pi Connect
- Raspberry Pi Desktop for PC and Mac
- Beta testing
- Other
- Android
- Debian
- FreeBSD
- Gentoo
- Linux Kernel
- NetBSD
- openSUSE
- Plan 9
- Puppy
- Arch
- Pidora / Fedora
- RISCOS
- Ubuntu
- Ye Olde Pi Shoppe
- For sale
- Wanted
- Off topic
- Off topic discussion