[FFmpeg-devel] [PATCH 1/2] Modified to generate PAT/PMT on every video keyframe. This is so that TS fragments produced by http://code.google.com/p/httpsegmenter/ would be compatible with JW Player.
pkoshevoy at gmail.com
pkoshevoy at gmail.com
Fri Feb 10 20:06:36 CET 2012
From: Pavel Koshevoy <pkoshevoy at gmail.com>
Signed-off-by: Pavel Koshevoy <pkoshevoy at gmail.com>
---
libavformat/mpegtsenc.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/libavformat/mpegtsenc.c b/libavformat/mpegtsenc.c
index a8c5c5c..e7990bf 100644
--- a/libavformat/mpegtsenc.c
+++ b/libavformat/mpegtsenc.c
@@ -589,7 +589,7 @@ static int mpegts_write_header(AVFormatContext *s)
ts->first_pcr = av_rescale(s->max_delay, PCR_TIME_BASE, AV_TIME_BASE);
} else {
- /* Arbitrary values, PAT/PMT could be written on key frames */
+ /* Arbitrary values, PAT/PMT will also be written on video key frames */
ts->sdt_packet_period = 200;
ts->pat_packet_period = 40;
if (pcr_st->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
@@ -650,7 +650,7 @@ static int mpegts_write_header(AVFormatContext *s)
}
/* send SDT, PAT and PMT tables regulary */
-static void retransmit_si_info(AVFormatContext *s)
+static void retransmit_si_info(AVFormatContext *s, int force_pat)
{
MpegTSWrite *ts = s->priv_data;
int i;
@@ -659,7 +659,7 @@ static void retransmit_si_info(AVFormatContext *s)
ts->sdt_packet_count = 0;
mpegts_write_sdt(s);
}
- if (++ts->pat_packet_count == ts->pat_packet_period) {
+ if (++ts->pat_packet_count == ts->pat_packet_period || force_pat) {
ts->pat_packet_count = 0;
mpegts_write_pat(s);
for(i = 0; i < ts->nb_services; i++) {
@@ -788,10 +788,12 @@ static void mpegts_write_pes(AVFormatContext *s, AVStream *st,
int afc_len, stuffing_len;
int64_t pcr = -1; /* avoid warning */
int64_t delay = av_rescale(s->max_delay, 90000, AV_TIME_BASE);
+ int force_pat = key && (st->codec->codec_type == AVMEDIA_TYPE_VIDEO);
is_start = 1;
while (payload_size > 0) {
- retransmit_si_info(s);
+ retransmit_si_info(s, force_pat);
+ force_pat = 0;
write_pcr = 0;
if (ts_st->pid == ts_st->service->pcr_pid) {
--
1.7.9
>From 900b3275aa5d7f0d2ace1e23ae78f4d51d7195d4 Mon Sep 17 00:00:00 2001
From: Pavel Koshevoy <pkoshevoy at gmail.com>
Date: Fri, 10 Feb 2012 11:31:21 -0700
Subject: [PATCH 2/2] Updated TS muxer regression test reference results
Signed-off-by: Pavel Koshevoy <pkoshevoy at gmail.com>
---
tests/ref/lavf/ts | 4 ++--
tests/ref/seek/lavf_ts | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/tests/ref/lavf/ts b/tests/ref/lavf/ts
index 81415b9..18566c4 100644
--- a/tests/ref/lavf/ts
+++ b/tests/ref/lavf/ts
@@ -1,3 +1,3 @@
-8f61dad7652abbab9e49fca274dabf30 *./tests/data/lavf/lavf.ts
-406644 ./tests/data/lavf/lavf.ts
+34f95a300355d474767b436430eba15b *./tests/data/lavf/lavf.ts
+ 406644 ./tests/data/lavf/lavf.ts
./tests/data/lavf/lavf.ts CRC=0x133216c1
diff --git a/tests/ref/seek/lavf_ts b/tests/ref/seek/lavf_ts
index 0bc7a52..690228d 100644
--- a/tests/ref/seek/lavf_ts
+++ b/tests/ref/seek/lavf_ts
@@ -8,7 +8,7 @@ ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 0 flags:1 ts:-0.317500
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 1 flags:0 ts: 2.576667
-ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
+ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 404012 size: 209
ret: 0 st: 1 flags:1 ts: 1.470833
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st:-1 flags:0 ts: 0.365002
@@ -16,13 +16,13 @@ ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st:-1 flags:1 ts:-0.740831
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 0 flags:0 ts: 2.153333
-ret: 0 st: 0 flags:0 dts: 2.160000 pts: 2.200000 pos: 325240 size: 12679
+ret: 0 st: 0 flags:0 dts: 2.160000 pts: 2.200000 pos: 325616 size: 12679
ret: 0 st: 0 flags:1 ts: 1.047500
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 1 flags:0 ts:-0.058333
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st: 1 flags:1 ts: 2.835833
-ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
+ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 404012 size: 209
ret: 0 st:-1 flags:0 ts: 1.730004
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st:-1 flags:1 ts: 0.624171
@@ -30,7 +30,7 @@ ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 0 flags:0 ts:-0.481667
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 0 flags:1 ts: 2.412500
-ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
+ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 404012 size: 209
ret: 0 st: 1 flags:0 ts: 1.306667
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st: 1 flags:1 ts: 0.200844
@@ -44,7 +44,7 @@ ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 0 flags:1 ts:-0.222489
ret: 0 st: 0 flags:1 dts: 1.360000 pts: 1.400000 pos: 564 size: 24801
ret: 0 st: 1 flags:0 ts: 2.671678
-ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 403636 size: 209
+ret: 0 st: 1 flags:1 dts: 2.131433 pts: 2.131433 pos: 404012 size: 209
ret: 0 st: 1 flags:1 ts: 1.565844
ret: 0 st: 1 flags:1 dts: 1.400000 pts: 1.400000 pos: 172584 size: 208
ret: 0 st:-1 flags:0 ts: 0.460008
--
1.7.9
More information about the ffmpeg-devel
mailing list