Search code examples
encodinggstreamermpeg-2pts

Writing PTS/DTS to MPEG Stream (Gstreamer)


So, for a GNURadio project, I am sending MPEG-2 video muxed with PSIP data to my TV. The actual passing of said data and video is fine, however, the video is not decoded properly. It is mostly blank with blinking blocks everywhere, with fast moving scenes having more "garbage". It kind of looks like this, except most of it is black and the "blocks" randomly appear and disappear. It's supposed to look like this.

I am using videtestsrc before I add it to my mixer for testing. I tried avconv, and for whatever reason, it does not have this issue.

Here is pipeline, also below:

VIDEOFORMATIN='video/x-raw, format=UYVY, width=1920, height=1080, framerate=60/1, interlaced='true''
gst-launch-1.0 -v videotestsrc do-timestamp=true is-live=true ! $VIDEOFORMATIN \
! videoconvert ! queue ! \
avenc_mpeg2video bitrate=15000000 rc-max-rate=17000000 rc-min-rate=14000000 rc-buffer-size=300000 \
rc-buffer-aggressivity=0.25 ! \
filesink location=video.mpeg

It renders fine in mpv, SMPlater, and TSReader can play the video, however an error that shows up in mpv's command output is"

"[libav] NULL: start time is not set in estimate_timings_from_pts"

and...

"No PTS found! Making something up"

Any idea what could be happening? How can I write the proper PTS/DTS values when it is a live source? Yes, I have to use MPEG-2 and gstreamer.


Solution

  • As you noticed you are missing PTS/DTS values which are essential timestamps for the decoder: it tells when to decode and present a frame. I don't think you can manually generate it as it is normally done during the muxing operation.

    It seems that mpv succeed in emulate them, this is why you have a clean render, but obviously you TV cannot.

    Have you tried to mux with ffmpeg ?