[FFmpeg-devel] [PATCH 07/10] avformat/mpegtsenc: count packets instead of using avio_tell
Marton Balint
cus at passwd.hu
Tue Nov 12 23:29:03 EET 2019
Next patch needs this.
Signed-off-by: Marton Balint <cus at passwd.hu>
---
libavformat/mpegtsenc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index be41311bf7..a4b28f7d74 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -112,6 +112,7 @@ typedef struct MpegTSWrite {
int64_t sdt_period_us;
int64_t last_pat_ts;
int64_t last_sdt_ts;
+ int64_t nb_packets;
int omit_video_pes_length;
} MpegTSWrite;
@@ -719,7 +720,7 @@ invalid:
static int64_t get_pcr(const MpegTSWrite *ts, AVIOContext *pb)
{
- return av_rescale(avio_tell(pb) + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
+ return av_rescale(ts->nb_packets * TS_PACKET_SIZE + 11, 8 * PCR_TIME_BASE, ts->mux_rate) +
ts->first_pcr;
}
@@ -734,6 +735,7 @@ static void write_packet(AVFormatContext *s, const uint8_t *packet)
sizeof(tp_extra_header));
}
avio_write(s->pb, packet, TS_PACKET_SIZE);
+ ts->nb_packets++;
}
static void section_write_packet(MpegTSSection *s, const uint8_t *packet)
--
2.16.4
More information about the ffmpeg-devel
mailing list