# GPU transcoding performance comparision using FFmpeg 4 and 5 branches

**URL:** <https://forums.developer.nvidia.com/t/gpu-transcoding-performance-comparision-using-ffmpeg-4-and-5-branches/269999>\
**Category:** Video Codec, PyNv & OFA\
**Tags:** ffmpeg, gpu, cuda\
**Created:** [October 19, 2023, 2:01pm UTC](https://forums.developer.nvidia.com/t/gpu-transcoding-performance-comparision-using-ffmpeg-4-and-5-branches/269999 "2023-10-19T14:01:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcomay](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@marcomay](https://forums.developer.nvidia.com/u/marcomay)\
**Post date:** [October 19, 2023, 2:01pm UTC](https://forums.developer.nvidia.com/t/gpu-transcoding-performance-comparision-using-ffmpeg-4-and-5-branches/269999/1 "2023-10-19T14:01:21Z")

</div>

Hi,

Recently I’ve created some test runs for transcoding given MP4 files using FFmpeg with GPU acceleration.

I’ve noticed a drop in performance testing the recent FFmpeg 5.1 release with a simple full hardware transcode using `h264_nvenc` in comparison with FFmpeg 4.3/4.4.

Are there any comparable issues? Any hints to diagnose this?

Are benchmark results for GPU encoding/transcoding to compare?

**Test**

Old FFmpeg v4.4.4 version is called with parameter:

```auto
ffmpeg -y -hwaccel cuvid -c:v h264_cuvid -i input.mp4 -c:v h264_nvenc -b:v 2M output.mp4

```

New FFmpeg v5.1.3 version with is called parameter:

```auto
ffmpeg -y -hwaccel cuda -hwaccel_output_format cuda -extra_hw_frames 8 -i input.mp4 -c:v h264_nvenc -b:v 2M output.mp4

```

Added `time ffmpeg -y -benchmark ...` to measure the difference.

**Results**

For FFmpeg 4.4.4:

```auto
frame=32782 fps=344 q=19.0 Lsize= 343834kB time=00:21:51.32 bitrate=2148.0kbits/s speed=13.8x
video:322022kB audio:20521kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.377177%
bench: utime=30.184s stime=21.803s rtime=95.442s
bench: maxrss=135840kB
[aac @ 0x5601c60686c0] Qavg: 222.746

real 1m35.543s
user 0m30.184s
sys 0m21.845s

```

For FFmpeg 5.1.2:

```auto
frame=32782 fps=241 q=19.0 Lsize= 343956kB time=00:21:51.34 bitrate=2148.7kbits/s speed=9.63x
video:322022kB audio:20643kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.377043%
bench: utime=66.753s stime=27.008s rtime=136.567s
bench: maxrss=161032kB
[aac @ 0x55d7f93bd3c0] Qavg: 579.972

real 2m16.669s
user 1m6.777s
sys 0m27.032s

```

**Setup**

The input.mp4 was a video container a video track with ~ 21 min, H.264 (High@L3.1), 720p, 25 fps, 892 kbps bitrate, yuv420p and audio: AAC, 128 kbps.

Ffmpeg builds created in a docker container using `nvidia/cuda:12.0.1-devel-ubuntu22.04` and `nvidia/cuda:12.0.1-base-ubuntu22.04` with `libnpp-12-0` installed as runtime image.

With headers from this tag: [https://github.com/FFmpeg/nv-codec-headers/archive/refs/tags/n12.0.16.0.tar.gz](https://github.com/FFmpeg/nv-codec-headers/archive/refs/tags/n12.0.16.0.tar.gz).

FFMPEG was build with following configuration:

```auto
RUN cd /tmp/ffmpeg-${FFMPEG_VERSION} && \
    ./configure \
    --prefix=${PREFIX} \
    --disable-debug \
    --disable-doc \
    --disable-ffplay \    
    --enable-version3 \
    --enable-gpl \
    --enable-nonfree \
    --enable-small \
    --enable-libfdk-aac \
    --enable-openssl \
    --enable-cuda \
    --enable-cuvid \
    --enable-nvenc \    
    --enable-libnpp \
    --enable-nvenc \    
    --enable-shared \
    --extra-cflags="-I${PREFIX}/include -I${PREFIX}/include/ffnvcodec -I/usr/local/cuda/include/" \
    --extra-ldflags="-L${PREFIX}/lib -L/usr/local/cuda/lib64/" \
    --extra-libs=-ldl && \
    make && \
    make install && \
    make distclean && \
    hash -r

```

Hardware: NVIDIA GeForce RTX 2080, Driver Version: 536.23, Docker 4.24.1 on Windows 10.

Thanks in advance for your comments and feedback on this issue.

---

<div class="post-metadata">

**Author:** ![val.zapod.vz](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@val.zapod.vz](https://forums.developer.nvidia.com/u/val.zapod.vz)\
**Post date:** [November 29, 2023, 8:27pm UTC](https://forums.developer.nvidia.com/t/gpu-transcoding-performance-comparision-using-ffmpeg-4-and-5-branches/269999/2 "2023-11-29T20:27:52Z")

</div>

Where is -hwaccel\_output\_format cuda -i .\test.mp4

It will be slow otherwise.
