H2/H2+ HW accelerated encoding H264 for WebRTC

Post Reply
Soleil
Posts: 60
Joined: Tue Apr 30, 2019 9:20 am
languages_spoken: english
Has thanked: 1 time
Been thanked: 3 times
Contact:

H2/H2+ HW accelerated encoding H264 for WebRTC

Post by Soleil »

Hi All,

Would there be a good soul who could confirm or even test what framerate is H2 capable of 1080p stream encoding either for H264 or VP8?
How to test it?
- All what it takes is have 1080p webcam (with no hardware H264 or other encoder - just normal webcam),
- connect from H2 via browser (Chromium provides best support) to any Jitsi instance, i.e. meet.jit.si or any from the list https://github.com/jitsi/jitsi-meet/wik ... -Instances
- connect from other system with webcam to same room (name to be chosen in previous step).

Observe on traffic lights FPS after a minute or two. It of course depends on bandwidth, etc. but assuming that this is not a problem these days (please make sure that you've enough uplink at both ends).

Other way would be from i.e. Linux to to re-encode a known stream, i.e. Elpehants Dream part:
http://www.w6rz.net/ => http://www.w6rz.net/ed24p_00.zip
Example command:
# ffmpeg -hide_banner -i ed24p_00.ts -c:v libx264 recompressed.mp4

This will take into account software encoder (slower)

Not sure what ffmpeg acceleration could be used on H2 hence can't provide exact encoder line. This could be checked with
# ffmpeg -hwaccels

The aim is to check how fast H2/H2+ is prior purchase as N2 is too slow for live stream of H264 at 1080p even if is faster a bit than Pi 4 (even overclocked one to 2Ghz).

I'm currently owning N2, but due to lack of support in software for HW acceleration looking for other platform and wanted to be sure before spending $$$.

mad_ady
Posts: 8820
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 586 times
Been thanked: 529 times
Contact:

Re: H2/H2+ HW accelerated encoding H264 for WebRTC

Post by mad_ady »

I don't have a 1080p webcam, but I tested encoding for you on a H2 (ubuntu 20.04):
- with your command:

Code: Select all

frame= 1243 fps= 14 q=28.0 size=   22528kB time=00:00:frame= 1252 fps= 14 q=28.0 size=   22784kB time=00:00:frame= 1261 fps= 14 q=28.0 size=   22784kB time=00:00:frame= 1271 fps= 14 q=28.0 size=   23040kB time=00:00:frame= 1281 fps= 14 q=28.0 size=   23296kB time=00:00:frame= 1289 fps= 14 q=28.0 size=   23552kB time=00:00:
Final file size: 25M

- with fixed bandwidth (-b:v 9500k)

Code: Select all

frame= 1255 fps= 10 q=25.0 size=   63488kB time=00:00:frame= 1264 fps= 10 q=25.0 size=   63744kB time=00:00:frame= 1271 fps= 10 q=25.0 size=   64000kB time=00:00:frame= 1279 fps= 11 q=25.0 size=   64256kB time=00:00:frame= 1288 fps= 11 q=25.0 size=   64512kB time=00:00:f
So hardly realtime performance... I'll play with it some more and let you know.

mad_ady
Posts: 8820
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 586 times
Been thanked: 529 times
Contact:

Re: H2/H2+ HW accelerated encoding H264 for WebRTC

Post by mad_ady »

Code: Select all

adrianp@lego:~$ ffmpeg -hwaccels                    ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers                                 built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)             configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared           libavutil      56. 31.100 / 56. 31.100                libavcodec     58. 54.100 / 58. 54.100                libavformat    58. 29.100 / 58. 29.100                libavdevice    58.  8.100 / 58.  8.100                libavfilter     7. 57.100 /  7. 57.100                libavresample   4.  0.  0 /  4.  0.  0                libswscale      5.  5.100 /  5.  5.100                libswresample   3.  5.100 /  3.  5.100                libpostproc    55.  5.100 / 55.  5.100              Hardware acceleration methods:                        vdpau                                                 cuda                                                  vaapi                                                 drm                                                   opencl                                                cuvid

Soleil
Posts: 60
Joined: Tue Apr 30, 2019 9:20 am
languages_spoken: english
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: H2/H2+ HW accelerated encoding H264 for WebRTC

Post by Soleil »

Hi mad_ady,

Thank you very much.
Numbers look pretty bad :(
I had high hopes on H2 tbh.

Would you be able to give it another try with:
timeout 30 ffmpeg -f x11grab -r 15 -s 1280x720 -i :0.0+0,0 -c:v libx264 -r 30 -preset ultrafast -b:v 4M -pix_fmt yuv420p -threads 0 -deadline realtime -tune zerolatency -f mp4 /tmp/test.mp4

And provide output like below?

Background of my tests is that unfortunately Chromium/webrtc doesn't use GPU for encoding and pushes everything on CPU. The N2 literally dies under the load hence eyeing on H2 - but need to validate performance prior spending $$$ to not waste it.
Another discovery was webrtc won't choose h264 stream even if such is available from the webcam and wants to send such to remote location.
Will literally pick yuv/mjpeg format and try to encode hence loading CPU.

Code: Select all

$ timeout 30 ffmpeg -hide_banner -f x11grab -s 1280x720 -i :0.0+0,0 -c:v libx264 -r 30 -preset ultrafast -b:v 4M  -pix_fmt yuv420p -threads 0 -deadline realtime -tune zerolatency -f mp4 /tmp/test.mp4
[x11grab @ 0x71946c0] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0+0,0':
  Duration: N/A, start: 1605741430.517086, bitrate: 442368 kb/s
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1280x720, 442368 kb/s, 15 fps, 1000k tbr, 1000k tbn, 1000k tbc
Codec AVOption deadline (Time to spend encoding, in microseconds.) specified for output file #0 (/tmp/test.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x71a1ec0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x71a1ec0] profile Constrained Baseline, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x71a1ec0] 264 - core 161 r3018 db0d417 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=abr mbtree=0 bitrate=4000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to '/tmp/test.mp4':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720, q=-1--1, 4000 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.91.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/4000000 buffer size: 0 vbv_delay: N/A
frame=   64 fps= 32 q=4.0 Lsize=     567kB time=00:00:02.10 bitrate=2210.8kbits/s dup=32 drop=0 speed=1.03x    
video:566kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.218102%
[libx264 @ 0x71a1ec0] frame I:1     Avg QP:28.00  size:110512
[libx264 @ 0x71a1ec0] frame P:63    Avg QP:12.33  size:  7428
[libx264 @ 0x71a1ec0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x71a1ec0] mb P  I16..4:  1.7%  0.0%  0.0%  P16..4: 14.9%  0.0%  0.0%  0.0%  0.0%    skip:83.4%
[libx264 @ 0x71a1ec0] final ratefactor: 17.17
[libx264 @ 0x71a1ec0] coded y,uvDC,uvAC intra: 34.6% 30.5% 28.4% inter: 5.5% 8.8% 6.9%
[libx264 @ 0x71a1ec0] i16 v,h,dc,p: 47% 47%  5%  1%
[libx264 @ 0x71a1ec0] i8c dc,h,v,p: 54% 32% 13%  1%
[libx264 @ 0x71a1ec0] kb/s:2169.24

mad_ady
Posts: 8820
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 586 times
Been thanked: 529 times
Contact:

Re: H2/H2+ HW accelerated encoding H264 for WebRTC

Post by mad_ady »

Here's the system before encoding - it has a Firefox instance open with Google Classroom and video streaming for my kid's online lessons - so, hardly idle:

Code: Select all

  1  [|||||||||||||||          46.9%]   Tasks: 137, 519 thr; 3 running
  2  [||||||||||||||||         51.0%]   Load average: 5.19 4.00 3.51 
  3  [||||||||||||||||||       54.4%]   Uptime: 01:07:57
  4  [|||||||||||||||          49.0%]
  Mem[|||||||||||||||||||1.79G/7.60G]
  Swp[                      0K/8.01G]

Here is the system load during capture/encoding:

Code: Select all


  1  [|||||||||||||||||||||||||83.2%]   Tasks: 139, 531 thr; 4 running
  2  [|||||||||||||||||||||||||83.7%]   Load average: 4.32 3.94 3.53 
  3  [|||||||||||||||||||||||||81.8%]   Uptime: 01:09:16
  4  [|||||||||||||||||||||||||80.5%]
  Mem[|||||||||||||||||||1.83G/7.60G]
  Swp[                      0K/8.01G]

    PID USER      PRI  NI  VIRT   RES 
Here is the output:

Code: Select all

teo@lego:~$ timeout 30 ffmpeg -f x11grab -r 15 -s 1280x720 -i :0.0+0,0 -c:v libx264 -r 30 -preset ultrafast -b:v 4M -pix_fmt yuv420p -threads 0 -deadline realtime -tune zerolatency -f mp4 /tmp/test3.mp4
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[x11grab @ 0x5597405d7940] Stream #0: not enough frames to estimate rate; consider increasing probesize
Input #0, x11grab, from ':0.0+0,0':
  Duration: N/A, start: 1605768264.832448, bitrate: N/A
    Stream #0:0: Video: rawvideo (BGR[0] / 0x524742), bgr0, 1280x720, 15 fps, 1000k tbr, 1000k tbn, 1000k tbc
Codec AVOption deadline (Time to spend encoding, in microseconds.) specified for output file #0 (/tmp/test3.mp4) has not been used for any stream. The most likely reason is either wrong type (e.g. a video option with no video streams) or that it is a private option of some encoder which was not actually used for any stream.
Stream mapping:
  Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
Press [q] to stop, [?] for help
[libx264 @ 0x5597405e4dc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
[libx264 @ 0x5597405e4dc0] profile Constrained Baseline, level 3.1
[libx264 @ 0x5597405e4dc0] 264 - core 155 r2917 0a84d98 - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=4 lookahead_threads=4 sliced_threads=1 slices=4 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=abr mbtree=0 bitrate=4000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to '/tmp/test3.mp4':
  Metadata:
    encoder         : Lavf58.29.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1280x720, q=-1--1, 4000 kb/s, 30 fps, 15360 tbn, 30 tbc
    Metadata:
      encoder         : Lavc58.54.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/4000000 buffer size: 0 vbv_delay: -1
frame=  895 fps= 30 q=0.0 Lsize=   10942kB time=00:00:29.80 bitrate=3008.0kbits/s dup=447 drop=0 speed=   1x     
video:10935kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.064765%
[libx264 @ 0x5597405e4dc0] frame I:4     Avg QP: 6.75  size:212254
[libx264 @ 0x5597405e4dc0] frame P:891   Avg QP: 3.23  size: 11614
[libx264 @ 0x5597405e4dc0] mb I  I16..4: 100.0%  0.0%  0.0%
[libx264 @ 0x5597405e4dc0] mb P  I16..4:  0.7%  0.0%  0.0%  P16..4: 15.8%  0.0%  0.0%  0.0%  0.0%    skip:83.5%
[libx264 @ 0x5597405e4dc0] final ratefactor: 9.82
[libx264 @ 0x5597405e4dc0] coded y,uvDC,uvAC intra: 45.7% 41.1% 39.8% inter: 8.3% 5.9% 5.4%
[libx264 @ 0x5597405e4dc0] i16 v,h,dc,p: 57% 37%  4%  2%
[libx264 @ 0x5597405e4dc0] i8c dc,h,v,p: 61% 24% 14%  2%
[libx264 @ 0x5597405e4dc0] kb/s:3002.49
Exiting normally, received signal 15.

Video plays back fine (though native resolution is 1680x1050 and the recording is truncated to 720p).

I also tried to capture 30fps from x11, but got limited to 24 fps (it wasn't a CPU bottleneck).

Now, all of these tests are using software encoding (libx264). I tried a little to use vaapi, which should do hardware encoding: https://trac.ffmpeg.org/wiki/Hardware/VAAPI, but I failed and didn't have time to pursue it further. If you can find some ways to try it out, let me know...

Code: Select all

root@lego:/home/adrianp# ffmpeg -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -i ed24p_00.ts -c:v h264_vaapi output.mp4
ffmpeg version 4.2.4-1ubuntu0.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 9 (Ubuntu 9.3.0-10ubuntu2)
  configuration: --prefix=/usr --extra-version=1ubuntu0.1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-avisynth --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librsvg --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
  libavutil      56. 31.100 / 56. 31.100
  libavcodec     58. 54.100 / 58. 54.100
  libavformat    58. 29.100 / 58. 29.100
  libavdevice    58.  8.100 / 58.  8.100
  libavfilter     7. 57.100 /  7. 57.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  5.100 /  5.  5.100
  libswresample   3.  5.100 /  3.  5.100
  libpostproc    55.  5.100 / 55.  5.100
[mpegts @ 0x561627743800] PES packet size mismatch
Input #0, mpegts, from 'ed24p_00.ts':
  Duration: 00:00:54.26, start: 2.132500, bitrate: 48453 kb/s
  Program 1 
    Stream #0:0[0x31]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 24 fps, 24 tbr, 90k tbn, 48 tbc
    Stream #0:1[0x32]: Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 384 kb/s
File 'output.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (mpeg2video (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
Conversion failed!

rexxster
Posts: 3
Joined: Fri Mar 20, 2020 7:44 pm
languages_spoken: english
ODROIDs: H2
Has thanked: 0
Been thanked: 0
Contact:

Re: H2/H2+ HW accelerated encoding H264 for WebRTC

Post by rexxster »

I've given this a shot with gstreamer. Using ed24p_00.ts from your first post,

Code: Select all

kirk@h2:~/Videos/yyy$ date && gst-launch-1.0 filesrc location=./ed24p_00.ts ! decodebin name=demux demux. ! queue ! audioresample ! "audio/x-raw,rate=44100" ! audioconvert ! "audio/x-raw,format=F32LE" ! vorbisenc ! mux. matroskamux name=mux ! filesink location=ed_640x480.mkv demux. ! queue ! videoconvert ! vaapipostproc width=640 height=480 ! vaapih264enc ! "video/x-h264,profile=high" ! h264parse ! mux. && date
Thu 19 Nov 2020 07:26:59 AM CST
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Got context from element 'vaapiencodeh264-0': gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0";
Redistribute latency...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:07.260251850
Setting pipeline to NULL ...
Freeing pipeline ...
Thu 19 Nov 2020 07:27:06 AM CST

kirk@h2:~/Videos/yyy$ date && gst-launch-1.0 filesrc location=./ed24p_00.ts ! decodebin name=demux demux. ! queue ! audioresample ! "audio/x-raw,rate=44100" ! audioconvert ! "audio/x-raw,format=F32LE" ! vorbisenc ! mux. matroskamux name=mux ! filesink location=ed_1920x1080.mkv demux. ! queue ! videoconvert ! vaapih264enc ! "video/x-h264,profile=high" ! h264parse ! mux. && date
Thu 19 Nov 2020 07:28:33 AM CST
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Got context from element 'vaapiencodeh264-0': gst.vaapi.Display=context, gst.vaapi.Display=(GstVaapiDisplay)"\(GstVaapiDisplayGLX\)\ vaapidisplayglx0";
Redistribute latency...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:08.788232628
Setting pipeline to NULL ...
Freeing pipeline ...
Thu 19 Nov 2020 07:28:42 AM CST

kirk@h2:~/Videos/yyy$ dt ed*
-rw-rw-r-- 1 kirk kirk    36649451 Nov 19 07:28 ed_1920x1080.mkv
-rw-rw-r-- 1 kirk kirk     9858274 Nov 19 07:27 ed_640x480.mkv
-rw-rw-r-- 1 kirk kirk   328656148 Jul  2  2007 ed24p_00.ts

cpu at idle about 2% all four cores. Downscaling of 1st command gave about 53% each core, and 47% or so with no scaling. Negligible memory consumption.
I am using a nvme drive.

Code: Select all

kirk@h2:~/Videos/yyy$ mediainfo ./ed24p_00.ts 
General
ID                                       : 0 (0x0)
Complete name                            : ./ed24p_00.ts
Format                                   : MPEG-TS
File size                                : 313 MiB
Duration                                 : 54 s 733 ms
Overall bit rate mode                    : Constant
Overall bit rate                         : 48.0 Mb/s

Video
ID                                       : 49 (0x31)
Menu ID                                  : 1 (0x1)
Format                                   : MPEG Video
Format version                           : Version 2
Format profile                           : Main@High
Format settings                          : CustomMatrix / BVOP
Format settings, BVOP                    : Yes
Format settings, Matrix                  : Custom
Format settings, GOP                     : M=3, N=15
Codec ID                                 : 2
Duration                                 : 54 s 250 ms
Bit rate mode                            : Variable
Bit rate                                 : 45.2 Mb/s
Maximum bit rate                         : 39.1 Mb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate                               : 24.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Compression mode                         : Lossy
Bits/(Pixel*Frame)                       : 0.909
Time code of first frame                 : 00:00:00:00
Time code source                         : Group of pictures header                                                  
Stream size                              : 293 MiB (93%)                                                             
                                                                                                                     
Audio                                                                                                                
ID                                       : 50 (0x32)                                                                 
Menu ID                                  : 1 (0x1)                                                                   
Format                                   : AC-3                                                                      
Format/Info                              : Audio Coding 3                                                            
Commercial name                          : Dolby Digital                                                             
Codec ID                                 : 129                                                                       
Duration                                 : 53 s 952 ms                                                               
Bit rate mode                            : Constant                                                                  
Bit rate                                 : 384 kb/s                                                                  
Channel(s)                               : 2 channels                                                                
Channel layout                           : L R                                                                       
Sampling rate                            : 48.0 kHz                                                                  
Frame rate                               : 31.250 FPS (1536 SPF)
Bit depth                                : 16 bits
Compression mode                         : Lossy
Delay relative to video                  : -14 ms
Stream size                              : 2.47 MiB (1%)
Service kind                             : Complete Main

Code: Select all

kirk@h2:~/Videos/yyy$ mediainfo ./ed_640x480.mkv 
General
Unique ID                                : 295909522697212383224578305862431099428 (0xDE9E19DF03DA2F669871EE8E329B4A24)
Complete name                            : ./ed_640x480.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 9.40 MiB
Duration                                 : 54 s 167 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 1 456 kb/s
Encoded date                             : UTC 2020-11-19 13:26:59
Writing application                      : GStreamer Matroska muxer
Writing library                          : GStreamer matroskamux version 1.17.90

Video
ID                                       : 2
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3
Format settings                          : 1 Ref Frames
Format settings, CABAC                   : No
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=30
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 54 s 167 ms
Bit rate                                 : 1 315 kb/s
Width                                    : 640 pixels
Height                                   : 480 pixels
Display aspect ratio                     : 4:3
Frame rate mode                          : Constant
Frame rate                               : 24.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.178
Stream size                              : 8.49 MiB (90%)
Title                                    : Video
Writing library                          : "VA-API\ H264\ encoder"
Language                                 : English
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.601 NTSC
Transfer characteristics                 : BT.601
Matrix coefficients                      : BT.601

Audio
ID                                       : 1
Format                                   : Vorbis
Format settings, Floor                   : 1
Codec ID                                 : A_VORBIS
Duration                                 : 54 s 167 ms
Bit rate mode                            : Variable
Bit rate                                 : 112 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 kHz
Compression mode                         : Lossy
Stream size                              : 741 KiB (8%)
Title                                    : Audio
Writing library                          : libVorbis (Now 100% fewer shells) (20180316 (Now 100% fewer shells))
Language                                 : English
Default                                  : Yes
Forced                                   : No

Code: Select all

kirk@h2:~/Videos/yyy$ mediainfo ./ed_1920x1080.mkv 
General
Unique ID                                : 337494891352902290429065891811777869476 (0xFDE726D8007B3D57AEEB9E23AC7476A4)
Complete name                            : ./ed_1920x1080.mkv
Format                                   : Matroska
Format version                           : Version 2
File size                                : 35.0 MiB
Duration                                 : 54 s 167 ms
Overall bit rate mode                    : Variable
Overall bit rate                         : 5 413 kb/s
Encoded date                             : UTC 2020-11-19 13:28:33
Writing application                      : GStreamer Matroska muxer
Writing library                          : GStreamer matroskamux version 1.17.90

Video
ID                                       : 2
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L4
Format settings                          : 1 Ref Frames
Format settings, CABAC                   : No
Format settings, ReFrames                : 1 frame
Format settings, GOP                     : M=1, N=30
Codec ID                                 : V_MPEG4/ISO/AVC
Duration                                 : 54 s 167 ms
Bit rate                                 : 5 193 kb/s
Width                                    : 1 920 pixels
Height                                   : 1 080 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 24.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.104
Stream size                              : 33.5 MiB (96%)
Title                                    : Video
Writing library                          : "VA-API\ H264\ encoder"
Language                                 : English
Default                                  : Yes
Forced                                   : No
Color range                              : Limited
Color primaries                          : BT.709
Transfer characteristics                 : BT.709
Matrix coefficients                      : BT.709

Audio
ID                                       : 1
Format                                   : Vorbis
Format settings, Floor                   : 1
Codec ID                                 : A_VORBIS
Duration                                 : 54 s 167 ms
Bit rate mode                            : Variable
Bit rate                                 : 112 kb/s
Channel(s)                               : 2 channels
Sampling rate                            : 44.1 kHz
Compression mode                         : Lossy
Stream size                              : 741 KiB (2%)
Title                                    : Audio
Writing library                          : libVorbis (Now 100% fewer shells) (20180316 (Now 100% fewer shells))
Language                                 : English
Default                                  : Yes
Forced                                   : No

mad_ady
Posts: 8820
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, C4, N1, N2, H2, Go, Go Advance
Location: Bucharest, Romania
Has thanked: 586 times
Been thanked: 529 times
Contact:

Re: H2/H2+ HW accelerated encoding H264 for WebRTC

Post by mad_ady »

So about 10 seconds... I'm impressed!

Soleil
Posts: 60
Joined: Tue Apr 30, 2019 9:20 am
languages_spoken: english
Has thanked: 1 time
Been thanked: 3 times
Contact:

Re: H2/H2+ HW accelerated encoding H264 for WebRTC

Post by Soleil »

@mad_ady, @rexxster
Thank you very much!

This is impressive, indeed, unfortunately for the use case I'm after => webrtc from browser (Chromium/Firefox) it uses only CPU. Even with GPU enabled, it will be used only for decoding.
Webrtc doesn't seem to take advantage of available acceleration and hence the problem and that kills the performance as requires big and hefty CPU.

In terms of 720p - it is due to the command "-s 1280x720", changing it to 1920x1080 would get the 1080p. The "-i" sets coordinates of top right and "-r 30" sets the FPS of the grab whilst later parameters try to limit delay to "-tune zerolatency" even at the cost of bandwidth limiting it to "-b:v 4M"bits on video stream.

timeout 30 ffmpeg -f x11grab -s 1280x720 -i :0.0+0,0 -c:v libx264 -r 30 -preset ultrafast -b:v 4M -pix_fmt yuv420p -threads 0 -deadline realtime -tune zerolatency -f mp4 /tmp/test3.mp4

Talking about H2+ - does it really require CEC adapter like?
https://www.pulse-eight.com/p/154/intel ... ec-adapter

That would be pity, but maybe that's the reality. The use case am after is to kick off activity once the telly is tuned to the HDMI on which system is connected and would want to avoid another expense as already seems like am moving far away from N2+ level of costs (which does have the CEC support on HDMI).

Thanks for all the help!

User avatar
odroid
Site Admin
Posts: 35871
Joined: Fri Feb 22, 2013 11:14 pm
languages_spoken: English, Korean
ODROIDs: ODROID
Has thanked: 1316 times
Been thanked: 910 times
Contact:

Re: H2/H2+ HW accelerated encoding H264 for WebRTC

Post by odroid »

Soleil wrote:
Fri Nov 20, 2020 5:17 am
Talking about H2+ - does it really require CEC adapter like?
https://www.pulse-eight.com/p/154/intel ... ec-adapter

That would be pity, but maybe that's the reality. The use case am after is to kick off activity once the telly is tuned to the HDMI on which system is connected and would want to avoid another expense as already seems like am moving far away from N2+ level of costs (which does have the CEC support on HDMI).
Unfortunately, Intel SoC has no CEC feature in their silicon design and we had add an expensive add-on board as this wiki page.
https://wiki.odroid.com/odroid-h2/appli ... ith_h2plus

Post Reply

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 4 guests