aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-04-24 18:44:51 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-04-24 19:00:41 +0200
commit44bd2f90a973960db5e5c74bf21110de8434a10f (patch)
treede3c4d080b8ea06389780ba3025b54fe920bc914
parentae0591f9132faf9a283f7b07540c19c2158bd293 (diff)
downloadffmpeg-44bd2f90a973960db5e5c74bf21110de8434a10f.tar.gz
ffmpeg: Fix initial dts for streamcopy, if the input packets lack dts.
Fixes Ticket1138 Based on a patch by: Eelco Lempsink <eml@tupil.com> Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--ffmpeg.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 069ada8d52..5c6a94fba5 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -235,6 +235,7 @@ typedef struct InputStream {
int64_t pts; ///< current pts of the decoded frame
double ts_scale;
int is_start; /* is 1 at the start and after a discontinuity */
+ int saw_first_ts;
int showed_multi_packet_warning;
AVDictionary *opts;
@@ -2691,6 +2692,15 @@ static int output_packet(InputStream *ist, const AVPacket *pkt)
int64_t pkt_pts = AV_NOPTS_VALUE;
AVPacket avpkt;
+ if (!ist->saw_first_ts) {
+ ist->dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
+ ist->pts = 0;
+ if (pkt != NULL && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {
+ ist->dts += av_rescale_q(pkt->pts, ist->st->time_base, AV_TIME_BASE_Q);
+ ist->pts = ist->dts; //unused but better to set it to a value thats not totally wrong
+ }
+ ist->saw_first_ts = 1;
+ }
if (ist->next_dts == AV_NOPTS_VALUE)
ist->next_dts = ist->dts;
@@ -2872,7 +2882,6 @@ static int init_input_stream(int ist_index, char *error, int error_len)
}
}
- ist->dts = ist->st->avg_frame_rate.num ? - ist->st->codec->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
ist->next_pts = AV_NOPTS_VALUE;
ist->next_dts = AV_NOPTS_VALUE;
ist->is_start = 1;