Using FFMEG for transcoding with hardware acceleration

DLNA, AirPlay, Chromecast, PS3, XBOX, iTunes, & other media players
Post Reply
boacon
Starting out
Posts: 15
Joined: Wed Jan 02, 2019 11:52 pm

Using FFMEG for transcoding with hardware acceleration

Post by boacon »

QNAP TS-251+

Hello - I am trying to use ffmpeg to transcode surveillance video from Surveillance Station to scale them down and from .avi to .mp4. I noticed that the command used when transcoded through MediaCenter (or CAYIN) is the command below (taken from running `top`).

Code: Select all

/opt/cdx/bin/ffmpeg -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i /tmp/23395_1628124822.avi -vf format=nv12|vaapi,hwupload,scale_vaapi=w=640:h=480 -map 0:v:0? -c:v h264_vaapi -map 0:a:0? -c:a aac -ab 64000 -ac 2 -f mp4 /share/CE_CACHEDEV1_DATA/Security-Cameras/test/16/.@__thumb/temp/.24471_1191171840_1628124819_RE5J8a.2021-01-28_15-35-01~15-40-01.avi
I have found that the ffmpeg command is located in `/usr/bin/ffmpeg` and have used that location to run the command above. Though when I try to run it I keep getting the following error message:

Code: Select all

Unrecognized option 'vaapi_device'.
Basically I am asking, how do I perform video transcoding using my QNAP NAS from the CLI? More specifically I'd like to script that and ensure it uses hardware acceleration as well.

Thanks!
QNAP TS-251+ 4GB RAM
User avatar
dolbyman
Guru
Posts: 34903
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Using FFMEG for transcoding with hardware acceleration

Post by dolbyman »

The regular ffmpeg was crippled (hence the introduction of Cayin... why? ..maybe commercial codec licensing issues, QNAP never said anything )

So install ffmpeg from qnapclub and try it again.
User avatar
dolbyman
Guru
Posts: 34903
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Using FFMEG for transcoding with hardware acceleration

Post by dolbyman »

see here for the discussion around the issue
viewtopic.php?f=50&t=157602
boacon
Starting out
Posts: 15
Joined: Wed Jan 02, 2019 11:52 pm

Re: Using FFMEG for transcoding with hardware acceleration

Post by boacon »

But the NAS itself is somehow able to run these transcriptions using ffmpeg. Is there just a different binary that it is using, or in a different location?
QNAP TS-251+ 4GB RAM
User avatar
dolbyman
Guru
Posts: 34903
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Using FFMEG for transcoding with hardware acceleration

Post by dolbyman »

see the link I posted
boacon
Starting out
Posts: 15
Joined: Wed Jan 02, 2019 11:52 pm

Re: Using FFMEG for transcoding with hardware acceleration

Post by boacon »

Firstly - Thanks for your quick responses. I truly appreciate it.

So I downloaded and installed that version from qnapclub. I am still getting that "Unrecognized option 'vaapi_device'." error.

I guess my question is shouldn't I be able to run the same exact command that MediaCenter is using to get the same result? And why is that not working?
QNAP TS-251+ 4GB RAM
User avatar
dolbyman
Guru
Posts: 34903
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Using FFMEG for transcoding with hardware acceleration

Post by dolbyman »

if you do a

Code: Select all

ffmpeg -hwaccels
is the vaapi option enabled or even present?

I only have cuvid (default qnap ffmpeg) enabled (TS-853BU)

Code: Select all

ffmpeg version 3.3.6 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --enable-cross-compile --arch=i686 --target-os=linux --disable-yasm --disable-static --enable-shared --enable-gpl --enable-libmp3lame --disable-libx264 --enable-libsoxr --enable-version3 --enable-nonfree --disable-openssl --disable-decoder=ac3 --disable-decoder=ac3_fixed --disable-decoder=eac3 --disable-decoder=dca --disable-decoder=truehd --disable-encoder=ac3 --disable-encoder=ac3_fixed --disable-encoder=eac3 --disable-encoder=dca --disable-decoder=hevc --disable-decoder=hevc_cuvid --disable-encoder=hevc_nvenc --disable-encoder=nvenc_hevc --disable-decoder=h264 --disable-decoder=h264_cuvid --disable-encoder=libx264 --disable-encoder=libx264rgb --disable-encoder=h264_nvenc --disable-encoder=nvenc --disable-encoder=nvenc_h264 --disable-decoder=mpeg2video --disable-decoder=mpegvideo --disable-decoder=mpeg2_cuvid --disable-encoder=mpeg2video --disable-decoder=mpeg4 --disable-decoder=mpeg4_cuvid --disable-decoder=msmpeg4v1 --disable-decoder=msmpeg4v2 --disable-decoder=msmpeg4v3 --disable-encoder=mpeg4 --disable-encoder=msmpeg4v2 --disable-encoder=msmpeg4v3 --disable-decoder=mvc1 --disable-decoder=vc1 --disable-decoder=vc1_cuvid --disable-decoder=vc1image --disable-decoder=aac --disable-decoder=aac_fixed --disable-decoder=aac_latm --disable-encoder=aac --extra-ldflags='-L/root/git/1.4.x/x86_64/ndk/LinkFS/usr/lib -L/root/git/1.4.x/x86_64/ndk/Model/TS-X53/build/RootFS/usr/local/medialibrary/lib -Wl,--rpath -Wl,/usr/local/medialibrary/lib' --extra-cflags='-I/root/git/1.4.x/x86_64/ndk/LinkFS/usr/include -I/root/git/1.4.x/x86_64/ndk/Model/TS-X53/build/RootFS/usr/local/medialibrary/include -D_GNU_SOURCE -DQNAP' --prefix=/root/git/1.4.x/x86_64/ndk/Model/TS-X53/build/RootFS/usr/local/medialibrary
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Hardware acceleration methods:
cuvid
Same result on my 951X btw, QSV hardware transcoding runs just fine on that one though (Plex)
Last edited by dolbyman on Fri Aug 06, 2021 2:52 am, edited 1 time in total.
boacon
Starting out
Posts: 15
Joined: Wed Jan 02, 2019 11:52 pm

Re: Using FFMEG for transcoding with hardware acceleration

Post by boacon »

So It seems like I have cuvid also:

Code: Select all

# ffmpeg -hwaccels
ffmpeg version 3.3.6 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --enable-cross-compile --arch=i686 --target-os=linux --disable-yasm --disable-static --enable-shared --enable-gpl --enable-libmp3lame --disable-libx264 --enable-libsoxr --enable-version3 --enable-nonfree --disable-openssl --disable-decoder=ac3 --disable-decoder=ac3_fixed --disable-decoder=eac3 --disable-decoder=dca --disable-decoder=truehd --disable-encoder=ac3 --disable-encoder=ac3_fixed --disable-encoder=eac3 --disable-encoder=dca --disable-decoder=hevc --disable-decoder=hevc_cuvid --disable-encoder=hevc_nvenc --disable-encoder=nvenc_hevc --disable-decoder=h264 --disable-decoder=h264_cuvid --disable-encoder=libx264 --disable-encoder=libx264rgb --disable-encoder=h264_nvenc --disable-encoder=nvenc --disable-encoder=nvenc_h264 --disable-decoder=mpeg2video --disable-decoder=mpegvideo --disable-decoder=mpeg2_cuvid --disable-encoder=mpeg2video --disable-decoder=mpeg4 --disable-decoder=mpeg4_cuvid --disable-decoder=msmpeg4v1 --disable-decoder=msmpeg4v2 --disable-decoder=msmpeg4v3 --disable-encoder=mpeg4 --disable-encoder=msmpeg4v2 --disable-encoder=msmpeg4v3 --disable-decoder=mvc1 --disable-decoder=vc1 --disable-decoder=vc1_cuvid --disable-decoder=vc1image --disable-decoder=aac --disable-decoder=aac_fixed --disable-decoder=aac_latm --disable-encoder=aac --extra-ldflags='-L/root/git/1.4.x/x86_64/ndk/LinkFS/usr/lib -L/root/git/1.4.x/x86_64/ndk/Model/TS-X53/build/RootFS/usr/local/medialibrary/lib -Wl,--rpath -Wl,/usr/local/medialibrary/lib' --extra-cflags='-I/root/git/1.4.x/x86_64/ndk/LinkFS/usr/include -I/root/git/1.4.x/x86_64/ndk/Model/TS-X53/build/RootFS/usr/local/medialibrary/include -D_GNU_SOURCE -DQNAP' --prefix=/root/git/1.4.x/x86_64/ndk/Model/TS-X53/build/RootFS/usr/local/medialibrary
  libavutil      55. 58.100 / 55. 58.100
  libavcodec     57. 89.100 / 57. 89.100
  libavformat    57. 71.100 / 57. 71.100
  libavdevice    57.  6.100 / 57.  6.100
  libavfilter     6. 82.100 /  6. 82.100
  libswscale      4.  6.100 /  4.  6.100
  libswresample   2.  7.100 /  2.  7.100
  libpostproc    54.  5.100 / 54.  5.100
Hardware acceleration methods:
cuvid
The reason I got vaapi was from the earlier command I saw running.

When I run the same for the ffmpeg version downloaded from qnapclub I see "vdpau".
QNAP TS-251+ 4GB RAM
User avatar
dolbyman
Guru
Posts: 34903
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Using FFMEG for transcoding with hardware acceleration

Post by dolbyman »

according to this

http://trac.ffmpeg.org/wiki/HWAccelIntro

Both are associated with Nvidia and should not be usable by intel QSV.

According to that list it should be VAAPI or OpenCL.
User avatar
dolbyman
Guru
Posts: 34903
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Using FFMEG for transcoding with hardware acceleration

Post by dolbyman »

Looks like QSV Hardware transcoding is not available in the regular ffmpeg package

viewtopic.php?f=320&t=127583&start=30#p765029

see if this helps (costs money though)
https://www.qnapclub.eu/en/qpkg/852
boacon
Starting out
Posts: 15
Joined: Wed Jan 02, 2019 11:52 pm

Re: Using FFMEG for transcoding with hardware acceleration

Post by boacon »

Thanks for that suggestion. Not sure if that last link would actually end up working the way things are going. I just feel like since you can do the transcription on the NAS via the UI, there has got to be a way to do it via the CLI with what is already existing on the NAS.

I tried running it again via the UI and this time ran `ps aux |grep ffmepg` and see the following. There seems to be an agent running as well. Not sure of the purpose of that.

Code: Select all

# ps aux | grep ffmpeg
 5302 admin     11660 S   /opt/cdx/bin/cdx-ffmpeg-agent -m mp4 -s width=640,height=480 -ac 2 -ab 64000 -fs /share/CE_CACHEDEV1_DATA/.system/transcode/24471_1174386432_1628190726_YJZlmV/24471_1174386432_1628190726_n7KMEx -i /share/CE_CACHEDEV1_DATA/Security-Cameras/test/2021-01-28_15-00-01~15-05-00.avi -o /share/CE_CACHEDEV1_DATA/Security-Cameras/test/15/.@__thumb/temp/.24471_1174386432_1628190726_Ta9agj.2021-01-28_15-00-01~15-05-00.avi
 5821 admin     62008 S   /opt/cdx/bin/ffmpeg -y -vaapi_device /dev/dri/renderD128 -hwaccel vaapi -hwaccel_output_format vaapi -noautorotate -i /tmp/5301_1628190729.avi -vf format=nv12|vaapi,hwupload,scale_vaapi=w=640:h=480 -map 0:v:0? -c:v h264_vaapi -map 0:a:0? -c:a aac -ab 64000 -ac 2 -f mp4 /share/CE_CACHEDEV1_DATA/Security-Cameras/test/.@__thumb/temp/.24471_1174386432_1628190726_Ta9agj.2021-01-28_15-00-01~15-05-00.avi
I opened up a ticket with QNAP to see if they can help.
QNAP TS-251+ 4GB RAM
User avatar
dolbyman
Guru
Posts: 34903
Joined: Sat Feb 12, 2011 2:11 am
Location: Vancouver BC , Canada

Re: Using FFMEG for transcoding with hardware acceleration

Post by dolbyman »

I hope QNAP can help ... I have a feeling they will not want to (due to licensing restrictions) .. but fingers crossed.
FastLaneJB
Starting out
Posts: 19
Joined: Sat Aug 14, 2021 3:03 am

Re: Using FFMEG for transcoding with hardware acceleration

Post by FastLaneJB »

I do transcoding on my NAS but I've approached this a different way by just using a container and mounting the directories I need to do it. I'm using docker but you could spin up an LXD container also to do quite easily. That way your not having to fiddle with or worry about the software on the NAS.
Post Reply

Return to “Media Streaming”