Nvh264enc not compatible with multifilesink next-file 2 (key-frame)

Hi,

I’m trying to setup a pipeline that encodes H264 video, and then save the result to a sequence of files.

I found that there’s a plugin called multifilesink for the task quickly. If the next-file property is set to 2 (key-frame), the plugin can create a new file each time a key frame is received, which is exactly what I want.

It works with one encoder, but fails with the other.

working example with openh264enc:

gst-launch-1.0 videotestsrc is-live=true ! video/x-raw,width=800,height=600,framerate=30/1 ! openh264enc bitrate=2560000 ! multifilesink location=output-%05d.mp4 next-file=2

failed example with nvh264enc:

gst-launch-1.0 videotestsrc is-live=true ! video/x-raw,width=800,height=600,framerate=30/1 ! nvh264enc ! multifilesink location=output-%05d.mp4 next-file=2

All files created by openh264enc can be opened by PotPlayer. They are also recognized by gst-discoverer-1.0 and ffprobe.

Files created by nvh264enc cannot be opened, or recognized by gst-discoverer / ffprobe, except for the first file.

I’m not sure whether it is an issue of nvh264enc. Is it a known issue or something new?

Here’s my testing environment:

  • Windows 11 23H2 64 bit
  • GStreamer 1.24.5 msvc x86_64
  • NVIDIA RTX 3060 Laptop (522.06, 31.0.15.2226)
  • PotPlayer 220106 (1.7.21595)

No issues with vah264enc. Maybe post your pipeline to NVidia forum for help.

nvh264enc will insert SPS/PPS only for the first keyframe by default. In main branch, nvh264enc repeat-sequence-header=true will insert the headers per keyframe.

Or, in case of 1.24, if you want to produce h264 ES chunks, below pipeline will work (see h264parse config-interval=-1, also output stream format of parser should be byte-stream if you need to write ES bitstream into files)
gst-launch-1.0 videotestsrc is-live=true ! video/x-raw,width=800,height=600,framerate=30/1 ! nvh264enc ! h264parse config-interval=-1 ! video/x-h264,stream-format=byte-stream ! multifilesink location=output-%05d.mp4 next-file=2

1 Like