Embedded Intel Atom® Processors
Technological Conversations about Intel Atom® Hardware, Software, Firmware, Graphics
1202 Discussions

Hardware encoding to H264 with ffmpeg using Intel Atom® Processor E3845

Janek
Novice
4,834 Views

Top of the morning to you kind sirs.

 

We have a custom made board and we use E3845 processor. As the topic says, we would like to use its built-in hardware capabilities to encode H264 video faster with the usage of ffmpeg. Could you please point me to the up-to-date resources regarding the issue?

 

I've looked at google and found this: https://www.intel.com/content/dam/www/public/us/en/documents/white-papers/quicksync-video-ffmpeg-install-valid.pdf

but this whitepaper is 6 years old so I am afraid this will no longer apply.

 

Thank you for your time and any response provided,

 

Janek

0 Kudos
1 Solution
Diego_INTEL
Moderator
4,811 Views

Hello @Janek,

 

Thank you for contacting Intel Embedded Community.

 

Yes, you are right, that one has some years. You can check this document:


https://www.intel.com/content/www/us/en/content-details/728030/building-ffmpeg-with-qsv-on-windows-and-linux-intel-platform.html?wapkw=ffmpeg

 

Let me know if it is what you are needing.

 

Best regards,

 

@Diego_INTEL

View solution in original post

0 Kudos
6 Replies
Diego_INTEL
Moderator
4,812 Views

Hello @Janek,

 

Thank you for contacting Intel Embedded Community.

 

Yes, you are right, that one has some years. You can check this document:


https://www.intel.com/content/www/us/en/content-details/728030/building-ffmpeg-with-qsv-on-windows-and-linux-intel-platform.html?wapkw=ffmpeg

 

Let me know if it is what you are needing.

 

Best regards,

 

@Diego_INTEL

0 Kudos
Janek
Novice
4,799 Views

Hello @Diego_INTEL 

 

Thank you very much, that is a perfect tutorial! I just have two additional questions if you don't mind:

1. I did a bit of research myself and I've found over the Internet a couple of examples that are using h264_vaapi instead of h264_qsv. What is the difference between these two?

For example, I've found such exemplary command:

ffmpeg -vaapi_device /dev/dri/renderD128 -vcodec h264_vaapi -i input.mp4 output.mp4

2. Can I use h264_qsv in Docker? Is there anything specific that needs to be done to run it in Docker? For example, in case of h264_vaapi the device must be passed in Dockerfile when building a Docker image, is this also the case for h264_qsv?

 

Thank you for your patience,

Best regards,

Janek

0 Kudos
Diego_INTEL
Moderator
4,775 Views

Hello @Janek,

 

That's good to read. As for your questions:

 

1) It is another encoder, both support the format H.264, you can use any of them or try both to compare what may give you best results.

https://en.wikipedia.org/wiki/Intel_Quick_Sync_Video

https://en.wikipedia.org/wiki/Video_Acceleration_API

 

Here are some links that you can check:

Open Source Media Framework

https://www.intel.com/content/www/us/en/developer/topic-technology/open/opensource-media-framework/resources.html

 

VAAPI (Video Acceleration API)

https://www.intel.com/content/www/us/en/developer/articles/technical/linuxmedia-vaapi.html?wapkw=vaapi

 

https://github.com/intel/intel-vaapi-driver

 

Open Source Media Framework - GStreamer, Video Acceleration API (VAAPI) & Intel® Media SDK Command-Line Examples

https://www.intel.com/content/www/us/en/developer/articles/technical/gstreamer-vaapi-media-sdk-command-line-examples.html?wapkw=vaapi

Open Source Media Framework - Linux* Video Acceleration API (VAAPI) Video Stack Basic Packages

https://www.intel.com/content/www/us/en/developer/articles/technical/linux-vaapi-video-stack-basic-packages.html?wapkw=vaapi

 

Open Source Media Framework - Linux* FFmpeg* VAAPI/QSV Installation Environment

https://www.intel.com/content/www/us/en/developer/articles/technical/linux-ffmpeg-vaapi-qsv-installation-environment.html?wapkw=vaapi

 

2) Yes, both encoders should work with a container from what I understand. You can check this link:

Use an Intel® GPU and Software Stack for Media Delivery

https://www.intel.com/content/www/us/en/developer/articles/containers/media-delivery-software-stack-for-gpu.html?wapkw=qsv%20docker

 

https://github.com/intel/media-delivery

 

I found these links that may be helpful too.

How to activate Intel Quick Sync in docker (Jellyfin, Handbrake,...)

https://forum.openmediavault.org/index.php?thread/38696-how-to-activate-intel-quick-sync-in-docker-jellyfin-handbrake/

Docker video encoding

https://github.com/fg-inet/docker-video-encoding

QSV

https://gist.github.com/feedsbrain/0191516b5625b577c2b14241cff4fe30

 

Best regards,

 

@Diego_INTEL

0 Kudos
Janek
Novice
4,740 Views

Hi @Diego_INTEL 

many thanks for plethora of links! I've followed the tutorial that you've kindly provided in your first response. I've built successfully all libraries, unfortunately it does not work. Here is what I've tried:

ffmpeg -hwaccel qsv -c:v h264_qsv -i output.mp4 -c:v h264_qsv out.mp4

 and here is the output:

test@QNH8:~/dev/xlib-anonymization/Anonymization/build$ ffmpeg -hwaccel qsv -c:v h264_qsv -i output.mp4 -c:v h264_qsv out.mp4
ffmpeg version N-110344-g73ddcad990 Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 11 (Ubuntu 11.3.0-1ubuntu1~22.04)
  configuration: --pkg-config-flags=--static --enable-static --disable-shared --prefix=/home/test/ffmpeg_build --bindir=/home/test/bin --extra-cflags=-I/home/test/ffmpeg_build/include --extra-ldflags=-L/home/test/ffmpeg_build/lib --extra-cflags=-I/opt/intel/mediasdk/include --extra-ldflags=-L/opt/intel/mediasdk/lib --extra-ldflags=-L/opt/intel/mediasdk/plugins --enable-libmfx --enable-vaapi --enable-opencl --disable-debug --enable-libdrm --enable-gpl --enable-runtime-cpudetect --enable-libx264 --enable-openssl --enable-pic --extra-libs='-lpthread -lm -lz -ldl' --enable-nonfree
  libavutil      58.  6.100 / 58.  6.100
  libavcodec     60. 10.100 / 60. 10.100
  libavformat    60.  5.100 / 60.  5.100
  libavdevice    60.  2.100 / 60.  2.100
  libavfilter     9.  5.100 /  9.  5.100
  libswscale      7.  2.100 /  7.  2.100
  libswresample   4. 11.100 /  4. 11.100
  libpostproc    57.  2.100 / 57.  2.100
[vist#0:0/h264 @ 0x5644a7715a40] WARNING: defaulting hwaccel_output_format to qsv for compatibility with old commandlines. This behaviour is DEPRECATED and will be removed in the future. Please explicitly set "-hwaccel_output_format qsv".
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.76.100
  Duration: 00:01:58.24, start: 0.000000, bitrate: 5976 kb/s
  Stream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, 5974 kb/s, 25.01 fps, 25.01 tbr, 25008 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
Device creation failed: -542398533.
No device available for decoder: device type qsv needed for codec h264_qsv.
[vist#0:0/h264 @ 0x5644a7715a40] Hardware device setup failed for decoder: Generic error in an external library
Generic error in an external library


 I've also run "clinfo" as suggested and here is the output:

 

Number of platforms                               1
  Platform Name                                   Portable Computing Language
  Platform Vendor                                 The pocl project
  Platform Version                                OpenCL 2.0 pocl 1.8  Linux, None+Asserts, RELOC, LLVM 11.1.0, SLEEF, DISTRO, POCL_DEBUG
  Platform Profile                                FULL_PROFILE
  Platform Extensions                             cl_khr_icd cl_pocl_content_size
  Platform Extensions function suffix             POCL

  Platform Name                                   Portable Computing Language
Number of devices                                 1
  Device Name                                     pthread-Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
  Device Vendor                                   GenuineIntel
  Device Vendor ID                                0x6c636f70
  Device Version                                  OpenCL 1.2 pocl HSTR: pthread-x86_64-pc-linux-gnu-skylake
  Driver Version                                  1.8
  Device OpenCL C Version                         OpenCL C 1.2 pocl
  Device Type                                     CPU
  Device Profile                                  FULL_PROFILE
  Device Available                                Yes
  Compiler Available                              Yes
  Linker Available                                Yes
  Max compute units                               12
  Max clock frequency                             2592MHz
  Device Partition                                (core)
    Max number of sub-devices                     12
    Supported partition types                     equally, by counts
    Supported affinity domains                    (n/a)
  Max work item dimensions                        3
  Max work item sizes                             4096x4096x4096
  Max work group size                             4096
  Preferred work group size multiple (kernel)     8
  Preferred / native vector sizes
    char                                                16 / 16
    short                                               16 / 16
    int                                                  8 / 8
    long                                                 4 / 4
    half                                                 0 / 0        (n/a)
    float                                                8 / 8
    double                                               4 / 4        (cl_khr_fp64)
  Half-precision Floating-point support           (n/a)
  Single-precision Floating-point support         (core)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
    Correctly-rounded divide and sqrt operations  Yes
  Double-precision Floating-point support         (cl_khr_fp64)
    Denormals                                     Yes
    Infinity and NANs                             Yes
    Round to nearest                              Yes
    Round to zero                                 Yes
    Round to infinity                             Yes
    IEEE754-2008 fused multiply-add               Yes
    Support is emulated in software               No
  Address bits                                    64, Little-Endian
  Global memory size                              14530224128 (13.53GiB)
  Error Correction support                        No
  Max memory allocation                           4294967296 (4GiB)
  Unified memory for Host and Device              Yes
  Minimum alignment for any data type             128 bytes
  Alignment of base address                       1024 bits (128 bytes)
  Global Memory cache type                        Read/Write
  Global Memory cache size                        12582912 (12MiB)
  Global Memory cache line size                   64 bytes
  Image support                                   Yes
    Max number of samplers per kernel             16
    Max size for 1D images from buffer            268435456 pixels
    Max 1D or 2D image array size                 2048 images
    Max 2D image size                             16384x16384 pixels
    Max 3D image size                             2048x2048x2048 pixels
    Max number of read image args                 128
    Max number of write image args                128
  Local memory type                               Global
  Local memory size                               262144 (256KiB)
  Max number of constant args                     8
  Max constant buffer size                        262144 (256KiB)
  Max size of kernel argument                     1024
  Queue properties
    Out-of-order execution                        Yes
    Profiling                                     Yes
  Prefer user sync for interop                    Yes
  Profiling timer resolution                      1ns
  Execution capabilities
    Run OpenCL kernels                            Yes
    Run native kernels                            Yes
  printf() buffer size                            16777216 (16MiB)
  Built-in kernels                                (n/a)
  Device Extensions                               cl_khr_byte_addressable_store cl_khr_global_int32_base_atomics cl_khr_global_int32_extended_atomics cl_khr_local_int32_base_atomics cl_khr_local_int32_extended_atomics cl_khr_3d_image_writes cl_khr_fp64 cl_khr_int64_base_atomics cl_khr_int64_extended_atomics cl_khr_fp64

NULL platform behavior
  clGetPlatformInfo(NULL, CL_PLATFORM_NAME, ...)  No platform
  clGetDeviceIDs(NULL, CL_DEVICE_TYPE_ALL, ...)   No platform
  clCreateContext(NULL, ...) [default]            No platform
  clCreateContext(NULL, ...) [other]              Success [POCL]
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_DEFAULT)  Success (1)
    Platform Name                                 Portable Computing Language
    Device Name                                   pthread-Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CPU)  Success (1)
    Platform Name                                 Portable Computing Language
    Device Name                                   pthread-Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_GPU)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ACCELERATOR)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_CUSTOM)  No devices found in platform
  clCreateContextFromType(NULL, CL_DEVICE_TYPE_ALL)  Success (1)
    Platform Name                                 Portable Computing Language
    Device Name                                   pthread-Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz

The question was originally about processor E3845 and I am testing it on Core(TM) i7-10750H but this should not matter because it also supports QSV by looking at feature matrix.

The only thing that is unusual on my system is that I am using Ubuntu through WSL2, I don't know if this matters.

 

I've also tried to use vaapi and that failed too, here is the output of "vainfo" command:

 

Trying display: wayland
libva info: VA-API version 1.14.0
libva info: User environment variable requested driver 'iHD'
libva info: Trying to open /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_14
libva error: /usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so init failed
libva info: va_openDriver() returns 2
vaInitialize failed with error code 2 (resource allocation failed),exit

Maybe I am missing some driver? But I guess I shouldn't be installing any drivers when using WSL2. I am really lost due to enormous amount of libraries that are tied to this...

 

 

0 Kudos
Diego_INTEL
Moderator
4,695 Views

Hello @Janek,

 

Yes, there is a lot of information that I thought may be helpful for you to check.

 

I have checking from the Media (Intel® oneAPI Video Processing Library, Intel Media SDK) community and found that WSL2 doesn't support QSV.

https://community.intel.com/t5/Media-Intel-oneAPI-Video/Quicksync-support-for-WSL2/m-p/1312085

 

Best regards,

 

@Diego_INTEL

0 Kudos
Janek
Novice
4,675 Views

Hi @Diego_INTEL 

 

Many thanks for your help.

 

Regs,

 

Janek

0 Kudos
Reply