aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Almer <jamrial@gmail.com>2021-05-31 17:15:56 -0300
committerJames Almer <jamrial@gmail.com>2021-06-04 22:36:39 -0300
commitab4f299e237708e81af473c88ec5acf0dd13d8eb (patch)
treec7c480a64f65dcc9f627c8c7f066c0621e307b11
parent57de80673cb42c04097067d304dc04df1bfed3e8 (diff)
downloadffmpeg-ab4f299e237708e81af473c88ec5acf0dd13d8eb.tar.gz
fftools/ffmpeg: remove usage of internal timestamp AVStream fields
They should not be accessed outside of libavformat. Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r--fftools/ffmpeg.c10
-rw-r--r--fftools/ffmpeg.h1
-rw-r--r--fftools/ffmpeg_opt.c1
3 files changed, 8 insertions, 4 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index b3658d8f65..04ddc9e60b 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1168,7 +1168,7 @@ static void do_video_out(OutputFile *of,
if (frame_rate.num > 0 && frame_rate.den > 0)
duration = 1/(av_q2d(frame_rate) * av_q2d(enc->time_base));
- if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->st->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
+ if(ist && ist->st->start_time != AV_NOPTS_VALUE && ist->first_dts != AV_NOPTS_VALUE && ost->frame_rate.num)
duration = FFMIN(duration, 1/(av_q2d(ost->frame_rate) * av_q2d(enc->time_base)));
if (!ost->filters_script &&
@@ -2625,9 +2625,11 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
avpkt = ist->pkt;
if (!ist->saw_first_ts) {
+ ist->first_dts =
ist->dts = ist->st->avg_frame_rate.num ? - ist->dec_ctx->has_b_frames * AV_TIME_BASE / av_q2d(ist->st->avg_frame_rate) : 0;
ist->pts = 0;
if (pkt && pkt->pts != AV_NOPTS_VALUE && !ist->decoding_needed) {
+ ist->first_dts =
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
}
@@ -3949,10 +3951,10 @@ static OutputStream *choose_output(void)
for (i = 0; i < nb_output_streams; i++) {
OutputStream *ost = output_streams[i];
- int64_t opts = ost->st->cur_dts == AV_NOPTS_VALUE ? INT64_MIN :
- av_rescale_q(ost->st->cur_dts, ost->st->time_base,
+ int64_t opts = ost->last_mux_dts == AV_NOPTS_VALUE ? INT64_MIN :
+ av_rescale_q(ost->last_mux_dts, ost->st->time_base,
AV_TIME_BASE_Q);
- if (ost->st->cur_dts == AV_NOPTS_VALUE)
+ if (ost->last_mux_dts == AV_NOPTS_VALUE)
av_log(NULL, AV_LOG_DEBUG,
"cur_dts is invalid st:%d (%d) [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n",
ost->st->index, ost->st->id, ost->initialized, ost->inputs_done, ost->finished);
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 606f2afe0c..e9d30fbd67 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -316,6 +316,7 @@ typedef struct InputStream {
/* predicted dts of the next packet read for this stream or (when there are
* several frames in a packet) of the next frame in current packet (in AV_TIME_BASE units) */
int64_t next_dts;
+ int64_t first_dts; ///< dts of the first packet read for this stream (in AV_TIME_BASE units)
int64_t dts; ///< dts of the last packet read for this stream (in AV_TIME_BASE units)
int64_t next_pts; ///< synthetic pts for the next decode frame (in AV_TIME_BASE units)
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 849d24b16d..a63bed54cf 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -809,6 +809,7 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
ist->discard = 1;
st->discard = AVDISCARD_ALL;
ist->nb_samples = 0;
+ ist->first_dts = AV_NOPTS_VALUE;
ist->min_pts = INT64_MAX;
ist->max_pts = INT64_MIN;