diff --git a/gst/mpegtsmux/gstbasetsmux.c b/gst/mpegtsmux/gstbasetsmux.c index f96959f99d..e85ac27bd3 100644 --- a/gst/mpegtsmux/gstbasetsmux.c +++ b/gst/mpegtsmux/gstbasetsmux.c @@ -685,13 +685,6 @@ gst_base_ts_mux_create_streams (GstBaseTsMux * mux) tsmux_set_pmt_interval (ts_pad->prog, mux->pmt_interval); g_hash_table_insert (mux->programs, GINT_TO_POINTER (ts_pad->prog_id), ts_pad->prog); - - /* Take the first stream of the program for the PCR */ - GST_DEBUG_OBJECT (ts_pad, - "Use stream (pid=%d) from pad as PCR for program (prog_id = %d)", - ts_pad->pid, ts_pad->prog_id); - - tsmux_program_set_pcr_stream (ts_pad->prog, ts_pad->stream); } if (ts_pad->stream == NULL) { @@ -700,6 +693,15 @@ gst_base_ts_mux_create_streams (GstBaseTsMux * mux) goto no_stream; } + if (ts_pad->prog->pcr_stream == NULL) { + /* Take the first stream of the program for the PCR */ + GST_DEBUG_OBJECT (ts_pad, + "Use stream (pid=%d) from pad as PCR for program (prog_id = %d)", + ts_pad->pid, ts_pad->prog_id); + + tsmux_program_set_pcr_stream (ts_pad->prog, ts_pad->stream); + } + /* Check for user-specified PCR PID */ pcr_name = g_strdup_printf ("PCR_%d", ts_pad->prog->pgm_number); if (mux->prog_map && gst_structure_has_field (mux->prog_map, pcr_name)) {