1

For a long time I have been using ffmpeg to convert mov-files taken on an iPhone to mp4 with the following command:

ffmpeg -i "in.MOV" -q:v 1 "out.MP4"

The result is files of good quality and relatively small volume (size).

I recently found out that ffmpeg already supports hardware acceleration. I decided to try, but got confused in the documentation. There are many complex and incomprehensible parameters. Google helped me compose this line:

ffmpeg -vaapi_device /dev/dri/renderD129 -i "in.MOV" -c:v h264_vaapi -vf 'format=nv12,hwupload' -c:a aac "out.MP4"

And it works. With hardware acceleration, files are converted much faster, but the size of the out.mp4 file turns out to be much larger than the size of the original file.

Please tell me how I can get about the same result as after the first command (quality / size), but using hardware acceleration.

Device / OS:

OS: Linuxmint 20.2 uma
Kernel: x86_64 Linux 5.4.0-91-generic
DE: Xfce
WM: Xfwm4
CPU: Intel Core i3-2310M @ 4x 2.1GHz
GPU: Mesa DRI Intel(R) HD Graphics 3000 (SNB GT2)
ffmpeg: 4.2.4

$ lspci -k | grep -i -A 2 -E "(vga|3d|display)"
00:02.0 VGA compatible controller: Intel Corporation 2nd Generation Core Processor Family Integrated Graphics Controller (rev 09)
    DeviceName: 32
    Subsystem: Hewlett-Packard Company 2nd Generation Core Processor Family Integrated Graphics Controller
--
01:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Seymour [Radeon HD 6400M/7400M Series]
    Subsystem: Hewlett-Packard Company Radeon HD 6490M
    Kernel driver in use: radeon
Evgeny
  • 45
  • 6
  • 1
    You'll need to specify the `-compression_level` you want (i.e. lower level of compression means higher quality and bigger files). The argument is a small integer, from 1 up to some limit dependent on the device (not more than 7) - higher values are faster / lower stream quality. You can also check here for samples: https://trac.ffmpeg.org/wiki/Hardware/VAAPI#Encode-only – yuuuu Dec 27 '21 at 18:11
  • 1
    If I add `-compression_level x` to the command line (where x=1...7), ffmpeg operation is interrupted and the following message is output: `No usable encoding entrypoint found for profile VAProfileH264High (7). Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height` – Evgeny Dec 28 '21 at 18:30

0 Answers0