diff mbox series

[FFmpeg-devel,v2,1/1] avformat/demux: Fix accurate probing of durations in mpegts/ps

Message ID 20240318222358.2150026-2-nicolas.gaullier@cji.paris
State New
Headers show
Series avformat/demux: Fix accurate probing of durations in mpegts/ps | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Nicolas Gaullier March 18, 2024, 10:23 p.m. UTC
Two issues affect accuracy of duration in estimate_timings_from_pts():
- pkt->duration typically reports the duration of a single audio frame,
whereas a pes often contain several audio frames
- for video, compute_frame_duration() use r_frame_rate which is not
reliable; typically, it is the duration of a single field for an
interlaced video using two field pictures.

Packet splitting/parsing is required to get accurate durations, so this
patch replaces ff_read_packet() calls by av_read_frame() calls.

Note that concatdec makes use of avformat_find_stream_info() to stitch
correctly the files, so it benefits from this patch (typically, overlap
is avoided).
e.g. in fate/concat-demuxer-simple2-lavf-ts: the input audio stream
duration is now longer than that of the video, which results in
concatdec joining on audio after the patch instead of joining on video
before that.

Signed-off-by: Nicolas Gaullier <nicolas.gaullier@cji.paris>
---
 libavformat/demux.c                           |  36 ++--
 tests/ref/fate/concat-demuxer-simple2-lavf-ts | 170 +++++++++---------
 tests/ref/fate/ts-opus-demux                  |   4 +-
 3 files changed, 100 insertions(+), 110 deletions(-)
diff mbox series

Patch

diff --git a/libavformat/demux.c b/libavformat/demux.c
index 4c50eb5568..5b89eb71c9 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1820,20 +1820,17 @@  static void estimate_timings_from_bit_rate(AVFormatContext *ic)
 #define DURATION_MAX_READ_SIZE 250000LL
 #define DURATION_MAX_RETRY 6
 
-/* only usable for MPEG-PS streams */
+/* only usable for MPEG-PS/TS streams */
 static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
 {
     FFFormatContext *const si = ffformatcontext(ic);
     AVPacket *const pkt = si->pkt;
-    int num, den, read_size, ret;
+    int read_size, ret;
     int found_duration = 0;
     int is_end;
     int64_t filesize, offset, duration;
     int retry = 0;
 
-    /* flush packet queue */
-    ff_flush_packet_queue(ic);
-
     for (unsigned i = 0; i < ic->nb_streams; i++) {
         AVStream *const st  = ic->streams[i];
         FFStream *const sti = ffstream(st);
@@ -1844,10 +1841,13 @@  static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
             av_log(ic, AV_LOG_WARNING,
                    "start time for stream %d is not set in estimate_timings_from_pts\n", i);
 
-        if (sti->parser) {
-            av_parser_close(sti->parser);
-            sti->parser = NULL;
-        }
+        /* Demuxer context updates may occur, particularly while seeking in mpegts,
+         * and this could loose codec parameters in avctx,
+         * so preserve them in codecpar.
+         */
+        if (sti->avctx_inited &&
+            avcodec_parameters_from_context(st->codecpar, sti->avctx))
+            goto skip_duration_calc;
     }
 
     if (ic->skip_estimate_duration_from_pts) {
@@ -1865,6 +1865,7 @@  static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
         if (offset < 0)
             offset = 0;
 
+        ff_read_frame_flush(ic);
         avio_seek(ic->pb, offset, SEEK_SET);
         read_size = 0;
         for (;;) {
@@ -1874,7 +1875,7 @@  static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
                 break;
 
             do {
-                ret = ff_read_packet(ic, pkt);
+                ret = av_read_frame(ic, pkt);
             } while (ret == AVERROR(EAGAIN));
             if (ret != 0)
                 break;
@@ -1884,15 +1885,6 @@  static void estimate_timings_from_pts(AVFormatContext *ic, int64_t old_offset)
             if (pkt->pts != AV_NOPTS_VALUE &&
                 (st->start_time != AV_NOPTS_VALUE ||
                  sti->first_dts != AV_NOPTS_VALUE)) {
-                if (pkt->duration == 0) {
-                    compute_frame_duration(ic, &num, &den, st, sti->parser, pkt);
-                    if (den && num) {
-                        pkt->duration = av_rescale_rnd(1,
-                                           num * (int64_t) st->time_base.den,
-                                           den * (int64_t) st->time_base.num,
-                                           AV_ROUND_DOWN);
-                    }
-                }
                 duration = pkt->pts + pkt->duration;
                 found_duration = 1;
                 if (st->start_time != AV_NOPTS_VALUE)
@@ -1948,15 +1940,13 @@  skip_duration_calc:
     fill_all_stream_timings(ic);
 
     avio_seek(ic->pb, old_offset, SEEK_SET);
+
+    ff_read_frame_flush(ic);
     for (unsigned i = 0; i < ic->nb_streams; i++) {
         AVStream *const st  = ic->streams[i];
         FFStream *const sti = ffstream(st);
 
         sti->cur_dts     = sti->first_dts;
-        sti->last_IP_pts = AV_NOPTS_VALUE;
-        sti->last_dts_for_order_check = AV_NOPTS_VALUE;
-        for (int j = 0; j < MAX_REORDER_DELAY + 1; j++)
-            sti->pts_buffer[j] = AV_NOPTS_VALUE;
     }
 }
 
diff --git a/tests/ref/fate/concat-demuxer-simple2-lavf-ts b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
index 548cab01c6..86e5e6670f 100644
--- a/tests/ref/fate/concat-demuxer-simple2-lavf-ts
+++ b/tests/ref/fate/concat-demuxer-simple2-lavf-ts
@@ -62,90 +62,90 @@  audio|0|86988|0.966533|86988|0.966533|2351|0.026122|209|N/A|K__
 audio|0|89339|0.992656|89339|0.992656|2351|0.026122|209|N/A|K__
 video|1|83782|0.930911|80182|0.890911|3600|0.040000|12678|347800|___|MPEGTS Stream ID|224
 video|1|87382|0.970911|83782|0.930911|3600|0.040000|24711|361336|K__
-video|1|91964|1.021822|88364|0.981822|3600|0.040000|24801|564|K__|MPEGTS Stream ID|224
-video|1|95564|1.061822|91964|1.021822|3600|0.040000|16429|25944|___|MPEGTS Stream ID|224
-video|1|99164|1.101822|95564|1.061822|3600|0.040000|14508|42864|___|MPEGTS Stream ID|224
-video|1|102764|1.141822|99164|1.101822|3600|0.040000|12622|58092|___|MPEGTS Stream ID|224
-video|1|106364|1.181822|102764|1.141822|3600|0.040000|13393|71064|___|MPEGTS Stream ID|224
-video|1|109964|1.221822|106364|1.181822|3600|0.040000|13092|84788|___|MPEGTS Stream ID|224
-video|1|113564|1.261822|109964|1.221822|3600|0.040000|12755|98700|___|MPEGTS Stream ID|224
-video|1|117164|1.301822|113564|1.261822|3600|0.040000|12023|111860|___|MPEGTS Stream ID|224
-audio|0|90982|1.010911|90982|1.010911|2351|0.026122|208|152844|K__|MPEGTS Stream ID|192
-audio|0|93333|1.037033|93333|1.037033|2351|0.026122|209|N/A|K__
-audio|0|95684|1.063156|95684|1.063156|2351|0.026122|209|N/A|K__
-audio|0|98035|1.089278|98035|1.089278|2351|0.026122|209|N/A|K__
-audio|0|100386|1.115400|100386|1.115400|2351|0.026122|209|N/A|K__
-audio|0|102737|1.141522|102737|1.141522|2351|0.026122|209|N/A|K__
-audio|0|105088|1.167644|105088|1.167644|2351|0.026122|209|N/A|K__
-audio|0|107439|1.193767|107439|1.193767|2351|0.026122|209|N/A|K__
-audio|0|109790|1.219889|109790|1.219889|2351|0.026122|209|N/A|K__
-audio|0|112141|1.246011|112141|1.246011|2351|0.026122|209|N/A|K__
-audio|0|114492|1.272133|114492|1.272133|2351|0.026122|209|N/A|K__
-audio|0|116843|1.298256|116843|1.298256|2351|0.026122|209|N/A|K__
-audio|0|119194|1.324378|119194|1.324378|2351|0.026122|209|N/A|K__
-audio|0|121545|1.350500|121545|1.350500|2351|0.026122|209|N/A|K__
-video|1|120764|1.341822|117164|1.301822|3600|0.040000|14098|124268|___|MPEGTS Stream ID|224
-video|1|124364|1.381822|120764|1.341822|3600|0.040000|13329|139120|___|MPEGTS Stream ID|224
-video|1|127964|1.421822|124364|1.381822|3600|0.040000|12135|155852|___|MPEGTS Stream ID|224
-video|1|131564|1.461822|127964|1.421822|3600|0.040000|12282|168448|___|MPEGTS Stream ID|224
-video|1|135164|1.501822|131564|1.461822|3600|0.040000|24786|181420|K__|MPEGTS Stream ID|224
-video|1|138764|1.541822|135164|1.501822|3600|0.040000|17440|206988|___|MPEGTS Stream ID|224
-video|1|142364|1.581822|138764|1.541822|3600|0.040000|15019|224848|___|MPEGTS Stream ID|224
-video|1|145964|1.621822|142364|1.581822|3600|0.040000|13449|240640|___|MPEGTS Stream ID|224
-video|1|149564|1.661822|145964|1.621822|3600|0.040000|12398|254552|___|MPEGTS Stream ID|224
-video|1|153164|1.701822|149564|1.661822|3600|0.040000|13455|267336|___|MPEGTS Stream ID|224
-audio|0|123897|1.376633|123897|1.376633|2351|0.026122|209|308508|K__|MPEGTS Stream ID|192
-audio|0|126248|1.402756|126248|1.402756|2351|0.026122|209|N/A|K__
-audio|0|128599|1.428878|128599|1.428878|2351|0.026122|209|N/A|K__
-audio|0|130950|1.455000|130950|1.455000|2351|0.026122|209|N/A|K__
-audio|0|133301|1.481122|133301|1.481122|2351|0.026122|209|N/A|K__
-audio|0|135652|1.507244|135652|1.507244|2351|0.026122|209|N/A|K__
-audio|0|138003|1.533367|138003|1.533367|2351|0.026122|209|N/A|K__
-audio|0|140354|1.559489|140354|1.559489|2351|0.026122|209|N/A|K__
-audio|0|142705|1.585611|142705|1.585611|2351|0.026122|209|N/A|K__
-audio|0|145056|1.611733|145056|1.611733|2351|0.026122|209|N/A|K__
-audio|0|147407|1.637856|147407|1.637856|2351|0.026122|209|N/A|K__
-audio|0|149758|1.663978|149758|1.663978|2351|0.026122|209|N/A|K__
-audio|0|152109|1.690100|152109|1.690100|2351|0.026122|209|N/A|K__
-audio|0|154460|1.716222|154460|1.716222|2351|0.026122|209|N/A|K__
-video|1|156764|1.741822|153164|1.701822|3600|0.040000|13836|281624|___|MPEGTS Stream ID|224
-video|1|160364|1.781822|156764|1.741822|3600|0.040000|12163|295912|___|MPEGTS Stream ID|224
-video|1|163964|1.821822|160364|1.781822|3600|0.040000|12692|311516|___|MPEGTS Stream ID|224
-video|1|167564|1.861822|163964|1.821822|3600|0.040000|10824|325052|___|MPEGTS Stream ID|224
-video|1|171164|1.901822|167564|1.861822|3600|0.040000|11286|336144|___|MPEGTS Stream ID|224
-audio|0|156811|1.742344|156811|1.742344|2351|0.026122|209|386716|K__|MPEGTS Stream ID|192
-audio|0|159162|1.768467|159162|1.768467|2351|0.026122|209|N/A|K__
-audio|0|161513|1.794589|161513|1.794589|2351|0.026122|209|N/A|K__
-audio|0|163864|1.820711|163864|1.820711|2351|0.026122|209|N/A|K__
-audio|0|166215|1.846833|166215|1.846833|2351|0.026122|209|N/A|K__
-audio|0|168566|1.872956|168566|1.872956|2351|0.026122|209|N/A|K__
-audio|0|170917|1.899078|170917|1.899078|2351|0.026122|209|N/A|K__
-audio|0|173268|1.925200|173268|1.925200|2351|0.026122|209|N/A|K__
-audio|0|175619|1.951322|175619|1.951322|2351|0.026122|209|N/A|K__
-audio|0|177970|1.977444|177970|1.977444|2351|0.026122|209|N/A|K__
-audio|0|180321|2.003567|180321|2.003567|2351|0.026122|209|N/A|K__
-video|1|174764|1.941822|171164|1.901822|3600|0.040000|12678|347800|___|MPEGTS Stream ID|224
-video|1|178364|1.981822|174764|1.941822|3600|0.040000|24711|361336|K__
-video|1|139582|1.550911|135982|1.510911|3600|0.040000|12692|311516|___|MPEGTS Stream ID|224
-video|1|143182|1.590911|139582|1.550911|3600|0.040000|10824|325052|___|MPEGTS Stream ID|224
-video|1|146782|1.630911|143182|1.590911|3600|0.040000|11286|336144|___|MPEGTS Stream ID|224
-audio|0|132429|1.471433|132429|1.471433|2351|0.026122|209|386716|K__|MPEGTS Stream ID|192
-audio|0|134780|1.497556|134780|1.497556|2351|0.026122|209|N/A|K__
-audio|0|137131|1.523678|137131|1.523678|2351|0.026122|209|N/A|K__
-audio|0|139482|1.549800|139482|1.549800|2351|0.026122|209|N/A|K__
-audio|0|141833|1.575922|141833|1.575922|2351|0.026122|209|N/A|K__
-audio|0|144184|1.602044|144184|1.602044|2351|0.026122|209|N/A|K__
-audio|0|146535|1.628167|146535|1.628167|2351|0.026122|209|N/A|K__
-audio|0|148886|1.654289|148886|1.654289|2351|0.026122|209|N/A|K__
-audio|0|151237|1.680411|151237|1.680411|2351|0.026122|209|N/A|K__
-audio|0|153588|1.706533|153588|1.706533|2351|0.026122|209|N/A|K__
-audio|0|155939|1.732656|155939|1.732656|2351|0.026122|209|N/A|K__
-video|1|150382|1.670911|146782|1.630911|3600|0.040000|12678|347800|___|MPEGTS Stream ID|224
-video|1|153982|1.710911|150382|1.670911|3600|0.040000|24711|361336|K__
-video|1|161182|1.790911|157582|1.750911|3600|0.040000|12135|155852|___|MPEGTS Stream ID|224
-video|1|164782|1.830911|161182|1.790911|3600|0.040000|12282|168448|___|MPEGTS Stream ID|224
-video|1|168382|1.870911|164782|1.830911|3600|0.040000|24786|181420|K__|MPEGTS Stream ID|224
-video|1|171982|1.910911|168382|1.870911|3600|0.040000|17440|206988|___|MPEGTS Stream ID|224
-video|1|175582|1.950911|171982|1.910911|3600|0.040000|15019|224848|___|MPEGTS Stream ID|224
+video|1|92672|1.029689|89072|0.989689|3600|0.040000|24801|564|K__|MPEGTS Stream ID|224
+video|1|96272|1.069689|92672|1.029689|3600|0.040000|16429|25944|___|MPEGTS Stream ID|224
+video|1|99872|1.109689|96272|1.069689|3600|0.040000|14508|42864|___|MPEGTS Stream ID|224
+video|1|103472|1.149689|99872|1.109689|3600|0.040000|12622|58092|___|MPEGTS Stream ID|224
+video|1|107072|1.189689|103472|1.149689|3600|0.040000|13393|71064|___|MPEGTS Stream ID|224
+video|1|110672|1.229689|107072|1.189689|3600|0.040000|13092|84788|___|MPEGTS Stream ID|224
+video|1|114272|1.269689|110672|1.229689|3600|0.040000|12755|98700|___|MPEGTS Stream ID|224
+video|1|117872|1.309689|114272|1.269689|3600|0.040000|12023|111860|___|MPEGTS Stream ID|224
+audio|0|91690|1.018778|91690|1.018778|2351|0.026122|208|152844|K__|MPEGTS Stream ID|192
+audio|0|94041|1.044900|94041|1.044900|2351|0.026122|209|N/A|K__
+audio|0|96392|1.071022|96392|1.071022|2351|0.026122|209|N/A|K__
+audio|0|98743|1.097144|98743|1.097144|2351|0.026122|209|N/A|K__
+audio|0|101094|1.123267|101094|1.123267|2351|0.026122|209|N/A|K__
+audio|0|103445|1.149389|103445|1.149389|2351|0.026122|209|N/A|K__
+audio|0|105796|1.175511|105796|1.175511|2351|0.026122|209|N/A|K__
+audio|0|108147|1.201633|108147|1.201633|2351|0.026122|209|N/A|K__
+audio|0|110498|1.227756|110498|1.227756|2351|0.026122|209|N/A|K__
+audio|0|112849|1.253878|112849|1.253878|2351|0.026122|209|N/A|K__
+audio|0|115200|1.280000|115200|1.280000|2351|0.026122|209|N/A|K__
+audio|0|117551|1.306122|117551|1.306122|2351|0.026122|209|N/A|K__
+audio|0|119902|1.332244|119902|1.332244|2351|0.026122|209|N/A|K__
+audio|0|122253|1.358367|122253|1.358367|2351|0.026122|209|N/A|K__
+video|1|121472|1.349689|117872|1.309689|3600|0.040000|14098|124268|___|MPEGTS Stream ID|224
+video|1|125072|1.389689|121472|1.349689|3600|0.040000|13329|139120|___|MPEGTS Stream ID|224
+video|1|128672|1.429689|125072|1.389689|3600|0.040000|12135|155852|___|MPEGTS Stream ID|224
+video|1|132272|1.469689|128672|1.429689|3600|0.040000|12282|168448|___|MPEGTS Stream ID|224
+video|1|135872|1.509689|132272|1.469689|3600|0.040000|24786|181420|K__|MPEGTS Stream ID|224
+video|1|139472|1.549689|135872|1.509689|3600|0.040000|17440|206988|___|MPEGTS Stream ID|224
+video|1|143072|1.589689|139472|1.549689|3600|0.040000|15019|224848|___|MPEGTS Stream ID|224
+video|1|146672|1.629689|143072|1.589689|3600|0.040000|13449|240640|___|MPEGTS Stream ID|224
+video|1|150272|1.669689|146672|1.629689|3600|0.040000|12398|254552|___|MPEGTS Stream ID|224
+video|1|153872|1.709689|150272|1.669689|3600|0.040000|13455|267336|___|MPEGTS Stream ID|224
+audio|0|124605|1.384500|124605|1.384500|2351|0.026122|209|308508|K__|MPEGTS Stream ID|192
+audio|0|126956|1.410622|126956|1.410622|2351|0.026122|209|N/A|K__
+audio|0|129307|1.436744|129307|1.436744|2351|0.026122|209|N/A|K__
+audio|0|131658|1.462867|131658|1.462867|2351|0.026122|209|N/A|K__
+audio|0|134009|1.488989|134009|1.488989|2351|0.026122|209|N/A|K__
+audio|0|136360|1.515111|136360|1.515111|2351|0.026122|209|N/A|K__
+audio|0|138711|1.541233|138711|1.541233|2351|0.026122|209|N/A|K__
+audio|0|141062|1.567356|141062|1.567356|2351|0.026122|209|N/A|K__
+audio|0|143413|1.593478|143413|1.593478|2351|0.026122|209|N/A|K__
+audio|0|145764|1.619600|145764|1.619600|2351|0.026122|209|N/A|K__
+audio|0|148115|1.645722|148115|1.645722|2351|0.026122|209|N/A|K__
+audio|0|150466|1.671844|150466|1.671844|2351|0.026122|209|N/A|K__
+audio|0|152817|1.697967|152817|1.697967|2351|0.026122|209|N/A|K__
+audio|0|155168|1.724089|155168|1.724089|2351|0.026122|209|N/A|K__
+video|1|157472|1.749689|153872|1.709689|3600|0.040000|13836|281624|___|MPEGTS Stream ID|224
+video|1|161072|1.789689|157472|1.749689|3600|0.040000|12163|295912|___|MPEGTS Stream ID|224
+video|1|164672|1.829689|161072|1.789689|3600|0.040000|12692|311516|___|MPEGTS Stream ID|224
+video|1|168272|1.869689|164672|1.829689|3600|0.040000|10824|325052|___|MPEGTS Stream ID|224
+video|1|171872|1.909689|168272|1.869689|3600|0.040000|11286|336144|___|MPEGTS Stream ID|224
+audio|0|157519|1.750211|157519|1.750211|2351|0.026122|209|386716|K__|MPEGTS Stream ID|192
+audio|0|159870|1.776333|159870|1.776333|2351|0.026122|209|N/A|K__
+audio|0|162221|1.802456|162221|1.802456|2351|0.026122|209|N/A|K__
+audio|0|164572|1.828578|164572|1.828578|2351|0.026122|209|N/A|K__
+audio|0|166923|1.854700|166923|1.854700|2351|0.026122|209|N/A|K__
+audio|0|169274|1.880822|169274|1.880822|2351|0.026122|209|N/A|K__
+audio|0|171625|1.906944|171625|1.906944|2351|0.026122|209|N/A|K__
+audio|0|173976|1.933067|173976|1.933067|2351|0.026122|209|N/A|K__
+audio|0|176327|1.959189|176327|1.959189|2351|0.026122|209|N/A|K__
+audio|0|178678|1.985311|178678|1.985311|2351|0.026122|209|N/A|K__
+audio|0|181029|2.011433|181029|2.011433|2351|0.026122|209|N/A|K__
+video|1|175472|1.949689|171872|1.909689|3600|0.040000|12678|347800|___|MPEGTS Stream ID|224
+video|1|179072|1.989689|175472|1.949689|3600|0.040000|24711|361336|K__
+video|1|140290|1.558778|136690|1.518778|3600|0.040000|12692|311516|___|MPEGTS Stream ID|224
+video|1|143890|1.598778|140290|1.558778|3600|0.040000|10824|325052|___|MPEGTS Stream ID|224
+video|1|147490|1.638778|143890|1.598778|3600|0.040000|11286|336144|___|MPEGTS Stream ID|224
+audio|0|133137|1.479300|133137|1.479300|2351|0.026122|209|386716|K__|MPEGTS Stream ID|192
+audio|0|135488|1.505422|135488|1.505422|2351|0.026122|209|N/A|K__
+audio|0|137839|1.531544|137839|1.531544|2351|0.026122|209|N/A|K__
+audio|0|140190|1.557667|140190|1.557667|2351|0.026122|209|N/A|K__
+audio|0|142541|1.583789|142541|1.583789|2351|0.026122|209|N/A|K__
+audio|0|144892|1.609911|144892|1.609911|2351|0.026122|209|N/A|K__
+audio|0|147243|1.636033|147243|1.636033|2351|0.026122|209|N/A|K__
+audio|0|149594|1.662156|149594|1.662156|2351|0.026122|209|N/A|K__
+audio|0|151945|1.688278|151945|1.688278|2351|0.026122|209|N/A|K__
+audio|0|154296|1.714400|154296|1.714400|2351|0.026122|209|N/A|K__
+audio|0|156647|1.740522|156647|1.740522|2351|0.026122|209|N/A|K__
+video|1|151090|1.678778|147490|1.638778|3600|0.040000|12678|347800|___|MPEGTS Stream ID|224
+video|1|154690|1.718778|151090|1.678778|3600|0.040000|24711|361336|K__
+video|1|162598|1.806644|158998|1.766644|3600|0.040000|12135|155852|___|MPEGTS Stream ID|224
+video|1|166198|1.846644|162598|1.806644|3600|0.040000|12282|168448|___|MPEGTS Stream ID|224
+video|1|169798|1.886644|166198|1.846644|3600|0.040000|24786|181420|K__|MPEGTS Stream ID|224
+video|1|173398|1.926644|169798|1.886644|3600|0.040000|17440|206988|___|MPEGTS Stream ID|224
+video|1|176998|1.966644|173398|1.926644|3600|0.040000|15019|224848|___|MPEGTS Stream ID|224
 0|mp2|unknown|audio|[3][0][0][0]|0x0003|s16p|44100|1|mono|0|0|N/A|0/0|0/0|1/90000|0|0.000000|N/A|N/A|64000|N/A|N/A|N/A|N/A|89|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 0
 1|mpeg2video|4|video|[2][0][0][0]|0x0002|352|288|0|0|0|0|1|1:1|11:9|yuv420p|8|tv|unknown|unknown|unknown|left|progressive|1|N/A|25/1|25/1|1/90000|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|N/A|60|22|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|0|this is stream 1|CPB properties|0|0|0|49152|-1
diff --git a/tests/ref/fate/ts-opus-demux b/tests/ref/fate/ts-opus-demux
index 961b7f2a92..62d1856ae0 100644
--- a/tests/ref/fate/ts-opus-demux
+++ b/tests/ref/fate/ts-opus-demux
@@ -510,5 +510,5 @@  packet|codec_type=audio|stream_index=0|pts=914400|pts_time=10.160000|dts=914400|
 packet|codec_type=audio|stream_index=0|pts=916200|pts_time=10.180000|dts=916200|dts_time=10.180000|duration=1800|duration_time=0.020000|size=760|pos=508728|flags=K__|data_hash=CRC32:fdf0ce4a|side_datum/mpegts_stream_id:side_data_type=MPEGTS Stream ID|side_datum/mpegts_stream_id:id=189
 packet|codec_type=audio|stream_index=0|pts=918000|pts_time=10.200000|dts=918000|dts_time=10.200000|duration=1800|duration_time=0.020000|size=761|pos=510044|flags=K__|data_hash=CRC32:75113c11|side_datum/mpegts_stream_id:side_data_type=MPEGTS Stream ID|side_datum/mpegts_stream_id:id=189
 packet|codec_type=audio|stream_index=0|pts=919800|pts_time=10.220000|dts=919800|dts_time=10.220000|duration=1800|duration_time=0.020000|size=759|pos=510984|flags=K__|data_hash=CRC32:59fc266f|side_datum/mpegts_stream_id:side_data_type=MPEGTS Stream ID|side_datum/mpegts_stream_id:id=189
-stream|index=0|codec_name=opus|profile=unknown|codec_type=audio|codec_tag_string=Opus|codec_tag=0x7375704f|sample_fmt=fltp|sample_rate=48000|channels=8|channel_layout=7.1|bits_per_sample=0|initial_padding=0|ts_id=51338|ts_packetsize=188|id=0x44|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=0|start_time=0.000000|duration_ts=919800|duration=10.220000|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=512|extradata_size=29|extradata_hash=CRC32:6d6089a7|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
-format|filename=test-8-7.1.opus-small.ts|nb_streams=1|nb_programs=1|nb_stream_groups=0|format_name=mpegts|start_time=0.000000|duration=10.220000|size=512000|bit_rate=400782|probe_score=50
+stream|index=0|codec_name=opus|profile=unknown|codec_type=audio|codec_tag_string=Opus|codec_tag=0x7375704f|sample_fmt=fltp|sample_rate=48000|channels=8|channel_layout=7.1|bits_per_sample=0|initial_padding=0|ts_id=51338|ts_packetsize=188|id=0x44|r_frame_rate=0/0|avg_frame_rate=0/0|time_base=1/90000|start_pts=0|start_time=0.000000|duration_ts=921600|duration=10.240000|bit_rate=N/A|max_bit_rate=N/A|bits_per_raw_sample=N/A|nb_frames=N/A|nb_read_frames=N/A|nb_read_packets=512|extradata_size=29|extradata_hash=CRC32:6d6089a7|disposition:default=0|disposition:dub=0|disposition:original=0|disposition:comment=0|disposition:lyrics=0|disposition:karaoke=0|disposition:forced=0|disposition:hearing_impaired=0|disposition:visual_impaired=0|disposition:clean_effects=0|disposition:attached_pic=0|disposition:timed_thumbnails=0|disposition:non_diegetic=0|disposition:captions=0|disposition:descriptions=0|disposition:metadata=0|disposition:dependent=0|disposition:still_image=0
+format|filename=test-8-7.1.opus-small.ts|nb_streams=1|nb_programs=1|nb_stream_groups=0|format_name=mpegts|start_time=0.000000|duration=10.240000|size=512000|bit_rate=400000|probe_score=50