Gstreamer convert .h264 to .mp4

Hi all,
I would like to convert an encoded .h264 file to a .mp4.
I would like to use it on jetson nano with gstreamer, since faster than ffmpeg. After some trial and error, i found this pipeline that work as expected:

gst-launch-1.0 filesrc location=video.h264 ! h264parse ! 'video/x-h264' ! omxh264dec! videoconvert ! nvv4l2h264enc ! h264parse ! mp4mux ! filesink location=video.mp4 -e

I have 2 questions:

  1. Since the encoding is the same, is necessary to first decode and then re-encode the video? I haven’t found any working pipeline withouth this decoding-encoding.
  2. This pipeline work, but produces some error messages. What’s that, can I ignore them or there is something to change?

Setting pipeline to PAUSED …
Pipeline is PREROLLING …
(gst-launch-1.0:12731): GStreamer-e[1;35mCRITICALe[0m **: e[34m18:48:10.125e[0m: gst_caps_is_empty: assertion ‘GST_IS_CAPS (caps)’ failed
(gst-launch-1.0:12731): GStreamer-e[1;35mCRITICALe[0m **: e[34m18:48:10.125e[0m: gst_caps_truncate: assertion ‘GST_IS_CAPS (caps)’ failed
(gst-launch-1.0:12731): GStreamer-e[1;35mCRITICALe[0m **: e[34m18:48:10.125e[0m: gst_caps_fixate: assertion ‘GST_IS_CAPS (caps)’ failed
(gst-launch-1.0:12731): GStreamer-e[1;35mCRITICALe[0m **: e[34m18:48:10.125e[0m: gst_caps_get_structure: assertion ‘GST_IS_CAPS (caps)’ failed
(gst-launch-1.0:12731): GStreamer-e[1;35mCRITICALe[0m **: e[34m18:48:10.125e[0m: gst_structure_get_string: assertion ‘structure != NULL’ failed
(gst-launch-1.0:12731): GStreamer-e[1;35mCRITICALe[0m **: e[34m18:48:10.125e[0m: gst_mini_object_unref: assertion ‘mini_object != NULL’ failed
NvMMLiteOpen : Block : BlockType = 261
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 261
Allocating new output: 1920x1088 (x 23), ThumbnailMode = 0
OPENMAX: HandleNewStreamFormat: 3605: Send OMX_EventPortSettingsChanged: nFrameWidth = 1920, nFrameHeight = 1080
Redistribute latency…
NvMMLiteOpen : Block : BlockType = 4
===== NVMEDIA: NVENC =====
NvMMLiteBlockCreate : Block : BlockType = 4
H264: Profile = 66, Level = 0
Pipeline is PREROLLED …
Setting pipeline to PLAYING …
New clock: GstSystemClock
Got EOS from element “pipeline0”.
Execution ended after 0:00:29.952669771
Setting pipeline to PAUSED …
Setting pipeline to READY …
Setting pipeline to NULL …
Freeing pipeline …

If you only need to mux h264 stream into mp4 without re-encoding, it is better to run ffmpeg command like:

$ ./ffmpeg -i video.h264 -vcodec copy video.mp4

The gstreamer command you run will decode the h264 stream, re-encode to h264 stream, and then mux into mp4.

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