@@ -85,6 +85,7 @@ typedef struct MOVParseTableEntry {
85
85
static int mov_read_default (MOVContext * c , AVIOContext * pb , MOVAtom atom );
86
86
static int mov_read_mfra (MOVContext * c , AVIOContext * f );
87
87
static void mov_free_stream_context (AVFormatContext * s , AVStream * st );
88
+ static int mov_switch_root (AVFormatContext * s , int64_t target , int index );
88
89
static int64_t add_ctts_entry (MOVCtts * * ctts_data , unsigned int * ctts_count , unsigned int * allocated_size ,
89
90
int count , int duration );
90
91
@@ -1653,6 +1654,31 @@ static int64_t get_frag_time(AVFormatContext *s, AVStream *dst_st,
1653
1654
return frag_stream_info -> sidx_pts ;
1654
1655
}
1655
1656
1657
+
1658
+ // Check if the requested stream is present in the fragment
1659
+ int exists = 0 ;
1660
+ for (i = 0 ; i < frag_index -> item [index ].nb_stream_info ; i ++ ) {
1661
+ if (dst_st -> id != frag_index -> item [index ].stream_info [i ].id ) {
1662
+ continue ;
1663
+ }
1664
+
1665
+ if ( get_stream_info_time (& frag_index -> item [index ].stream_info [i ]) != AV_NOPTS_VALUE ) {
1666
+ exists = 1 ;
1667
+ break ;
1668
+ }
1669
+ if ( mov_switch_root (s ,-1 ,index ) < 0 )
1670
+ return AV_NOPTS_VALUE ;
1671
+
1672
+ if ( get_stream_info_time (& frag_index -> item [index ].stream_info [i ]) != AV_NOPTS_VALUE ) {
1673
+ exists = 1 ;
1674
+ break ;
1675
+ }
1676
+ }
1677
+
1678
+ if (!exists )
1679
+ return AV_NOPTS_VALUE ;
1680
+
1681
+
1656
1682
for (i = 0 ; i < frag_index -> item [index ].nb_stream_info ; i ++ ) {
1657
1683
AVStream * frag_stream = NULL ;
1658
1684
frag_stream_info = & frag_index -> item [index ].stream_info [i ];
0 commit comments