diff mbox series

[FFmpeg-devel] avformat/mov: Handle when we have an mfra box but have not read the full sidx for a fragment

Message ID 20210315170437.605788-1-derek.buitenhuis@gmail.com
State Accepted
Commit 8f1580c31a3cfb9994bda7b3914a97e09b9f1d48
Headers show
Series [FFmpeg-devel] avformat/mov: Handle when we have an mfra box but have not read the full sidx for a fragment | expand

Checks

Context Check Description
andriy/x86_make success Make finished
andriy/x86_make_fate success Make fate finished
andriy/PPC64_make success Make finished
andriy/PPC64_make_fate success Make fate finished

Commit Message

Derek Buitenhuis March 15, 2021, 5:04 p.m. UTC
Use the tfra timestamp if it is available and sidx timestamp is not.

Fixes reading the entire file after seeking in a live-style DASH FMP4
with an MFRA.

This specifically fixes when use_mfra_for is set.

Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
---
I could also put it behind an additional use_mfra_for option check if that is
what people want.
---
 libavformat/mov.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Derek Buitenhuis March 17, 2021, 1:12 p.m. UTC | #1
On 15/03/2021 17:04, Derek Buitenhuis wrote:
> Use the tfra timestamp if it is available and sidx timestamp is not.
> 
> Fixes reading the entire file after seeking in a live-style DASH FMP4
> with an MFRA.
> 
> This specifically fixes when use_mfra_for is set.
> 
> Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
> ---

Will push later today if there are no objections.

- Derek
diff mbox series

Patch

diff --git a/libavformat/mov.c b/libavformat/mov.c
index 23b0ead01e..97857789f4 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1279,6 +1279,10 @@  static int64_t get_frag_time(MOVFragmentIndex *frag_index,
 
     if (track_id >= 0) {
         frag_stream_info = get_frag_stream_info(frag_index, index, track_id);
+        if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE)
+            return frag_stream_info->sidx_pts;
+        if (frag_stream_info->first_tfra_pts != AV_NOPTS_VALUE)
+            return frag_stream_info->first_tfra_pts;
         return frag_stream_info->sidx_pts;
     }