How to use gstreamer to re-mux a single title out of a DVD without re-encoding

Jan Schmidt jan at widgetgrove.com.au
Sun Mar 19 09:56:29 UTC 2023


Hi,

On 16/3/23 03:05, Michael Jones via gstreamer-devel wrote:

> On Sun, Mar 12, 2023 at 2:52 PM Michael Jones<jonesmz at jonesmz.com>  wrote:
>> Question also posted on stackoverflow:
>> https://stackoverflow.com/questions/75714501/use-gstreamer-to-remux-a-single-title-out-of-a-dvd-without-re-encoding
>>
>> I am trying to re-mux the video of a specific title out of a DVD into
>> a video file, without decoding then re-encoding the video.
>>
>> [snip]
>>
>> So what am I missing from my pipeline that prevents the buffers read
>> from the DVD from having a valid timestamp when they get to the
>> matroskamux ?

This is a guess, but one difference between MPEG-TS and matroska is that 
MPEG-TS only requires that you place a PTS/DTS on buffers at least every 
700ms, so timestamps may be sparse. It’s then up to the decoder to 
reconstruct the full timestamp sequence as it processes and outputs 
frames, interpolating missing ones. Matroska needs continuous 
timestamps, hence the complaint when they are missing.

In GStreamer 1.22 there is a new element |h264timestamper| that can 
interpolate missing DTS from the PTS information - useful for the case 
where you only have PTS. It could possibly be enhanced to also fill in 
missing PTS.

  * Jan

>> My best guess is that I need to insert something between
>> mpegvideoparse and the matroskmamux, but I don't know what it would
>> be.
> This appears to be a bug in the matroskamux.
>
> This pipeline
>
> GST_DEBUG=2                                 \
> gst-launch-1.0 -v -e                        \
> dvdreadsrc title=${TITLE} device=${DVD} \
> ! mpegpsdemux name=demux            \
> \
> tee name=vtee                           \
> tee name=atee                           \
> demux. ! mpegvideoparse ! vtee.     \
> demux. ! ac3parse    ! atee.     \
> \
> multiqueue name=convqueue               \
> vtee. ! convqueue.                  \
> atee. ! convqueue.                  \
> \
> mpegtsmux name=mux                  \
> convqueue. ! mux.                   \
> convqueue. ! mux.                   \
> \
> mux. ! filesink location=~/test.mkv
>
>
>
> produces a video file with smooth audio and video playback
>
>
> This pipeline
>
> GST_DEBUG=2                                \
> gst-launch-1.0 -v -e                       \
> dvdreadsrc title=${TITLE} device=${DVD} \
> ! mpegpsdemux                       \
> ! mpegvideoparse                    \
> ! mpegtsmux                         \
> ! tsdemux                           \
> ! mpegvideoparse                    \
> ! matroskamux                       \
> ! filesink location=~/test.mkv
>
> Produces a video file (sans audio, of course) that has jittery but not
> "slide show" video.
> Notably, the first pipeline has no warnings but the second has warnings like
> matroskamux matroska-mux.c:4035:gst_matroska_mux_write_data:<matroskamux0:video_0>
> Invalid buffer timestamp; dropping buffer
>
> Though only about a 100th of the number of them that i get when
> converting directly to matroskamux.
>
>
> What's wrong with the matroskamux that it can't handle video that the
> mpegtsmux can?
>
>
> Trying mpegpsmux instead of mpegtsmux in the first pipeline gives me
> smooth playback, but no audio, and thousands of these warnings
> mpegpsmux mpegpsmux.c:421:mpegpsmux_queue_buffer_for_stream:<mux:pad0>
> got DTS without PTS
>
> So there appears to be a problem with the timestamps of my video file,
> as i originally thought, but instead of matroskamux or mpegpsmux
> gracefully handling this problem, they spews warnings that don't tell
> me what to do about it.
>
> This lack of graceful handling or helpful diagnostics would be a bug
> in matroskamux and mpegpsmux.

​
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20230319/1e46a31b/attachment.htm>


More information about the gstreamer-devel mailing list