0

I'm relatively new to the entrails of ffmpeg so feel free to point out anything in my question which would not make sense.

I have a .mp4 file encoded with hevc which I would want converted to h264 :

ffprobe version git-2020-06-23-ce297b4 Copyright (c) 2007-2020 the FFmpeg developers
  built with gcc 9.3.1 (GCC) 20200621
  configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libgsm --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
  libavutil      56. 55.100 / 56. 55.100
  libavcodec     58. 93.100 / 58. 93.100
  libavformat    58. 47.100 / 58. 47.100
  libavdevice    58. 11.100 / 58. 11.100
  libavfilter     7. 86.100 /  7. 86.100
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'source.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    creation_time   : <redacted>
    title           : <redacted>
    encoder         : Lavf58.20.100
    comment         : <redacted>
  Duration: 01:30:15.47, start: 0.000000, bitrate: 2232 kb/s
    Stream #0:0(und): Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(tv), 1920x1080 [SAR 1:1 DAR 16:9], 2003 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 23.98 tbc (default)
    Metadata:
      creation_time   : <redacted>
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 5.1, fltp, 224 kb/s (default)
    Metadata:
      creation_time   : <redacted>
      handler_name    : SoundHandler

This works totally fine if I use CPU-bound libraries. But it is painfully slow (somewhere around 40 FPS) :

ffmpeg -i source.mp4 -map 0 -c:v libx264 -crf 18 -vf format=yuv420p -c:a copy output.mp4

Based on the doc I did check that dxva2 is enabled and working fine (roughly 300 FPS) :

ffmpeg -hwaccel dxva2 -threads 4 -i source.mp4 -f null - -benchmark

But as soon as I throw a -map to convert the 0 stream (which I presume is the video) to libx264 then I'm back at CPU-bound performances (task manager shows the GPU sits mostly idle, CPU is 100%. Progress made at 30 FPS)

ffmpeg -hwaccel dxva2 -threads 1 -i source.mp4 -map 0 -c:v libx264 -crf 18 -c:a copy out.mp4

Is the command wrong ? Or is it expected performances ?

I'm running W10 with NVidia RTX 2060

0 Answers0