[FFmpeg-devel] [PATCH 2/3] avformat/mov: set packet duration in fragmented input
James Almer
jamrial at gmail.com
Thu Nov 21 18:54:14 EET 2024
On 11/21/2024 1:52 PM, Thierry Foucu wrote:
> On Wed, Nov 20, 2024, 12:27 PM James Almer <jamrial at gmail.com> wrote:
>
>> From: Thierry Foucu <tfoucu at gmail.com>
>>
>> Fixes ticket #11312.
>>
>> Signed-off-by: James Almer <jamrial at gmail.com>
>> ---
>> libavformat/isom.h | 1 +
>> libavformat/mov.c | 4 ++++
>> 2 files changed, 5 insertions(+)
>>
>> diff --git a/libavformat/isom.h b/libavformat/isom.h
>> index ff08f2a48d..9a086b05c2 100644
>> --- a/libavformat/isom.h
>> +++ b/libavformat/isom.h
>> @@ -62,6 +62,7 @@ typedef struct MOVStts {
>> typedef struct MOVCtts {
>> unsigned int count;
>> int offset;
>> + int duration; // used when handling fragments
>> } MOVCtts;
>>
>> typedef struct MOVStsc {
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 3e94a21418..c5c9fb10a6 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -4089,6 +4089,7 @@ static int64_t add_ctts_entry(MOVCtts** ctts_data,
>> unsigned int* ctts_count, uns
>>
>> ctts_buf_new[*ctts_count].count = count;
>> ctts_buf_new[*ctts_count].offset = offset;
>> + ctts_buf_new[*ctts_count].duration = 0;
>>
>> *ctts_count = (*ctts_count) + 1;
>> return *ctts_count;
>> @@ -5910,6 +5911,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext
>> *pb, MOVAtom atom)
>> sti->index_entries[index_entry_pos].flags = index_entry_flags;
>>
>> sc->ctts_data[index_entry_pos].count = 1;
>> + sc->ctts_data[index_entry_pos].duration = sample_duration;
>> sc->ctts_data[index_entry_pos].offset = ctts_duration;
>> index_entry_pos++;
>>
>> @@ -10722,6 +10724,8 @@ static int mov_finalize_packet(AVFormatContext *s,
>> AVStream *st, AVIndexEntry *s
>> }
>> if (sc->ctts_data && sc->ctts_index < sc->ctts_count) {
>> pkt->pts = av_sat_add64(pkt->dts, av_sat_add64(sc->dts_shift,
>> sc->ctts_data[sc->ctts_index].offset));
>> + if (sc->ctts_data[sc->ctts_index].duration)
>> + pkt->duration = sc->ctts_data[sc->ctts_index].duration;
>>
>> /* update ctts context */
>> sc->ctts_sample++;
>> --
>> 2.47.0
>>
>> _______________________________________________
>> ffmpeg-devel mailing list
>> ffmpeg-devel at ffmpeg.org
>> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>>
>> To unsubscribe, visit link above, or email
>> ffmpeg-devel-request at ffmpeg.org with subject "unsubscribe".
>>
>
>
>
>
> Thanks. This patch does fix the ticket #11312
I sent an alternative and better approach in a separate patch in this
same thread. Can you test it too?
-------------- next part --------------
A non-text attachment was scrubbed...
Name: OpenPGP_signature.asc
Type: application/pgp-signature
Size: 495 bytes
Desc: OpenPGP digital signature
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20241121/e61fe115/attachment.sig>
More information about the ffmpeg-devel
mailing list