Skip to content
Holger Winnemoeller edited this page Jan 10, 2025 · 31 revisions

SynoCommunity package FFmpeg specific FAQ

FFmpeg provides a set of command line tools to process audio and video media files.

Commands are located in /usr/local/ffmpeg<version>/bin and libraries are required by other packages. In DSM 7.0, they are located in /volume1/@appstore/ffmpeg<version>/bin.

Symbolic links are made available thru /usr/local/bin as the following where the latest installed version will become default ffmpeg:

  • ffmpeg4
  • ffmpeg5
  • ffmpeg6
  • ffmpeg7
  • ffmpeg -> Last installed version

Download Fmpeg: https://www.ffmpeg.org/ffmpeg-master-latest-win64-gpl.zip

FFMPEG ultimate guide: https://img.ly/blog/ultimate-guide-to-ffmpeg/

How to check supported formats and encoders

Ref: https://dev.to/drsensor/list-of-helpful-ffmpeg-command-for-checking-capabilities-1110

How to list all filter options:

$ ffmpeg7 -hide_banner -filters
Filters:
  T.. = Timeline support
  .S. = Slice threading
  ..C = Command support
  A = Audio input/output
  V = Video input/output
  N = Dynamic number and/or type of input/output
  | = Source or sink filter
 T.. adelay           A->A       Delay one or more audio channels.
 ... aecho            A->A       Add echoing to the audio.
...

How to list hardware acceleration:

$ ffmpeg7 -hide_banner -hwaccels
Hardware acceleration methods:
vaapi
qsv
drm
opencl

How to validate ffmpeg OpenCL acceleration (only available on DSM >=7 with more recent Intel processors):

$ ffmpeg7 -hide_banner -filters | grep opencl
 ... avgblur_opencl    V->V       Apply average blur filter
 ... boxblur_opencl    V->V       Apply boxblur filter to input video
 ... colorkey_opencl   V->V       Turns a certain color into transparency. Operates on RGB colors.
 ... convolution_opencl V->V       Apply convolution mask to input video
 ... deshake_opencl    V->V       Feature-point based video stabilization filter
 ... dilation_opencl   V->V       Apply dilation effect
 ... erosion_opencl    V->V       Apply erosion effect
 ... nlmeans_opencl    V->V       Non-local means denoiser through OpenCL
 ... overlay_opencl    VV->V      Overlay one video on top of another
 ... pad_opencl        V->V       Pad the input video.
 ... prewitt_opencl    V->V       Apply prewitt operator
 ... program_opencl    N->V       Filter video using an OpenCL program
 ... remap_opencl      VVV->V     Remap pixels using OpenCL.
 ... roberts_opencl    V->V       Apply roberts operator
 ... scale_opencl      V->V       Scale the input video size through OpenCL.
 ... sobel_opencl      V->V       Apply sobel operator
 ... tonemap_opencl    V->V       Perform HDR to SDR conversion with tonemapping.
 ... transpose_opencl  V->V       Transpose input video
 ... unsharp_opencl    V->V       Apply unsharp mask to input video
 ... xfade_opencl      VV->V      Cross fade one video with another video.
 ... openclsrc         |->V       Generate video using an OpenCL program

On Intel type processor, validate hardware acceleration:

  • Access to the video device file is granted on a per application basis. This allows an application such as tvheadend to be granted access use hardware acceleration when calling ffmpeg.
  • As a default user you must interact with ffmpeg acting as a user who's access was already granted (see example below) or add your user account to the videodriver group.
    • You can do this by SSH'ing into the Synology NAS and then using sudo synogroup --member videodriver username to add username to the videodriver group.
    • Note that, after adding the user to the group, you have to log out and then back in to realize the change group permissions for the user.
$ sudo su -s /bin/bash sc-ffmpeg7 -c '/var/packages/synocli-videodriver/target/bin/vainfo'
Trying display: drm
libva info: VA-API version 1.22.0
libva info: Trying to open /var/packages/synocli-videodriver/target/lib/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_22
libva info: va_openDriver() returns 0
vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel iHD driver for Intel(R) Gen Graphics - 24.2.5 (a20bb2e)
vainfo: Supported profile and entrypoints
      VAProfileNone                   :	VAEntrypointVideoProc
      VAProfileNone                   :	VAEntrypointStats
      VAProfileMPEG2Simple            :	VAEntrypointVLD
      VAProfileMPEG2Main              :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointVLD
      VAProfileH264Main               :	VAEntrypointEncSlice
      VAProfileH264Main               :	VAEntrypointFEI
      VAProfileH264Main               :	VAEntrypointEncSliceLP
      VAProfileH264High               :	VAEntrypointVLD
      VAProfileH264High               :	VAEntrypointEncSlice
      VAProfileH264High               :	VAEntrypointFEI
      VAProfileH264High               :	VAEntrypointEncSliceLP
      VAProfileVC1Simple              :	VAEntrypointVLD
      VAProfileVC1Main                :	VAEntrypointVLD
      VAProfileVC1Advanced            :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointVLD
      VAProfileJPEGBaseline           :	VAEntrypointEncPicture
      VAProfileH264ConstrainedBaseline:	VAEntrypointVLD
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSlice
      VAProfileH264ConstrainedBaseline:	VAEntrypointFEI
      VAProfileH264ConstrainedBaseline:	VAEntrypointEncSliceLP
      VAProfileVP8Version0_3          :	VAEntrypointVLD
      VAProfileVP8Version0_3          :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointVLD
      VAProfileHEVCMain               :	VAEntrypointEncSlice
      VAProfileHEVCMain               :	VAEntrypointFEI
      VAProfileHEVCMain10             :	VAEntrypointVLD
      VAProfileVP9Profile0            :	VAEntrypointVLD

Note that older Intel processor will fall-back to legacy i965 driver part of vainfo output:

vainfo: VA-API version: 1.22 (libva 2.22.0)
vainfo: Driver version: Intel i965 driver for Intel(R) CherryView - 2.4.1

If access restricted or non-existant such as on virtual DSM:

$ vainfo 
Trying display: drm
error: failed to initialize display

How to validate OpenCL hardware acceleration (truncated output below - only available on DSM >=7 with more recent Intel processors):

$ sudo su -s /bin/bash sc-ffmpeg7 -c '/var/packages/synocli-videodriver/target/bin/clinfo'
Number of platforms                               1
  Platform Name                                   Intel(R) OpenCL Graphics
  Platform Vendor                                 Intel(R) Corporation
  Platform Version                                OpenCL 3.0 
  Platform Profile                                FULL_PROFILE
...

How to list encoders|decoders|codecs

$ ffmpeg7 -hide_banner -encoders
$ ffmpeg7 -hide_banner -decoders
$ ffmpeg7 -hide_banner -codecs

How to list details of a specific encoder|decoder|codec

$ ffmpeg7 -hide_banner -h encoder=<encoder>
$ ffmpeg7 -hide_banner -h decoder=<decoder>

Example for HEVC:

$ ffmpeg7 -hide_banner -h decoder=hevc
Decoder hevc [HEVC (High Efficiency Video Coding)]:
    General capabilities: dr1 delay threads 
    Threading capabilities: frame and slice
    Supported hardware devices: vaapi 
HEVC decoder AVOptions:
  -apply_defdispwin  <boolean>    .D.V....... Apply default display window from VUI (default false)
  -strict-displaywin <boolean>    .D.V....... stricly apply default display window size (default false)

Example for VVC (new with ffmpeg7):

$ ffmpeg7 -hide_banner -h decoder=vvc
Decoder vvc [VVC (Versatile Video Coding)]:
    General capabilities: dr1 delay exp threads 
    Threading capabilities: other

x265 specific

For a specific feature like 10bits support in HEVC:

$ /var/packages/ffmpeg7/target/bin/x265 -V -D10
x265 [info]: HEVC encoder version 3.6+1-aa7f602f7
x265 [info]: build info [Linux][GCC 8.5.0][64 bit] 10bit
x265 [info]: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2

Example hardware-accelerated encode

The following command-line assumes that your user has been added to the videodriver group (see above for details).

$ ffmpeg7 -hide_banner -hwaccel qsv -i input.mp4 -c:v hevc_qsv -preset faster -global_quality 25 -tag:v hvc1 -map_metadata 0 output.mp4

Explanation of relevant options:

Option Notes
-hwaccel qsv This is what requests hardware acceleration via the Intel QSV driver
-c:v hevc_qsv This selects the HEVC encoder that is QSV accelerated. You can look for other encoders that are accelerated (those ending in _qsv).
-global_quality 25 The quality setting for HEVC (for others it might be called -crf)
-tag:v hvc1 This adds a tag to the output that makes the resulting MP4 file more compatible with MacOS (e.g. without it Quicktime pretends that it cannot read the file). This is specific to HEVC encoded files.
-map_metadata 0 This is completely optional, but it copies the meta-data from the original file over to the transcoded file (things like camera info, GPS data (if present) etc.)

Note: If you haven't added your user to the videodriver group, you can adapt the above su call. In general, you have to issue commands like this: sudo su -s /bin/bash sc-ffmpeg7 -c 'COMMAND_TO_RUN'. This essentially runs COMMAND_TO_RUN with sc-ffmpeg7 permissions. Specifically, the full command from above would look like: sudo su -s /bin/bash sc-ffmpeg7 -c 'ffmpeg7 -hide_banner -hwaccel qsv -i input.mp4 -c:v hevc_qsv -preset faster -global_quality 25 -tag:v hvc1 -map_metadata 0 output.mp4'.

Clone this wiki locally