Adapting H264 encoding rate

Guillaume Denis gdenispro at gmail.com
Thu Jun 1 07:18:00 UTC 2023


Hello,

We are using GStreamer within a WebRTC app (the WebRTC part is done with
https://github.com/pion/webrtc) where we estimate the best target bitrate
depending on network conditions (congestion control).

I was wondering if anyone has experience about the best way to control
encoders (x264enc and nvcodec' nvh264enc) in particular:

   - when we update the target bitrate: should it be done at a slow pace?
   (or: is updating every second could be useless or even harmful in any way)
   - can it have an impact on keyframes (other than their quality)?
   - are there other encoders' properties worth controlling?

Just in case anyone is interested, below is a typical pipeline we use.

Thanks,
Guillaume

## Pipeline with RTP in/out (appsrc/appsink)
## and two filesinks (one for the in/dry stream, one after applying a video
FX, here facedetect)
## we force streams to a 800x600 resolution not to crash muxers with
changing resolutions

appsrc name=video_src is-live=true format=GST_FORMAT_TIME
min-latency=33333333
appsink name=video_sink qos=true
matroskamux name=dry_recorder ! filesink location=data/dry.mkv
matroskamux name=wet_recorder ! filesink location=data/wet.mkv

video_src. !
application/x-rtp,encoding-name=H264 !
rtpjitterbuffer name=video_buffer do-lost=1
add-reference-timestamp-meta=true latency=200 !
rtph264depay wait-for-keyframe=true !
h264parse !
nvh264sldec min-force-key-unit-interval=3000000000
discard-corrupted-frames=true qos=true !
cudaupload !
cudaconvertscale !
cudadownload !
videorate !
video/x-raw, framerate=30/1, width=800, height=600, format=I420,
colorimetry=bt601, chroma-site=jpeg, pixel-aspect-ratio=1/1 !

tee name=tee_video_in !
queue !
nvh264enc name=video_encoder_dry rc-mode=3 preset=4 gop-size=15
zerolatency=true b-adapt=0 bframes=0 rc-lookahead=0
min-force-key-unit-interval=3000000000 qos=true ! video/x-h264,
profile=constrained-baseline !
h264parse !
dry_recorder.

tee_video_in. !
queue !
videoconvert !
facedetect !
queue !
cudaupload !
cudaconvertscale !
cudadownload !
video/x-raw, format=I420, colorimetry=bt601, chroma-site=jpeg,
pixel-aspect-ratio=1/1 !
nvh264enc name=video_encoder_wet rc-mode=3 preset=4 gop-size=15
zerolatency=true b-adapt=0 bframes=0 rc-lookahead=0
min-force-key-unit-interval=3000000000 qos=true !
video/x-h264, profile=constrained-baseline !
h264parse !

tee name=tee_video_out !
queue !
wet_recorder.

tee_video_out. !
queue !
rtph264pay config-interval=-1 min-ptime=30000000 !
video_sink.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230601/e82d18d9/attachment.htm>


More information about the gstreamer-devel mailing list