Hardware h264 encoding

Moderators: mdrjr, odroid

Hardware h264 encoding

Unread postby svpcom » Mon Oct 17, 2016 6:47 pm

Hi All,
I've port C2 encoder (viewtopic.php?f=136&t=23680) to C1/C0
It consists of two parts: user-space library (provided by amlogic) and kernel driver (already in latest odroid kernel).

User-space API: https://github.com/svpcom/codec_c1
Video encoder (using v4l2 camera) and tests: https://github.com/svpcom/c1cap
It capture from V4L2 device that supports YUYV or UYVY surfaces.

The h264 bitstream output does *not* include framerate information. This will need to specified in the container when muxing.

Usage:
Code: Select all
git clone https://github.com/svpcom/codec_c1
git clone https://github.com/svpcom/c1cap
(cd codec_c1 && make)
cd c1cap
make


To save into local file:
Code: Select all
./c1cap | ffmpeg -f h264 -framerate 30 -i - -vcodec copy test.avi


To stream via network:
  • Using MPEG-TS stream:
    Code: Select all
    ./c1cap | ffmpeg -f h264 -framerate 30 -i - -vcodec copy -f mpegts udp://localhost:9000
  • Using RTP stream:
    Code: Select all
    ./c1cap | ffmpeg -f h264 -framerate 30 -i - -vcodec copy -f rtp udp://localhost:9000

To receive mpeg-ts stream:
Code: Select all
mplayer -benchmark udp://localhost:9000

Mplayer starts displaying stream in ~ 15s

To receive rtp stream:
Code: Select all
gst-launch-1.0 udpsrc port=9000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! avdec_h264 ! autovideosink fps-update-interval=1000 sync=false

gstreamer starts displaying immediate
Last edited by svpcom on Mon Oct 31, 2016 8:29 pm, edited 4 times in total.
svpcom
 
Posts: 20
Joined: Fri Aug 26, 2016 7:15 pm
languages_spoken: english
ODROIDs: C0

Re: Hardware h264 encoding

Unread postby odroid » Tue Oct 18, 2016 10:22 am

Your pull-request has been merged and released with -169 kernel update.
https://github.com/hardkernel/linux/com ... 12903f9287
User avatar
odroid
Site Admin
 
Posts: 28859
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Hardware h264 encoding

Unread postby odroid » Tue Nov 01, 2016 10:53 am

Thank you for the update ! :D
User avatar
odroid
Site Admin
 
Posts: 28859
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID

Re: Hardware h264 encoding

Unread postby pz91 » Mon Dec 12, 2016 11:09 pm

Hello,
I have problem with Your code.
When I run test, app output is:
Code: Select all
handle = 147464
vl_video_encoder_encode = -1
vl_video_encoder_encode = -1
vl_video_encoder_encode = -1
vl_video_encoder_encode = -1
...
vl_video_encoder_encode = -1


I have Odroid C1+ with Linux odroid 3.10.80-20-odrobian.
Can You help me?


Regards, Paul ;)
pz91
 
Posts: 2
Joined: Mon Dec 12, 2016 11:04 pm
languages_spoken: english
ODROIDs: c1+

Re: Hardware h264 encoding

Unread postby svpcom » Mon Dec 12, 2016 11:19 pm

You need to update kernel. Use latest for C1+ from hardkernel's github.

pz91 wrote:Hello,
I have problem with Your code.
When I run test, app output is:
Code: Select all
handle = 147464
vl_video_encoder_encode = -1
vl_video_encoder_encode = -1
vl_video_encoder_encode = -1
vl_video_encoder_encode = -1
...
vl_video_encoder_encode = -1


I have Odroid C1+ with Linux odroid 3.10.80-20-odrobian.
Can You help me?


Regards, Paul ;)
svpcom
 
Posts: 20
Joined: Fri Aug 26, 2016 7:15 pm
languages_spoken: english
ODROIDs: C0

Re: Hardware h264 encoding

Unread postby pz91 » Mon Dec 12, 2016 11:34 pm

Do I understand?
I have to download a kernel from the git source and make it. Then, change kernel to a new one.
Address sources are: https://github.com/hardkernel/linux?
pz91
 
Posts: 2
Joined: Mon Dec 12, 2016 11:04 pm
languages_spoken: english
ODROIDs: c1+

Re: Hardware h264 encoding

Unread postby svpcom » Tue Dec 13, 2016 12:20 am

yes. Prebuilt kernel there are for ubuntu only.

pz91 wrote:Do I understand?
I have to download a kernel from the git source and make it. Then, change kernel to a new one.
Address sources are: https://github.com/hardkernel/linux?
svpcom
 
Posts: 20
Joined: Fri Aug 26, 2016 7:15 pm
languages_spoken: english
ODROIDs: C0

Re: Hardware h264 encoding

Unread postby meveric » Tue Dec 13, 2016 1:57 am

svpcom wrote:yes. Prebuilt kernel there are for ubuntu only.

That's not exactly true. First there are prebuild Kernel for Debian and Arch as well (in fact Debian Kernels were available even before Ubuntu ones saw the light of day), besides that, the Kernel is generally always the same, if you take a Kernel that was compiled on/for Debian it's running the same way on Ubuntu, there's really no difference (as long as the libc6 version is supported)

Problem with "odrobian" is that the maintainer left the community many months ago.
Donate to support my work on the ODROID GameStation Turbo Image for U2/U3 XU3/XU4 X2 X C1 as well as many other releases.
Check out the Games and Emulators section to find some of my work or check the files in my repository to find the software i build for ODROIDs.
If you want to add my repository to your image read my HOWTO integrate my repo into your image.
User avatar
meveric
 
Posts: 9313
Joined: Mon Feb 25, 2013 2:41 pm
languages_spoken: german, english
ODROIDs: X2, U2, U3, XU-Lite, XU3, XU3-Lite, C1, XU4, C2, C1+, XU4Q, HC1, N1, Go

Re: Hardware h264 encoding

Unread postby rompelstompel » Thu Mar 09, 2017 3:46 pm

svpcom wrote:Hi All,
I've port C2 encoder (viewtopic.php?f=136&t=23680) to C1/C0
It consists of two parts: user-space library (provided by amlogic) and kernel driver (already in latest odroid kernel).

User-space API: https://github.com/svpcom/codec_c1
Video encoder (using v4l2 camera) and tests: https://github.com/svpcom/c1cap
It capture from V4L2 device that supports YUYV or UYVY surfaces.

The h264 bitstream output does *not* include framerate information. This will need to specified in the container when muxing.

Usage:
Code: Select all
git clone https://github.com/svpcom/codec_c1
git clone https://github.com/svpcom/c1cap
(cd codec_c1 && make)
cd c1cap
make


To save into local file:
Code: Select all
./c1cap | ffmpeg -f h264 -framerate 30 -i - -vcodec copy test.avi


To stream via network:
  • Using MPEG-TS stream:
    Code: Select all
    ./c1cap | ffmpeg -f h264 -framerate 30 -i - -vcodec copy -f mpegts udp://localhost:9000
  • Using RTP stream:
    Code: Select all
    ./c1cap | ffmpeg -f h264 -framerate 30 -i - -vcodec copy -f rtp udp://localhost:9000

To receive mpeg-ts stream:
Code: Select all
mplayer -benchmark udp://localhost:9000

Mplayer starts displaying stream in ~ 15s

To receive rtp stream:
Code: Select all
gst-launch-1.0 udpsrc port=9000 caps='application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264' ! rtph264depay ! avdec_h264 ! autovideosink fps-update-interval=1000 sync=false

gstreamer starts displaying immediate


Excellent! Is there also a hardware decoding option available? I need a headless h264 decoding option, which can decode more than one h264 stream simultaneously. RPI kan do it with the ffmpeg plugin h264_mmal. Is there something similar for the ODROID C1+ or C2?
rompelstompel
 
Posts: 2
Joined: Tue Mar 07, 2017 4:31 am
languages_spoken: english
ODROIDs: C1+

Re: Hardware h264 encoding

Unread postby odroid » Thu Mar 09, 2017 4:52 pm

User avatar
odroid
Site Admin
 
Posts: 28859
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English
ODROIDs: ODROID


Return to Projects

Who is online

Users browsing this forum: No registered users and 1 guest