Adrian W
Adrian W

Reputation: 5036

Timing is lost when converting h264 video to non segmented mp4 using gstreamer

I would like to create a non segmented .mp4 video from a matroska source. I have seen this post and created a similar pipeline. My source contains only h264 video and no sound, so my pipeline looks like this:

gst-launch-1.0 filesrc location=x.mkv ! matroskademux ! h264parse ! mp4mux ! filesink location=x.mp4

However running gst-discoverer-1.0 on the result gives a duration of 0:00:00.000000000. Also vlc is not able to play the resulting .mp4 file and it cannot be used in a HTML5 <video> element (which is the final purpose of this conversion).

If I create a segmented .mp4 by adding fragment-duration=1000 to the mp4mux element, then vlc can play the .mp4, but this is not what I want. I need a .mp4 where the total length is known. What am I doing wrong?

Additional information: The length was present in the matroska source, as displayed by gst-discoverer-1.0, and vlc can display that source. I also can replay the non segmented .mp4 with gstreamer (using gst-launch-1.0 filesrc location=x.mp4 ! qtdemux ! h264parse ! avdec_h264 ! videoconvert ! autovideosink). Inspecting the generated .dot file reveals a framerate of 10000/1 coming out of qtdemux which seems quite strange.

Upvotes: 1

Views: 1340

Answers (1)

Adrian W
Adrian W

Reputation: 5036

The solution was to add disable-passthrough=true to the h264parse element, so the pipeline now looks like this:

gst-launch-1.0 filesrc location=x.mkv ! \
matroskademux ! \
h264parse disable-passthrough=true ! \
mp4mux ! \
filesink location=x.mp4

Now the resulting .mp4 file includes the timing information and can nicely be played with vlc as well as in a <video> tag including forward/backward navigation.

Upvotes: 2

Related Questions