Jump to content

Multimedia Codecs H264 H265 Support Examples

From RidgeRun Developer Wiki

Follow us on: YouTube Twitter LinkedIn Email Share this page

Share This Page

Preferred Partner Logo 3 Partner Program Banner



Codecs

This section validates the NVIDIA hardware accelerated encoding and decoding paths available on Jetson platforms.

The examples still exercise the NVIDIA accelerated codec stack end to end, including:

  • Hardware accelerated H.264 encoding
  • Hardware accelerated H.265 encoding
  • NVIDIA accelerated decoding
  • Buffer conversion through nvvidconv
  • File muxing and playback
  • Multi-branch pipeline handling

Before continuing, make sure the multimedia environment described in Software Environment is already available on the target system.

Runtime Requirements

The examples in this section require the multimedia enabled image together with the NVIDIA accelerated plugins used by the Jetson multimedia stack.

The following plugins should already be available:

gst-inspect-1.0 videotestsrc
gst-inspect-1.0 nvvidconv
gst-inspect-1.0 nvv4l2h264enc
gst-inspect-1.0 nvv4l2h265enc
gst-inspect-1.0 nvv4l2decoder
gst-inspect-1.0 h264parse
gst-inspect-1.0 h265parse
gst-inspect-1.0 matroskamux

What to expect:

  • Each command should print plugin information.
  • None of the commands should return:
No such element or plugin

If one or more plugins are missing, the multimedia image is incomplete and the remaining examples should not be used yet.

Unlike the camera validation examples, this section does not require:

  • nvarguscamerasrc
  • nvargus-daemon
  • CSI camera overlays
  • Physical camera hardware

This makes the section useful for validating codec functionality independently from camera integration.

Synthetic Video Preview

This example validates live video generation together with graphical rendering.

gst-launch-1.0 -e -v videotestsrc is-live=true pattern=smpte \
  ! video/x-raw,width=1920,height=1080,framerate=30/1,format=I420 \
  ! nvvidconv ! 'video/x-raw(memory:NVMM),format=RGBA' \
  ! queue ! nvegltransform ! nveglglessink sync=0

What to expect:

  • The pipeline should move from PAUSED to PLAYING.
  • The SMPTE test pattern should appear in a graphical window if using a local display.
  • Pipelines should terminate cleanly after processing all buffers.
  • The terminal should end with:
Got EOS

H264 Recording

This example validates hardware accelerated H.264 encoding using synthetic video input.

gst-launch-1.0 -e -v videotestsrc is-live=true num-buffers=300 pattern=smpte \
  ! video/x-raw,width=1920,height=1080,framerate=30/1,format=I420 \
  ! nvvidconv ! 'video/x-raw(memory:NVMM),format=I420' \
  ! queue \
  ! nvv4l2h264enc maxperf-enable=1 bitrate=8000000 iframeinterval=30 insert-sps-pps=true \
  ! h264parse config-interval=-1 \
  ! matroskamux ! filesink location=synthetic_h264.mkv sync=false async=false

This pipeline validates:

  • Buffer conversion through nvvidconv
  • Hardware accelerated H.264 encoding
  • H.264 parsing
  • Matroska container generation
  • File output handling

What to expect:

  • The encoder should initialize correctly.
  • The pipeline should terminate with:
Got EOS
  • The file:
synthetic_h264.mkv

should be generated successfully.

Verify the generated file:

ls -lh synthetic_h264.mkv
file synthetic_h264.mkv

Expected results:

  • The file size should be greater than zero.
  • The file command should identify the output as Matroska data.

H265 Recording

This example validates hardware accelerated H.265 encoding using the same synthetic source.

gst-launch-1.0 -e -v videotestsrc is-live=true num-buffers=300 pattern=smpte \
  ! video/x-raw,width=1920,height=1080,framerate=30/1,format=I420 \
  ! nvvidconv ! 'video/x-raw(memory:NVMM),format=I420' \
  ! queue \
  ! nvv4l2h265enc maxperf-enable=1 bitrate=8000000 iframeinterval=30 insert-sps-pps=true \
  ! h265parse config-interval=-1 \
  ! matroskamux ! filesink location=synthetic_h265.mkv sync=false async=false

What to expect:

  • The H.265 encoder should negotiate correctly.
  • The pipeline should terminate cleanly.
  • The output file should have a non-zero size.
  • No plugin negotiation errors should appear.

Verify the generated file:

ls -lh synthetic_h265.mkv
file synthetic_h265.mkv

H264 Playback

This example validates hardware accelerated decoding using the file generated during the H.264 recording step.

For graphical playback:

gst-launch-1.0 -e -v filesrc location=synthetic_h264.mkv \
  ! matroskademux ! h264parse ! nvv4l2decoder \
  ! queue ! nvegltransform ! nveglglessink sync=0

What to expect:

  • The file should demux correctly.
  • The decoder should initialize successfully.
  • Graphical playback should appear smoothly on local systems.
  • Headless systems should terminate cleanly without decode errors.

If playback fails, first verify that the recording file was generated correctly.

Split Preview and Recording

This example exercises two simultaneous branches using the same synthetic source.

One branch renders the live preview while the second branch records the stream to disk.

gst-launch-1.0 -e -v videotestsrc is-live=true num-buffers=300 pattern=smpte \
  ! video/x-raw,width=1920,height=1080,framerate=30/1,format=I420 \
  ! nvvidconv ! 'video/x-raw(memory:NVMM),format=NV12' \
  ! tee name=t \
  t. ! queue ! nvegltransform ! nveglglessink sync=0 \
  t. ! queue ! nvv4l2h264enc maxperf-enable=1 bitrate=8000000 iframeinterval=30 insert-sps-pps=true \
     ! h264parse config-interval=-1 ! matroskamux ! filesink location=synthetic_dual.mkv sync=false async=false

What to expect:

  • Both branches should run simultaneously.
  • The preview branch should remain stable.
  • The recording branch should generate:
synthetic_dual.mkv
  • The pipeline should terminate without:
Internal data stream error

Additional Notes

  • videotestsrc allows the complete codec path to be exercised without requiring camera hardware.
  • matroskamux is used because it is generally more tolerant during validation than MP4 containers.
  • If generated files are unexpectedly small, verify that:
  • num-buffers was specified correctly
  • The encoder initialized successfully
  • The muxer was included in the pipeline
  • Playback issues are often caused by invalid recording files rather than decoder failures.

Additional Resources



Cookies help us deliver our services. By using our services, you agree to our use of cookies.