[FFmpeg-user] High Bitrate H265 (Hardware Accelerated) RTP Streaming

Kyle Vernyi vernyikyle4 at gmail.com
Tue Apr 4 21:01:19 EEST 2023


Hi all.

I am currently using FFmpeg as my encoder / decoder / media player for a
research project at NASA Glenn. We are developing ways to stream multimedia
in near Earth networks. Specifically, I am using a network framework called
HDTN. Search "HDTN NASA Glenn" for more info if you are interested.

Regardless, I am having issues with FFmpeg. I am attempting to stream a
pre-encoded video. I am trying to do a simple loopback test before
implementing the stream into our own custom network.

Here is a description of the media I wish to stream (using RTP) from
FFprobe:

ffprobe water_bubble.mp4
ffprobe version N-109867-g5247dab6b1 Copyright (c) 2007-2023 the FFmpeg
developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp
--extra-cflags=-I/usr/local/cuda/include
--extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared
--enable-libx265 --enable-gpl --enable-ffplay --enable-libvmaf
--enable-version3 --enable-libx264
  libavutil      58.  1.100 / 58.  1.100
  libavcodec     60.  2.100 / 60.  2.100
  libavformat    60.  2.100 / 60.  2.100
  libavdevice    60.  0.100 / 60.  0.100
  libavfilter     9.  1.100 /  9.  1.100
  libswscale      7.  0.100 /  7.  0.100
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    57.  0.100 / 57.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'water_bubble.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf60.2.100
  Duration: 00:01:00.74, start: 0.000000, bitrate: 99765 kb/s
  Stream #0:0[0x1](und): Video: hevc (Rext) (hev1 / 0x31766568),
yuv422p10le(tv, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 99934
kb/s, 60.06 fps, 59.94 tbr, 16k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      timecode        : 03:57:30;00
  Stream #0:1[0x2](eng): Data: none (tmcd / 0x64636D74)
    Metadata:
      handler_name    : TimeCodeHandler
      timecode        : 03:57:30;00

As you can see, it is a 4K60 422p10le H265 encoded video. I understand this
is a fairly demanding video format and the bitrate shows that.

Here is my ffmpeg "sender" command and the resultant output:

ffmpeg -y -sdp_file HDTN.sdp -re -i $file -c copy -an -f rtp "rtp://
127.0.0.1:50000"

ffmpeg version N-109867-g5247dab6b1 Copyright (c) 2000-2023 the FFmpeg
developers
  built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1)
  configuration: --enable-nonfree --enable-cuda-nvcc --enable-libnpp
--extra-cflags=-I/usr/local/cuda/include
--extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared
--enable-libx265 --enable-gpl --enable-ffplay --enable-libvmaf
--enable-version3 --enable-libx264
  libavutil      58.  1.100 / 58.  1.100
  libavcodec     60.  2.100 / 60.  2.100
  libavformat    60.  2.100 / 60.  2.100
  libavdevice    60.  0.100 / 60.  0.100
  libavfilter     9.  1.100 /  9.  1.100
  libswscale      7.  0.100 /  7.  0.100
  libswresample   4.  9.100 /  4.  9.100
  libpostproc    57.  0.100 / 57.  0.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
official_test_media/water_bubble.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf60.2.100
  Duration: 00:01:00.74, start: 0.000000, bitrate: 99765 kb/s
  Stream #0:0[0x1](und): Video: hevc (Rext) (hev1 / 0x31766568),
yuv422p10le(tv, bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], 99934
kb/s, 60.06 fps, 59.94 tbr, 16k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      timecode        : 03:57:30;00
  Stream #0:1[0x2](eng): Data: none (tmcd / 0x64636D74)
    Metadata:
      handler_name    : TimeCodeHandler
      timecode        : 03:57:30;00
Output #0, rtp, to 'rtp://127.0.0.1:50000':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2mp41
    encoder         : Lavf60.2.100
  Stream #0:0(und): Video: hevc (Rext) (hev1 / 0x31766568), yuv422p10le(tv,
bt709, progressive), 3840x2160 [SAR 1:1 DAR 16:9], q=2-31, 99934 kb/s,
60.06 fps, 59.94 tbr, 90k tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
      timecode        : 03:57:30;00
Stream mapping:
  Stream #0:0 -> #0:0 (copy)

I am using RTP, so I have to send the audio and video on two separate
channels. I am not very concerned with audio for now so I am leaving that
out.

Here is the receiver command. I am using an RTX3080 with hwaccel.

ffmpeg  -hwaccel cuda -hwaccel_output_format cuda \
        -protocol_whitelist file,udp,rtp \
        -strict experimental \
        -fflags +genpts \
        -seek2any 1 \
        -avoid_negative_ts +make_zero \
        -reorder_queue_size 0 \
        -loglevel verbose \
        -fflags nobuffer+fastseek+flush_packets -flags low_delay \
        -i HDTN.sdp \
        -f matroska - | ffplay -i -

As you can see, I am piping the output to ffplay for display. I thought
ffplay may be the issue I also tried

-f mp4 loopback_output.mp4

But that had zero effect.

The main issue is that the video stream is completely destroyed. The screen
is covered in grey and green H265 artifacts. It is covered in macroblocks
and is almost unrecognizable.

Is there something wrong with my ffmpeg commands? This test serves to just
determine the capabilities of ffmpeg to generate and save a high quality
RTP stream. I recognize that the video bitrate is very high, and that may
be the issue. However, my CPU is not throttling. I find it strange that
ffmpeg can not keep up despite doing no actual encoding or decoding in this
example. I tested the same commands with a different 4k60 10Mbps bitrate
video and it handles that much much better, though not perfectly.

Some additional notes:
- the stream quality is even worse when I expand the reorder_queue_size
more than 0
- I get many many decoder errors such as
     - [hevc @ 0x5570dce9c180] Could not find ref with POC 160
     - [hevc @ 0x5570dce9c180] The cu_qp_delta 76 is outside the valid
range [-32, 31].
- the original video itself is perfect quality
- lowering the frame rate to 5fps helps the quality (lowers bitrate?)

Thank you for any assistance
Kyle


More information about the ffmpeg-user mailing list