Checking that ffmpeg uses hardware encoder on H2

Post Reply
User avatar
mad_ady
Posts: 5393
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Contact:

Checking that ffmpeg uses hardware encoder on H2

Unread post by mad_ady » Fri Jan 04, 2019 8:04 pm

It's the time of the year when I'm going through and sorting all my family photos for that year, which includes re-encoding videos - which are generally encoded with ~20Mbps CBR by the respective cameras. I can get the same perceived quality with 6Mbps or less.
This means I run my videos through Handbrake or ffmpeg. I used to do it on my xu4, but since I have access to a H2 I thought I'd try it out.

So, I changed my scripts to use ffmpeg instead of Handbrake (because Handbrake doesn't use acceleration), but I fear I'm doing something wrong. This is the command line I'm using for encoding:

Code: Select all

nice ffmpeg -i '$infile' -c:v libx264 -preset slower -crf 22 -x264-params 'nal-hrd=cbr' -b:v ${bandwidth}k -maxrate ${bandwidth}k -bufsize 2M -c:a aac '$outfile'
The videos come out ok, but I'm getting 3-5fps and 100% cpu usage.

So, clearly, it's not using the onboard encoder. I'll try to tune out the parameters (starting with -c:v libx264) and see what comes up.

Edit:
Ok, the obvious attempt failed. Most likely I need extra parameters

Code: Select all

$ nice ffmpeg -i PB307128.MOV -c:v h264_vaapi -b:v 6000k -maxrate 6000k -bufsize 2M -c:a aac PB307128--hw.mp4
ffmpeg version 4.0.2-2 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 8 (Ubuntu 8.2.0-7ubuntu1)
  configuration: --prefix=/usr --extra-version=2 --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-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opengl --enable-sdl2 --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libopencv --enable-libx264 --enable-shared
  libavutil      56. 14.100 / 56. 14.100
  libavcodec     58. 18.100 / 58. 18.100
  libavformat    58. 12.100 / 58. 12.100
  libavdevice    58.  3.100 / 58.  3.100
  libavfilter     7. 16.100 /  7. 16.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  1.100 /  5.  1.100
  libswresample   3.  1.100 /  3.  1.100
  libpostproc    55.  1.100 / 55.  1.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55cf04cfea80] st: 0 edit list: 1 Missing key frame while searching for timestamp: 3003
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55cf04cfea80] st: 0 edit list 1 Cannot find an index entry before timestamp: 3003.
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x55cf04cfea80] Referenced QT chapter track not found
Guessed Channel Layout for Input Stream #0.1 : stereo
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'PB307128.MOV':
  Metadata:
    major_brand     : qt  
    minor_version   : 537986816
    compatible_brands: qt  
    creation_time   : 2018-11-30T12:25:57.000000Z
  Duration: 00:01:00.56, start: 0.000000, bitrate: 25691 kb/s
    Stream #0:0(jpn): Video: h264 (High) (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1080 [SAR 1:1 DAR 16:9], 24033 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2018-11-30T12:25:57.000000Z
    Stream #0:1(jpn): Audio: pcm_s16le (sowt / 0x74776F73), 48000 Hz, stereo, s16, 1536 kb/s (default)
    Metadata:
      creation_time   : 2018-11-30T12:25:57.000000Z
File 'PB307128--hw.mp4' already exists. Overwrite ? [y/N] y
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> h264 (h264_vaapi))
  Stream #0:1 -> #0:1 (pcm_s16le (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!


tkaiser
Posts: 671
Joined: Mon Nov 09, 2015 12:30 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, HC1
Contact:

Re: Checking that ffmpeg uses hardware encoder on H2

Unread post by tkaiser » Fri Jan 04, 2019 8:44 pm

According to https://trac.ffmpeg.org/wiki/Hardware/QuickSync the first step is ffmpeg -decoders|grep qsv

User avatar
mad_ady
Posts: 5393
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Contact:

Re: Checking that ffmpeg uses hardware encoder on H2

Unread post by mad_ady » Fri Jan 04, 2019 9:10 pm

qsv is not listed in the output for decode nor encode.

tkaiser
Posts: 671
Joined: Mon Nov 09, 2015 12:30 am
languages_spoken: english
ODROIDs: C1+, C2, XU4, HC1
Contact:

Re: Checking that ffmpeg uses hardware encoder on H2

Unread post by tkaiser » Fri Jan 04, 2019 10:49 pm

mad_ady wrote:
Fri Jan 04, 2019 9:10 pm
qsv is not listed in the output for decode nor encode.
I would assume you read the whole page to get the reason why?

User avatar
mad_ady
Posts: 5393
Joined: Wed Jul 15, 2015 5:00 pm
languages_spoken: english
ODROIDs: XU4, C1+, C2, N1, H2, N2
Location: Bucharest, Romania
Contact:

Re: Checking that ffmpeg uses hardware encoder on H2

Unread post by mad_ady » Fri Jan 04, 2019 11:20 pm

I'm not sure if qsv is needed, since h264_vaapi is supported. I think that's the way forward.

Post Reply

Return to “Ubuntu”

Who is online

Users browsing this forum: No registered users and 1 guest