On 11/21/2024 1:52 PM, Thierry Foucu wrote:
On Wed, Nov 20, 2024, 12:27 PM James Almer <jamr...@gmail.com> wrote:

From: Thierry Foucu <tfo...@gmail.com>

Fixes ticket #11312.

Signed-off-by: James Almer <jamr...@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@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@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?

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-requ...@ffmpeg.org with subject "unsubscribe".

Reply via email to