RTMP Streaming Issue(nvv4l2h264enc vs x264enc)

The nvv4l2h264enc has a problem when sending a rtmp stream to vimeo.com, WowzaStreamingEngine-4.8.12+1 server using a transcoder or some other rtmp platforms.
But with x264enc had no problem So I made and dumped the encoded files to compare between nvv4l2h264enc and x264enc.

A difference of two plugins was “nominal bitrate” and the encoded file by nvv4l2h264enc had no bitrate value.
Is there anyway to set “nominal bitrate” in audio and video?

filedump with x264enc

$ gst-launch-1.0 -e -v \
	flvmux name=mux streamable=true latency=100000000 \
	! filesink location=x264.flv \
	videotestsrc num-buffers=1000 \
	! "video/x-raw ,width=(int)640 ,height=(int)360 ,framerate=(fraction)30/1, format=(string)NV12" \
	! x264enc \
	! h264parse \
	! mux. \
	audiotestsrc num-buffers=1000 \
	! "audio/x-raw,format=(string)S32LE,rate=48000,channels=2" \
	! audiorate \
	! queue \
	! audioconvert \
	! voaacenc \
	! aacparse \
	! mux.

$ gst-discoverer-1.0 -v x264.flv
Analyzing file:///home/aile/x264.flv
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Done discovering file:///home/aile/x264.flv

Topology:
  container: video/x-flv
    audio: audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)48000, channels=(int)2, codec_data=(buffer)1190, level=(string)2, base-profile=(string)lc, profile=(string)lc
      Tags:
        encoder: GStreamer 1.14.5 FLV muxer
        datetime: 2021-10-14T02:45:18Z
        video codec: H.264
        audio codec: MPEG-4 AAC
        nominal bitrate: 0

      Codec:
        audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)48000, channels=(int)2, codec_data=(buffer)1190, level=(string)2, base-profile=(string)lc, profile=(string)lc
      Additional info:
        None
      Stream ID: 15f8ddece27f1b7e75f5ef82441eb3381b643d66b82791ec7a8c32e0be455d85/audio
      Language: <unknown>
      Channels: 2 (front-left, front-right)
      Sample rate: 48000
      Depth: 32
      Bitrate: 0
      Max bitrate: 0
    video: video/x-h264, stream-format=(string)byte-stream, pixel-aspect-ratio=(fraction)1/1, width=(int)640, height=(int)360, framerate=(fraction)30/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true, alignment=(string)au, profile=(string)high, level=(string)3
      Tags:
        encoder: GStreamer 1.14.5 FLV muxer
        datetime: 2021-10-14T02:45:18Z
        video codec: H.264
        nominal bitrate: 2097152
        audio codec: MPEG-4 AAC

      Codec:
        video/x-h264, stream-format=(string)byte-stream, pixel-aspect-ratio=(fraction)1/1, width=(int)640, height=(int)360, framerate=(fraction)30/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true, alignment=(string)au, profile=(string)high, level=(string)3
      Additional info:
        None
      Stream ID: 15f8ddece27f1b7e75f5ef82441eb3381b643d66b82791ec7a8c32e0be455d85/video
      Width: 640
      Height: 360
      Depth: 24
      Frame rate: 30/1
      Pixel aspect ratio: 1/1
      Interlaced: false
      Bitrate: 2097152
      Max bitrate: 0

Properties:
  Duration: 0:00:33.233000000
  Seekable: yes
  Live: no
  Tags:
      encoder: GStreamer 1.14.5 FLV muxer
      datetime: 2021-10-14T02:45:18Z
      video codec: H.264
      audio codec: MPEG-4 AAC
      nominal bitrate: 0

filedump with nvv4l2h264enc

$ gst-launch-1.0 -e -v \
	flvmux name=mux streamable=true latency=100000000 \
	! filesink location=h264.flv \
	videotestsrc num-buffers=1000 \
	! "video/x-raw ,width=(int)640 ,height=(int)360 ,framerate=(fraction)30/1, format=(string)NV12" \
	! nvvidconv ! nvv4l2h264enc profile=4 bitrate=2000000 insert-vui=true insert-aud=true \
	! h264parse \
	! mux. \
	audiotestsrc num-buffers=1000 \
	! "audio/x-raw,format=(string)S32LE,rate=48000,channels=2" \
	! audiorate \
	! queue \
	! audioconvert \
	! voaacenc \
	! aacparse \
	! mux.

$ gst-discoverer-1.0 -v h264.flv
Analyzing file:///home/aile/h264.flv
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Done discovering file:///home/aile/h264.flv

Topology:
  container: video/x-flv
    audio: audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)48000, channels=(int)2, codec_data=(buffer)1190, level=(string)2, base-profile=(string)lc, profile=(string)lc
      Tags:
        encoder: GStreamer 1.14.5 FLV muxer
        datetime: 2021-10-14T02:45:31Z
        video codec: H.264
        audio codec: MPEG-4 AAC
        nominal bitrate: 0

      Codec:
        audio/mpeg, mpegversion=(int)4, framed=(boolean)true, stream-format=(string)raw, rate=(int)48000, channels=(int)2, codec_data=(buffer)1190, level=(string)2, base-profile=(string)lc, profile=(string)lc
      Additional info:
        None
      Stream ID: 71f87fc66c2230d8e68c6737aec2cf46759d969b01b97835f3c698470f476cc3/audio
      Language: <unknown>
      Channels: 2 (front-left, front-right)
      Sample rate: 48000
      Depth: 32
      Bitrate: 0
      Max bitrate: 0
    video: video/x-h264, stream-format=(string)byte-stream, pixel-aspect-ratio=(fraction)1/1, width=(int)640, height=(int)360, framerate=(fraction)30/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true, alignment=(string)au, profile=(string)high, level=(string)3
      Tags:
        encoder: GStreamer 1.14.5 FLV muxer
        datetime: 2021-10-14T02:45:31Z
        video codec: H.264
        nominal bitrate: 0
        audio codec: MPEG-4 AAC

      Codec:
        video/x-h264, stream-format=(string)byte-stream, pixel-aspect-ratio=(fraction)1/1, width=(int)640, height=(int)360, framerate=(fraction)30/1, interlace-mode=(string)progressive, chroma-format=(string)4:2:0, bit-depth-luma=(uint)8, bit-depth-chroma=(uint)8, parsed=(boolean)true, alignment=(string)au, profile=(string)high, level=(string)3
      Additional info:
        None
      Stream ID: 71f87fc66c2230d8e68c6737aec2cf46759d969b01b97835f3c698470f476cc3/video
      Width: 640
      Height: 360
      Depth: 24
      Frame rate: 30/1
      Pixel aspect ratio: 1/1
      Interlaced: false
      Bitrate: 0
      Max bitrate: 0

Properties:
  Duration: 0:00:33.300000000
  Seekable: yes
  Live: no
  Tags:
      encoder: GStreamer 1.14.5 FLV muxer
      datetime: 2021-10-14T02:45:31Z
      video codec: H.264
      audio codec: MPEG-4 AAC
      nominal bitrate: 0

Hi,
Could you try ffprobe? I am able to see bitrate information when parsing the file through ffprobe.

Not sure why vimeo cannot read the stream. Suggest try to set the properties:

  idrinterval         : Encoding IDR Frame occurance frequency
                        flags: readable, writable, changeable only in NULL or READY state
                        Unsigned Integer. Range: 0 - 4294967295 Default: 256
  profile             : Set profile for v4l2 encode
                        flags: readable, writable, changeable only in NULL or READY state
                        Enum "GstV4l2VideoEncProfileType" Default: 0, "Baseline"
                           (0): Baseline         - GST_V4L2_H264_VIDENC_BASELINE_PROFILE
                           (2): Main             - GST_V4L2_H264_VIDENC_MAIN_PROFILE
                           (4): High             - GST_V4L2_H264_VIDENC_HIGH_PROFILE
                           (7): High444          - GST_V4L2_H264_VIDENC_HIGH_444_PREDICTIVE
  insert-sps-pps      : Insert H.264 SPS, PPS at every IDR frame
                        flags: readable, writable
                        Boolean. Default: false
  disable-cabac       : Set Entropy Coding Type CAVLC(TRUE) or CABAC(FALSE)
                        flags: readable, writable
                        Boolean. Default: false

The default IDR interval is 256. The value is a bit large for streaming. May set to 30 or 60 for a try. Or can try baseline or main profile. Or encode in CAVLC.

ffprobe with nvv4l2h264enc:

❯ ffprobe -show_streams -show_format -hide_banner h264.flv
Input #0, flv, from 'h264.flv':
  Metadata:
    AspectRatioX    : 1
    AspectRatioY    : 1
    metadatacreator : GStreamer 1.14.5 FLV muxer
    creationdate    : Thu Oct 14 02:45:31 2021
  Duration: 00:00:33.30, start: 0.000000, bitrate: 2150 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt470bg/reserved/reserved, progressive), 640x360, 30 fps, 30 tbr, 1k tbn, 60 tbc
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1/60
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=640
height=360
coded_width=640
coded_height=360
has_b_frames=0
sample_aspect_ratio=0:1
display_aspect_ratio=0:1
pix_fmt=yuv420p
level=30
color_range=tv
color_space=bt470bg
color_transfer=reserved
color_primaries=reserved
chroma_location=left
field_order=progressive
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=30/1
avg_frame_rate=30/1
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[STREAM]
index=1
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_time_base=1/48000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=h264.flv
nb_streams=2
nb_programs=0
format_name=flv
format_long_name=FLV (Flash Video)
start_time=0.000000
duration=33.300000
size=8953395
bit_rate=2150965
probe_score=100
TAG:AspectRatioX=1
TAG:AspectRatioY=1
TAG:metadatacreator=GStreamer 1.14.5 FLV muxer
TAG:creationdate=Thu Oct 14 02:45:31 2021
[/FORMAT]

ffprobe with x264enc:

❯ ffprobe -show_streams -show_format -hide_banner x264.flv
Input #0, flv, from 'x264.flv':
  Metadata:
    AspectRatioX    : 1
    AspectRatioY    : 1
    metadatacreator : GStreamer 1.14.5 FLV muxer
    creationdate    : Thu Oct 14 02:45:18 2021
  Duration: 00:00:33.23, start: 0.000000, bitrate: 2155 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(tv, bt470bg/smpte170m/bt709, progressive), 640x360 [SAR 1:1 DAR 16:9], 2097 kb/s, 30 fps, 30 tbr, 1k tbn, 60 tbc
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp
[STREAM]
index=0
codec_name=h264
codec_long_name=H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
profile=High
codec_type=video
codec_time_base=1/60
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
width=640
height=360
coded_width=640
coded_height=360
has_b_frames=2
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=30
color_range=tv
color_space=bt470bg
color_transfer=bt709
color_primaries=smpte170m
chroma_location=center
field_order=progressive
timecode=N/A
refs=1
is_avc=true
nal_length_size=4
id=N/A
r_frame_rate=30/1
avg_frame_rate=30/1
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=2097152
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[STREAM]
index=1
codec_name=aac
codec_long_name=AAC (Advanced Audio Coding)
profile=LC
codec_type=audio
codec_time_base=1/48000
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=fltp
sample_rate=48000
channels=2
channel_layout=stereo
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/1000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
[FORMAT]
filename=x264.flv
nb_streams=2
nb_programs=0
format_name=flv
format_long_name=FLV (Flash Video)
start_time=0.000000
duration=33.233000
size=8953085
bit_rate=2155227
probe_score=100
TAG:AspectRatioX=1
TAG:AspectRatioY=1
TAG:metadatacreator=GStreamer 1.14.5 FLV muxer
TAG:creationdate=Thu Oct 14 02:45:18 2021
[/FORMAT]

add properties: idrinterval, profile, disable-cache

gst-launch-1.0 -e -v \
        flvmux name=mux streamable=true latency=100000000 \
	! filesink location=h264.flv \
        videotestsrc \
        ! "video/x-raw ,width=(int)640 ,height=(int)360 ,framerate=(fraction)30/1, format=(string)NV12, pixel-aspect-ratio=1/1" \
        ! nvvidconv \
        ! nvv4l2h264enc insert-sps-pps=true vbv_size=2000000 bitrate=2000000 idrinterval=30 profile=2 disable-cabac=true \
        ! h264parse \
        ! mux. \
        audiotestsrc \
        ! "audio/x-raw,format=(string)S32LE,rate=48000,channels=2" \
        ! audiorate \
        ! queue \
        ! audioconvert \
        ! voaacenc \
        ! aacparse \
        ! mux.

but the nvv4l2h264enc has a problem.

test environment

$ cat /etc/nv_tegra_release
# R32 (release), REVISION: 6.1, GCID: 27863751, BOARD: t210ref, EABI: aarch64, DATE: Mon Jul 26 19:20:30 UTC 2021
$ gst-launch-1.0 --version
gst-launch-1.0 version 1.14.5
GStreamer 1.14.5
https://launchpad.net/distros/ubuntu/+source/gstreamer1.0

We thought “nominal bitrate” was a cause of problem, because VBR encoding also set the nominal bitrate to zero and rtmp stream had problem to vimeo and wowza transcoding server, as well.
Both of nvv4l2h264enc and x264 with VBR encoding had a problem.

Can we set “nominal bitrate” when using nvv4l2h264enc and CBR condition?

Hi,
Since source code of gst-v4l2 is public. You can check code of x264enc and port the part to gst-v4l2:
gst-plugins-ugly/gstx264enc.c at master · GStreamer/gst-plugins-ugly · GitHub

Source code of gst-v4l2 is in
https://developer.nvidia.com/embedded/l4t/r32_release_v6.1/sources/t186/public_sources.tbz2

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.