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

Michael Jones jonesmz at jonesmz.com
Wed Mar 15 16:05:54 UTC 2023


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 ?
>
> 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.


More information about the gstreamer-devel mailing list