gstreamervp8libvpx

What settings can be used for live video for vp8enc in gstreamer?


I'm looking into using this element to encode live video, and in most cases, where the input video is relatively simple, it works fine. However for some of our scenes the encoder falls behind. (In particular we have a test scene with a bunch of birds that gives encoders fits.)

Looking at the output, I believe this is because the element doesn't seem to adjust the QP for complex scenes. I don't see a specific tuning for "live" video though. Does anyone have any suggestions?

Element Properties:
  name                : The name of the object
                        flags: readable, writable
                        String. Default: "vp8enc0"
  parent              : The parent of the object
                        flags: readable, writable
                        Object of type "GstObject"
  end-usage           : Rate control mode
                        flags: readable, writable
                        Enum "GstVPXEncEndUsage" Default: 0, "vbr"
                           (0): vbr              - Variable Bit Rate (VBR) mode
                           (1): cbr              - Constant Bit Rate (CBR) mode
                           (2): cq               - Constant Quality Mode (CQ) mode
  target-bitrate      : Target bitrate (in bits/sec)
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 256000 
  min-quantizer       : Minimum Quantizer (best)
                        flags: readable, writable
                        Integer. Range: 0 - 63 Default: 4 
  max-quantizer       : Maximum Quantizer (worst)
                        flags: readable, writable
                        Integer. Range: 0 - 63 Default: 63 
  dropframe-threshold : Temporal resampling threshold (buf %)
                        flags: readable, writable
                        Integer. Range: 0 - 100 Default: 0 
  resize-allowed      : Allow spatial resampling
                        flags: readable, writable
                        Boolean. Default: false
  resize-up-threshold : Upscale threshold (buf %)
                        flags: readable, writable
                        Integer. Range: 0 - 100 Default: 60 
  resize-down-threshold: Downscale threshold (buf %)
                        flags: readable, writable
                        Integer. Range: 0 - 100 Default: 30 
  undershoot          : Datarate undershoot (min) target (%)
                        flags: readable, writable
                        Integer. Range: 0 - 1000 Default: 100 
  overshoot           : Datarate overshoot (max) target (%)
                        flags: readable, writable
                        Integer. Range: 0 - 1000 Default: 100 
  buffer-size         : Client buffer size (ms)
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 6000 
  buffer-initial-size : Initial client buffer size (ms)
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 4000 
  buffer-optimal-size : Optimal client buffer size (ms)
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 5000 
  twopass-vbr-bias    : CBR/VBR bias (0=CBR, 100=VBR)
                        flags: readable, writable
                        Integer. Range: 0 - 100 Default: 50 
  twopass-vbr-minsection: GOP minimum bitrate (% target)
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 0 
  twopass-vbr-maxsection: GOP maximum bitrate (% target)
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 400 
  keyframe-mode       : Keyframe placement
                        flags: readable, writable
                        Enum "GstVPXEncKfMode" Default: 1, "auto"
                           (1): auto             - Determine optimal placement automatically
                           (0): disabled         - Don't automatically place keyframes
  keyframe-max-dist   : Maximum distance between keyframes (number of frames)
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 128 
  temporal-scalability-number-layers: Number of coding layers to use
                        flags: readable, writable
                        Integer. Range: 1 - 5 Default: 1 
  temporal-scalability-target-bitrate: Target bitrates for coding layers (one per layer, decreasing)
                        flags: readable, writable
                        Array of GValues of type "gint"
  temporal-scalability-rate-decimator: Rate decimation factors for each layer
                        flags: readable, writable
                        Array of GValues of type "gint"
  temporal-scalability-periodicity: Length of sequence that defines layer membership periodicity
                        flags: readable, writable
                        Integer. Range: 0 - 16 Default: 0 
  temporal-scalability-layer-id: Sequence defining coding layer membership
                        flags: readable, writable
                        Array of GValues of type "gint"
  multipass-mode      : Multipass encode mode
                        flags: readable, writable
                        Enum "GstVPXEncMultipassMode" Default: 0, "one-pass"
                           (0): one-pass         - One pass encoding (default)
                           (1): first-pass       - First pass of multipass encoding
                           (2): last-pass        - Last pass of multipass encoding
  multipass-cache-file: Multipass cache file. If stream caps reinited, multiple files will be created: file, file.1, file.2, ... and so on.
                        flags: readable, writable
                        String. Default: "multipass.cache"
  error-resilient     : Error resilience flags
                        flags: readable, writable
                        Flags "GstVPXEncErFlags" Default: 0x00000000, "(none)"
                           (0x00000001): default          - Default error resilience
                           (0x00000002): partitions       - Allow partitions to be decoded independently
  lag-in-frames       : Maximum number of frames to lag
                        flags: readable, writable
                        Integer. Range: 0 - 25 Default: 0 
  threads             : Number of threads to use
                        flags: readable, writable
                        Integer. Range: 0 - 64 Default: 0 
  deadline            : Deadline per frame (usec, 0=disabled)
                        flags: readable, writable
                        Integer64. Range: 0 - 9223372036854775807 Default: 0 
  horizontal-scaling-mode: Horizontal scaling mode
                        flags: readable, writable
                        Enum "GstVPXEncScalingMode" Default: 0, "normal"
                           (0): normal           - Normal
                           (1): 4:5              - 4:5
                           (2): 3:5              - 3:5
                           (3): 1:2              - 1:2
  vertical-scaling-mode: Vertical scaling mode
                        flags: readable, writable
                        Enum "GstVPXEncScalingMode" Default: 0, "normal"
                           (0): normal           - Normal
                           (1): 4:5              - 4:5
                           (2): 3:5              - 3:5
                           (3): 1:2              - 1:2
  cpu-used            : CPU used
                        flags: readable, writable
                        Integer. Range: -16 - 16 Default: 0 
  auto-alt-ref        : Automatically generate AltRef frames
                        flags: readable, writable
                        Boolean. Default: false
  noise-sensitivity   : Noise sensisivity (frames to blur)
                        flags: readable, writable
                        Integer. Range: 0 - 6 Default: 0 
  sharpness           : Filter sharpness
                        flags: readable, writable
                        Integer. Range: 0 - 7 Default: 0 
  static-threshold    : Motion detection threshold
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 0 
  token-partitions    : Number of token partitions
                        flags: readable, writable
                        Enum "GstVPXEncTokenPartitions" Default: 0, "1"
                           (0): 1                - One token partition
                           (1): 2                - Two token partitions
                           (2): 4                - Four token partitions
                           (3): 8                - Eight token partitions
  arnr-maxframes      : AltRef maximum number of frames
                        flags: readable, writable
                        Integer. Range: 0 - 15 Default: 0 
  arnr-strength       : AltRef strength
                        flags: readable, writable
                        Integer. Range: 0 - 6 Default: 3 
  arnr-type           : AltRef type
                        flags: readable, writable, deprecated
                        Integer. Range: 1 - 3 Default: 3 
  tuning              : Tuning
                        flags: readable, writable
                        Enum "GstVPXEncTuning" Default: 0, "psnr"
                           (0): psnr             - Tune for PSNR
                           (1): ssim             - Tune for SSIM
  cq-level            : Constrained quality level
                        flags: readable, writable
                        Integer. Range: 0 - 63 Default: 10 
  max-intra-bitrate   : Maximum Intra frame bitrate
                        flags: readable, writable
                        Integer. Range: 0 - 2147483647 Default: 0 
  timebase            : Fraction of one second that is the shortest interframe time - normally left as zero which will default to the framerate
                        flags: readable, writable
                        Fraction. Range: 0/1 - 2147483647/1 Default: 0/1 

Solution

  • Here is my setup using a webcam and JACK as the audio source:

    gst-launch-1.0 v4l2src device=/dev/video0 ! video/x-raw, format=YUY2, width=$WIDTH, height=$HEIGHT, framerate=$FRAMERATE/1  \
            ! queue ! videoconvert \
            ! queue ! vp8enc threads=4 deadline=2 \
            ! queue ! muxout. \
            jackaudiosrc connect=1 ! audio/x-raw, format=F32LE, channels=1 \
            ! queue ! audiocheblimit mode=high-pass cutoff=120 poles=4 \
            ! queue ! audiodynamic characteristics=soft-knee mode=compressor threshold=0.16 ratio=0.15 \
            ! queue ! rgvolume pre-amp=6.0 headroom=1.0 \
            ! queue ! rglimiter \
            ! queue ! audioconvert \
            ! queue ! opusenc bitrate=96000 \
            ! queue ! muxout. \
            webmmux streamable=true name=muxout \
            ! queue ! tcpserversink host=127.0.0.1 port=9000 blocksize=65536 sync-method=1 \
            > /dev/null