* [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option
@ 2022-09-28 9:55 Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: drop always-true conditions Anton Khirnov
` (7 more replies)
0 siblings, 8 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
It has been deprecated in favor of the aresample filter for almost 10
years.
Another thing this option can do is drop audio timestamps and have them
generated by the encoding code or the muxer, but
- for encoding, this can already be done with the setpts filter
- for muxing this should almost never be done as timestamp generation by
the muxer is deprecated, but people who really want to do this can use
the setts bitstream filter
---
doc/ffmpeg.texi | 12 ------------
fftools/ffmpeg.c | 2 +-
fftools/ffmpeg.h | 1 -
fftools/ffmpeg_filter.c | 10 ----------
fftools/ffmpeg_mux.c | 3 +--
fftools/ffmpeg_opt.c | 3 ---
6 files changed, 2 insertions(+), 29 deletions(-)
diff --git a/doc/ffmpeg.texi b/doc/ffmpeg.texi
index 42440d93b4..e9020b30d5 100644
--- a/doc/ffmpeg.texi
+++ b/doc/ffmpeg.texi
@@ -1697,18 +1697,6 @@ The default is -1.1. One possible usecase is to avoid framedrops in case
of noisy timestamps or to increase frame drop precision in case of exact
timestamps.
-@item -async @var{samples_per_second}
-Audio sync method. "Stretches/squeezes" the audio stream to match the timestamps,
-the parameter is the maximum samples per second by which the audio is changed.
--async 1 is a special case where only the start of the audio stream is corrected
-without any later correction.
-
-Note that the timestamps may be further modified by the muxer, after this.
-For example, in the case that the format option @option{avoid_negative_ts}
-is enabled.
-
-This option has been deprecated. Use the @code{aresample} audio filter instead.
-
@item -adrift_threshold @var{time}
Set the minimum difference between timestamps and audio data (in seconds) to trigger
adding/dropping samples to make it match the timestamps. This option effectively is
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 69716de6b6..f84701ec75 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1048,7 +1048,7 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
if (!check_recording_time(ost))
return;
- if (frame->pts == AV_NOPTS_VALUE || audio_sync_method < 0)
+ if (frame->pts == AV_NOPTS_VALUE)
frame->pts = ost->sync_opts;
ost->sync_opts = frame->pts + frame->nb_samples;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index ede0b2bd96..8acc83e92a 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -656,7 +656,6 @@ extern float audio_drift_threshold;
extern float dts_delta_threshold;
extern float dts_error_threshold;
-extern int audio_sync_method;
extern enum VideoSyncMethod video_sync_method;
extern float frame_drop_threshold;
extern int do_benchmark;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index 17928cea2c..82abb38a93 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -892,16 +892,6 @@ static int configure_input_audio_filter(FilterGraph *fg, InputFilter *ifilter,
last_filter = filt_ctx; \
} while (0)
- if (audio_sync_method > 0) {
- char args[256] = {0};
-
- av_strlcatf(args, sizeof(args), "async=%d", audio_sync_method);
- av_strlcatf(args, sizeof(args), ":min_hard_comp=%f", audio_drift_threshold);
- if (!fg->reconfiguration)
- av_strlcatf(args, sizeof(args), ":first_pts=0");
- AUTO_INSERT_FILTER_INPUT("-async", "aresample", args);
- }
-
snprintf(name, sizeof(name), "trim for input stream %d:%d",
ist->file_index, ist->st->index);
if (copy_ts) {
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index b781e1f5a6..395f7cc89f 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -102,8 +102,7 @@ static int write_packet(OutputFile *of, OutputStream *ost, AVPacket *pkt)
goto fail;
}
- if ((st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP) ||
- (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0))
+ if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && ost->vsync_method == VSYNC_DROP)
pkt->pts = pkt->dts = AV_NOPTS_VALUE;
if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) {
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 5febe319e4..8f57b699f1 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -157,7 +157,6 @@ float audio_drift_threshold = 0.1;
float dts_delta_threshold = 10;
float dts_error_threshold = 3600*30;
-int audio_sync_method = 0;
enum VideoSyncMethod video_sync_method = VSYNC_AUTO;
float frame_drop_threshold = 0;
int do_benchmark = 0;
@@ -3910,8 +3909,6 @@ const OptionDef options[] = {
"set video sync method globally; deprecated, use -fps_mode", "" },
{ "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &frame_drop_threshold },
"frame drop threshold", "" },
- { "async", HAS_ARG | OPT_INT | OPT_EXPERT, { &audio_sync_method },
- "audio sync method", "" },
{ "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &audio_drift_threshold },
"audio drift threshold", "threshold" },
{ "copyts", OPT_BOOL | OPT_EXPERT, { ©_ts },
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: drop always-true conditions
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
@ 2022-09-28 9:55 ` Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg: move forced keyframe processing into its own function Anton Khirnov
` (6 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
in_picture->pts cannot be AV_NOPTS_VALUE, as it is set to ost->sync_opts
a few lines above. ost->sync_opts is never AV_NOPTS_VALUE.
---
fftools/ffmpeg.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index f84701ec75..2054271c82 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1291,12 +1291,10 @@ static void do_video_out(OutputFile *of,
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
- if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE &&
- in_picture->pts != AV_NOPTS_VALUE)
+ if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE)
ost->forced_kf_ref_pts = in_picture->pts;
- pts_time = in_picture->pts != AV_NOPTS_VALUE ?
- (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base) : NAN;
+ pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base);
if (ost->forced_kf_index < ost->forced_kf_count &&
in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
ost->forced_kf_index++;
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg: move forced keyframe processing into its own function
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: drop always-true conditions Anton Khirnov
@ 2022-09-28 9:55 ` Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: cosmetics Anton Khirnov
` (5 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffmpeg.c | 108 +++++++++++++++++++++++++----------------------
1 file changed, 58 insertions(+), 50 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 2054271c82..833df0b167 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1133,6 +1133,63 @@ static void do_subtitle_out(OutputFile *of,
}
}
+static enum AVPictureType forced_kf_apply(OutputStream *ost,
+ const AVFrame *in_picture, int dup_idx)
+{
+ AVCodecContext *enc = ost->enc_ctx;
+ double pts_time;
+
+ if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE)
+ ost->forced_kf_ref_pts = in_picture->pts;
+
+ pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base);
+ if (ost->forced_kf_index < ost->forced_kf_count &&
+ in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
+ ost->forced_kf_index++;
+ goto force_keyframe;
+ } else if (ost->forced_keyframes_pexpr) {
+ double res;
+ ost->forced_keyframes_expr_const_values[FKF_T] = pts_time;
+ res = av_expr_eval(ost->forced_keyframes_pexpr,
+ ost->forced_keyframes_expr_const_values, NULL);
+ ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
+ ost->forced_keyframes_expr_const_values[FKF_N],
+ ost->forced_keyframes_expr_const_values[FKF_N_FORCED],
+ ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
+ ost->forced_keyframes_expr_const_values[FKF_T],
+ ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
+ res);
+
+ ost->forced_keyframes_expr_const_values[FKF_N] += 1;
+
+ if (res) {
+ ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
+ ost->forced_keyframes_expr_const_values[FKF_N] - 1;
+ ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
+ ost->forced_keyframes_expr_const_values[FKF_T];
+ ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
+ goto force_keyframe;
+ }
+ } else if ( ost->forced_keyframes
+ && !strncmp(ost->forced_keyframes, "source", 6)
+ && in_picture->key_frame==1
+ && !dup_idx) {
+ goto force_keyframe;
+ } else if ( ost->forced_keyframes
+ && !strncmp(ost->forced_keyframes, "source_no_drop", 14)
+ && !dup_idx) {
+ ost->dropped_keyframe = 0;
+ if ((in_picture->key_frame == 1) || ost->dropped_keyframe)
+ goto force_keyframe;
+ }
+
+ return AV_PICTURE_TYPE_NONE;
+
+force_keyframe:
+ av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time);
+ return AV_PICTURE_TYPE_I;
+}
+
/* May modify/reset next_picture */
static void do_video_out(OutputFile *of,
OutputStream *ost,
@@ -1272,8 +1329,6 @@ static void do_video_out(OutputFile *of,
/* duplicates frame if needed */
for (i = 0; i < nb_frames; i++) {
AVFrame *in_picture;
- int forced_keyframe = 0;
- double pts_time;
if (i < nb0_frames && ost->last_frame->buf[0]) {
in_picture = ost->last_frame;
@@ -1289,54 +1344,7 @@ static void do_video_out(OutputFile *of,
return;
in_picture->quality = enc->global_quality;
- in_picture->pict_type = 0;
-
- if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE)
- ost->forced_kf_ref_pts = in_picture->pts;
-
- pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base);
- if (ost->forced_kf_index < ost->forced_kf_count &&
- in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
- ost->forced_kf_index++;
- forced_keyframe = 1;
- } else if (ost->forced_keyframes_pexpr) {
- double res;
- ost->forced_keyframes_expr_const_values[FKF_T] = pts_time;
- res = av_expr_eval(ost->forced_keyframes_pexpr,
- ost->forced_keyframes_expr_const_values, NULL);
- ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
- ost->forced_keyframes_expr_const_values[FKF_N],
- ost->forced_keyframes_expr_const_values[FKF_N_FORCED],
- ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
- ost->forced_keyframes_expr_const_values[FKF_T],
- ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
- res);
- if (res) {
- forced_keyframe = 1;
- ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
- ost->forced_keyframes_expr_const_values[FKF_N];
- ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
- ost->forced_keyframes_expr_const_values[FKF_T];
- ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
- }
-
- ost->forced_keyframes_expr_const_values[FKF_N] += 1;
- } else if ( ost->forced_keyframes
- && !strncmp(ost->forced_keyframes, "source", 6)
- && in_picture->key_frame==1
- && !i) {
- forced_keyframe = 1;
- } else if ( ost->forced_keyframes
- && !strncmp(ost->forced_keyframes, "source_no_drop", 14)
- && !i) {
- forced_keyframe = (in_picture->key_frame == 1) || ost->dropped_keyframe;
- ost->dropped_keyframe = 0;
- }
-
- if (forced_keyframe) {
- in_picture->pict_type = AV_PICTURE_TYPE_I;
- av_log(NULL, AV_LOG_DEBUG, "Forced keyframe at time %f\n", pts_time);
- }
+ in_picture->pict_type = forced_kf_apply(ost, in_picture, i);
ret = submit_encode_frame(of, ost, in_picture);
if (ret < 0 && ret != AVERROR_EOF)
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: cosmetics
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: drop always-true conditions Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg: move forced keyframe processing into its own function Anton Khirnov
@ 2022-09-28 9:55 ` Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 5/9] fftools/ffmpeg: drop never-set OutputStream.first_pts Anton Khirnov
` (4 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
Reindent after previous commit, apply some style fixes.
---
fftools/ffmpeg.c | 85 ++++++++++++++++++++++++------------------------
1 file changed, 42 insertions(+), 43 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 833df0b167..697971167c 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1137,51 +1137,50 @@ static enum AVPictureType forced_kf_apply(OutputStream *ost,
const AVFrame *in_picture, int dup_idx)
{
AVCodecContext *enc = ost->enc_ctx;
- double pts_time;
-
- if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE)
- ost->forced_kf_ref_pts = in_picture->pts;
-
- pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base);
- if (ost->forced_kf_index < ost->forced_kf_count &&
- in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
- ost->forced_kf_index++;
- goto force_keyframe;
- } else if (ost->forced_keyframes_pexpr) {
- double res;
- ost->forced_keyframes_expr_const_values[FKF_T] = pts_time;
- res = av_expr_eval(ost->forced_keyframes_pexpr,
- ost->forced_keyframes_expr_const_values, NULL);
- ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
- ost->forced_keyframes_expr_const_values[FKF_N],
- ost->forced_keyframes_expr_const_values[FKF_N_FORCED],
- ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
- ost->forced_keyframes_expr_const_values[FKF_T],
- ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
- res);
-
- ost->forced_keyframes_expr_const_values[FKF_N] += 1;
-
- if (res) {
- ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
- ost->forced_keyframes_expr_const_values[FKF_N] - 1;
- ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
- ost->forced_keyframes_expr_const_values[FKF_T];
- ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
- goto force_keyframe;
- }
- } else if ( ost->forced_keyframes
- && !strncmp(ost->forced_keyframes, "source", 6)
- && in_picture->key_frame==1
- && !dup_idx) {
+ double pts_time;
+
+ if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE)
+ ost->forced_kf_ref_pts = in_picture->pts;
+
+ pts_time = (in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base);
+ if (ost->forced_kf_index < ost->forced_kf_count &&
+ in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
+ ost->forced_kf_index++;
+ goto force_keyframe;
+ } else if (ost->forced_keyframes_pexpr) {
+ double res;
+ ost->forced_keyframes_expr_const_values[FKF_T] = pts_time;
+ res = av_expr_eval(ost->forced_keyframes_pexpr,
+ ost->forced_keyframes_expr_const_values, NULL);
+ ff_dlog(NULL, "force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
+ ost->forced_keyframes_expr_const_values[FKF_N],
+ ost->forced_keyframes_expr_const_values[FKF_N_FORCED],
+ ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N],
+ ost->forced_keyframes_expr_const_values[FKF_T],
+ ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T],
+ res);
+
+ ost->forced_keyframes_expr_const_values[FKF_N] += 1;
+
+ if (res) {
+ ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_N] =
+ ost->forced_keyframes_expr_const_values[FKF_N] - 1;
+ ost->forced_keyframes_expr_const_values[FKF_PREV_FORCED_T] =
+ ost->forced_keyframes_expr_const_values[FKF_T];
+ ost->forced_keyframes_expr_const_values[FKF_N_FORCED] += 1;
goto force_keyframe;
- } else if ( ost->forced_keyframes
- && !strncmp(ost->forced_keyframes, "source_no_drop", 14)
- && !dup_idx) {
- ost->dropped_keyframe = 0;
- if ((in_picture->key_frame == 1) || ost->dropped_keyframe)
- goto force_keyframe;
}
+ } else if (ost->forced_keyframes &&
+ !strncmp(ost->forced_keyframes, "source", 6) &&
+ in_picture->key_frame == 1 && !dup_idx) {
+ goto force_keyframe;
+ } else if (ost->forced_keyframes &&
+ !strncmp(ost->forced_keyframes, "source_no_drop", 14) &&
+ !dup_idx) {
+ ost->dropped_keyframe = 0;
+ if ((in_picture->key_frame == 1) || ost->dropped_keyframe)
+ goto force_keyframe;
+ }
return AV_PICTURE_TYPE_NONE;
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 5/9] fftools/ffmpeg: drop never-set OutputStream.first_pts
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
` (2 preceding siblings ...)
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: cosmetics Anton Khirnov
@ 2022-09-28 9:55 ` Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: stop setting OutputStream.sync_opts for streamcopy Anton Khirnov
` (3 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
---
fftools/ffmpeg.c | 2 +-
fftools/ffmpeg.h | 3 ---
2 files changed, 1 insertion(+), 4 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 697971167c..971c146fea 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -763,7 +763,7 @@ static int check_recording_time(OutputStream *ost)
OutputFile *of = output_files[ost->file_index];
if (of->recording_time != INT64_MAX &&
- av_compare_ts(ost->sync_opts - ost->first_pts, ost->enc_ctx->time_base, of->recording_time,
+ av_compare_ts(ost->sync_opts, ost->enc_ctx->time_base, of->recording_time,
AV_TIME_BASE_Q) >= 0) {
close_output_stream(ost);
return 0;
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 8acc83e92a..a9883c0442 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -495,9 +495,6 @@ typedef struct OutputStream {
/* input pts and corresponding output pts
for A/V sync */
int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ // FIXME look at frame_number
- /* pts of the first frame encoded for this stream, used for limiting
- * recording time */
- int64_t first_pts;
/* dts of the last packet sent to the muxing queue, in AV_TIME_BASE_Q */
int64_t last_mux_dts;
/* pts of the last frame received from the filters, in AV_TIME_BASE_Q */
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: stop setting OutputStream.sync_opts for streamcopy
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
` (3 preceding siblings ...)
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 5/9] fftools/ffmpeg: drop never-set OutputStream.first_pts Anton Khirnov
@ 2022-09-28 9:55 ` Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: pass the timestamp to check_recording_time() Anton Khirnov
` (2 subsequent siblings)
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
It is not used for anything.
---
fftools/ffmpeg.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 971c146fea..1a6768f6c2 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1934,8 +1934,6 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
opkt->duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase);
- ost->sync_opts += opkt->duration;
-
output_packet(of, opkt, ost, 0);
ost->streamcopy_started = 1;
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: pass the timestamp to check_recording_time()
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
` (4 preceding siblings ...)
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: stop setting OutputStream.sync_opts for streamcopy Anton Khirnov
@ 2022-09-28 9:55 ` Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg: rename OutputStream.sync_opts to next_pts Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move some code from init_output_stream() to init_output_stream_encode() Anton Khirnov
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
Stop setting OutputStream.sync_opts for subtitle encoding, as it is now
unused.
---
fftools/ffmpeg.c | 12 +++++-------
1 file changed, 5 insertions(+), 7 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 1a6768f6c2..40c01b1c65 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -758,13 +758,12 @@ fail:
}
-static int check_recording_time(OutputStream *ost)
+static int check_recording_time(OutputStream *ost, int64_t ts, AVRational tb)
{
OutputFile *of = output_files[ost->file_index];
if (of->recording_time != INT64_MAX &&
- av_compare_ts(ost->sync_opts, ost->enc_ctx->time_base, of->recording_time,
- AV_TIME_BASE_Q) >= 0) {
+ av_compare_ts(ts, tb, of->recording_time, AV_TIME_BASE_Q) >= 0) {
close_output_stream(ost);
return 0;
}
@@ -1045,7 +1044,7 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
adjust_frame_pts_to_encoder_tb(of, ost, frame);
- if (!check_recording_time(ost))
+ if (!check_recording_time(ost, ost->sync_opts, ost->enc_ctx->time_base))
return;
if (frame->pts == AV_NOPTS_VALUE)
@@ -1091,8 +1090,7 @@ static void do_subtitle_out(OutputFile *of,
for (i = 0; i < nb; i++) {
unsigned save_num_rects = sub->num_rects;
- ost->sync_opts = av_rescale_q(pts, AV_TIME_BASE_Q, enc->time_base);
- if (!check_recording_time(ost))
+ if (!check_recording_time(ost, pts, AV_TIME_BASE_Q))
return;
ret = av_new_packet(pkt, subtitle_out_max_size);
@@ -1339,7 +1337,7 @@ static void do_video_out(OutputFile *of,
in_picture->pts = ost->sync_opts;
- if (!check_recording_time(ost))
+ if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base))
return;
in_picture->quality = enc->global_quality;
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg: rename OutputStream.sync_opts to next_pts
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
` (5 preceding siblings ...)
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: pass the timestamp to check_recording_time() Anton Khirnov
@ 2022-09-28 9:55 ` Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move some code from init_output_stream() to init_output_stream_encode() Anton Khirnov
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
The current name is confusing.
---
fftools/ffmpeg.c | 22 ++++++++++++----------
fftools/ffmpeg.h | 6 +++---
2 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 40c01b1c65..6deca8bfbf 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1044,12 +1044,12 @@ static void do_audio_out(OutputFile *of, OutputStream *ost,
adjust_frame_pts_to_encoder_tb(of, ost, frame);
- if (!check_recording_time(ost, ost->sync_opts, ost->enc_ctx->time_base))
+ if (!check_recording_time(ost, ost->next_pts, ost->enc_ctx->time_base))
return;
if (frame->pts == AV_NOPTS_VALUE)
- frame->pts = ost->sync_opts;
- ost->sync_opts = frame->pts + frame->nb_samples;
+ frame->pts = ost->next_pts;
+ ost->next_pts = frame->pts + frame->nb_samples;
ret = submit_encode_frame(of, ost, frame);
if (ret < 0 && ret != AVERROR_EOF)
@@ -1230,7 +1230,9 @@ static void do_video_out(OutputFile *of,
ost->last_nb0_frames[1],
ost->last_nb0_frames[2]);
} else {
- delta0 = sync_ipts - ost->sync_opts; // delta0 is the "drift" between the input frame (next_picture) and where it would fall in the output.
+ /* delta0 is the "drift" between the input frame (next_picture) and
+ * where it would fall in the output. */
+ delta0 = sync_ipts - ost->next_pts;
delta = delta0 + duration;
/* by default, we output a single frame */
@@ -1245,7 +1247,7 @@ static void do_video_out(OutputFile *of,
av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0);
} else
av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0);
- sync_ipts = ost->sync_opts;
+ sync_ipts = ost->next_pts;
duration += delta0;
delta0 = 0;
}
@@ -1256,7 +1258,7 @@ static void do_video_out(OutputFile *of,
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
delta = duration;
delta0 = 0;
- ost->sync_opts = llrint(sync_ipts);
+ ost->next_pts = llrint(sync_ipts);
}
case VSYNC_CFR:
// FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
@@ -1275,13 +1277,13 @@ static void do_video_out(OutputFile *of,
if (delta <= -0.6)
nb_frames = 0;
else if (delta > 0.6)
- ost->sync_opts = llrint(sync_ipts);
+ ost->next_pts = llrint(sync_ipts);
next_picture->duration = duration;
break;
case VSYNC_DROP:
case VSYNC_PASSTHROUGH:
next_picture->duration = duration;
- ost->sync_opts = llrint(sync_ipts);
+ ost->next_pts = llrint(sync_ipts);
break;
default:
av_assert0(0);
@@ -1335,7 +1337,7 @@ static void do_video_out(OutputFile *of,
if (!in_picture)
return;
- in_picture->pts = ost->sync_opts;
+ in_picture->pts = ost->next_pts;
if (!check_recording_time(ost, in_picture->pts, ost->enc_ctx->time_base))
return;
@@ -1347,7 +1349,7 @@ static void do_video_out(OutputFile *of,
if (ret < 0 && ret != AVERROR_EOF)
exit_program(1);
- ost->sync_opts++;
+ ost->next_pts++;
ost->vsync_frame_number++;
}
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index a9883c0442..d466a1ff9f 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -492,9 +492,9 @@ typedef struct OutputStream {
AVStream *st; /* stream in the output file */
/* number of frames emitted by the video-encoding sync code */
int64_t vsync_frame_number;
- /* input pts and corresponding output pts
- for A/V sync */
- int64_t sync_opts; /* output frame counter, could be changed to some true timestamp */ // FIXME look at frame_number
+ /* predicted pts of the next frame to be encoded
+ * audio/video encoding only */
+ int64_t next_pts;
/* dts of the last packet sent to the muxing queue, in AV_TIME_BASE_Q */
int64_t last_mux_dts;
/* pts of the last frame received from the filters, in AV_TIME_BASE_Q */
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move some code from init_output_stream() to init_output_stream_encode()
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
` (6 preceding siblings ...)
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg: rename OutputStream.sync_opts to next_pts Anton Khirnov
@ 2022-09-28 9:55 ` Anton Khirnov
7 siblings, 0 replies; 9+ messages in thread
From: Anton Khirnov @ 2022-09-28 9:55 UTC (permalink / raw)
To: ffmpeg-devel
The code is subtitle-encoding-specific, so this is a more appropriate
place for it.
---
fftools/ffmpeg.c | 58 ++++++++++++++++++++++++------------------------
1 file changed, 29 insertions(+), 29 deletions(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 6deca8bfbf..754172e568 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -3129,6 +3129,34 @@ static int init_output_stream_encode(OutputStream *ost, AVFrame *frame)
enc_ctx->width = input_streams[ost->source_index]->par->width;
enc_ctx->height = input_streams[ost->source_index]->par->height;
}
+ if (dec_ctx && dec_ctx->subtitle_header) {
+ /* ASS code assumes this buffer is null terminated so add extra byte. */
+ ost->enc_ctx->subtitle_header = av_mallocz(dec_ctx->subtitle_header_size + 1);
+ if (!ost->enc_ctx->subtitle_header)
+ return AVERROR(ENOMEM);
+ memcpy(ost->enc_ctx->subtitle_header, dec_ctx->subtitle_header,
+ dec_ctx->subtitle_header_size);
+ ost->enc_ctx->subtitle_header_size = dec_ctx->subtitle_header_size;
+ }
+ if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE &&
+ enc_ctx->codec_type == AVMEDIA_TYPE_SUBTITLE) {
+ int input_props = 0, output_props = 0;
+ AVCodecDescriptor const *input_descriptor =
+ avcodec_descriptor_get(ist->dec->id);
+ AVCodecDescriptor const *output_descriptor =
+ avcodec_descriptor_get(ost->enc_ctx->codec_id);
+ if (input_descriptor)
+ input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
+ if (output_descriptor)
+ output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
+ if (input_props && output_props && input_props != output_props) {
+ av_log(NULL, AV_LOG_ERROR,
+ "Subtitle encoding currently only possible from text to text "
+ "or bitmap to bitmap");
+ return AVERROR_INVALIDDATA;
+ }
+ }
+
break;
case AVMEDIA_TYPE_DATA:
break;
@@ -3156,23 +3184,13 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
if (ost->enc_ctx) {
const AVCodec *codec = ost->enc_ctx->codec;
- AVCodecContext *dec = NULL;
InputStream *ist;
ret = init_output_stream_encode(ost, frame);
if (ret < 0)
return ret;
- if ((ist = get_input_stream(ost)))
- dec = ist->dec_ctx;
- if (dec && dec->subtitle_header) {
- /* ASS code assumes this buffer is null terminated so add extra byte. */
- ost->enc_ctx->subtitle_header = av_mallocz(dec->subtitle_header_size + 1);
- if (!ost->enc_ctx->subtitle_header)
- return AVERROR(ENOMEM);
- memcpy(ost->enc_ctx->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
- ost->enc_ctx->subtitle_header_size = dec->subtitle_header_size;
- }
+ ist = get_input_stream(ost);
if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0))
av_dict_set(&ost->encoder_opts, "threads", "auto", 0);
@@ -3184,24 +3202,6 @@ static int init_output_stream(OutputStream *ost, AVFrame *frame,
return ret;
}
- if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && codec->type == AVMEDIA_TYPE_SUBTITLE) {
- int input_props = 0, output_props = 0;
- AVCodecDescriptor const *input_descriptor =
- avcodec_descriptor_get(dec->codec_id);
- AVCodecDescriptor const *output_descriptor =
- avcodec_descriptor_get(ost->enc_ctx->codec_id);
- if (input_descriptor)
- input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
- if (output_descriptor)
- output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
- if (input_props && output_props && input_props != output_props) {
- snprintf(error, error_len,
- "Subtitle encoding currently only possible from text to text "
- "or bitmap to bitmap");
- return AVERROR_INVALIDDATA;
- }
- }
-
if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)
abort_codec_experimental(codec, 1);
--
2.35.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2022-09-28 9:59 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-28 9:55 [FFmpeg-devel] [PATCH 1/9] fftools/ffmpeg: drop the -async option Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 2/9] fftools/ffmpeg: drop always-true conditions Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 3/9] fftools/ffmpeg: move forced keyframe processing into its own function Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 4/9] fftools/ffmpeg: cosmetics Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 5/9] fftools/ffmpeg: drop never-set OutputStream.first_pts Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 6/9] fftools/ffmpeg: stop setting OutputStream.sync_opts for streamcopy Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 7/9] fftools/ffmpeg: pass the timestamp to check_recording_time() Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 8/9] fftools/ffmpeg: rename OutputStream.sync_opts to next_pts Anton Khirnov
2022-09-28 9:55 ` [FFmpeg-devel] [PATCH 9/9] fftools/ffmpeg: move some code from init_output_stream() to init_output_stream_encode() Anton Khirnov
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git