ffmpeg: move setting video sync method to new_video_stream()
do_video_out() is the wrong place for it, since the necessary information is already known when creating the stream and its value should never change.
This commit is contained in:
parent
6ce9546428
commit
9145c6d3b2
|
@ -1144,7 +1144,6 @@ static void do_video_out(OutputFile *of,
|
||||||
AVFrame *next_picture)
|
AVFrame *next_picture)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
enum VideoSyncMethod format_video_sync;
|
|
||||||
AVPacket *pkt = ost->pkt;
|
AVPacket *pkt = ost->pkt;
|
||||||
AVCodecContext *enc = ost->enc_ctx;
|
AVCodecContext *enc = ost->enc_ctx;
|
||||||
AVRational frame_rate;
|
AVRational frame_rate;
|
||||||
|
@ -1191,28 +1190,10 @@ static void do_video_out(OutputFile *of,
|
||||||
nb0_frames = 0; // tracks the number of times the PREVIOUS frame should be duplicated, mostly for variable framerate (VFR)
|
nb0_frames = 0; // tracks the number of times the PREVIOUS frame should be duplicated, mostly for variable framerate (VFR)
|
||||||
nb_frames = 1;
|
nb_frames = 1;
|
||||||
|
|
||||||
format_video_sync = video_sync_method;
|
|
||||||
if (format_video_sync == VSYNC_AUTO) {
|
|
||||||
if(!strcmp(of->ctx->oformat->name, "avi")) {
|
|
||||||
format_video_sync = VSYNC_VFR;
|
|
||||||
} else
|
|
||||||
format_video_sync = (of->ctx->oformat->flags & AVFMT_VARIABLE_FPS) ? ((of->ctx->oformat->flags & AVFMT_NOTIMESTAMPS) ? VSYNC_PASSTHROUGH : VSYNC_VFR) : VSYNC_CFR;
|
|
||||||
if ( ist
|
|
||||||
&& format_video_sync == VSYNC_CFR
|
|
||||||
&& input_files[ist->file_index]->ctx->nb_streams == 1
|
|
||||||
&& input_files[ist->file_index]->input_ts_offset == 0) {
|
|
||||||
format_video_sync = VSYNC_VSCFR;
|
|
||||||
}
|
|
||||||
if (format_video_sync == VSYNC_CFR && copy_ts) {
|
|
||||||
format_video_sync = VSYNC_VSCFR;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ost->is_cfr = (format_video_sync == VSYNC_CFR || format_video_sync == VSYNC_VSCFR);
|
|
||||||
|
|
||||||
if (delta0 < 0 &&
|
if (delta0 < 0 &&
|
||||||
delta > 0 &&
|
delta > 0 &&
|
||||||
format_video_sync != VSYNC_PASSTHROUGH &&
|
ost->vsync_method != VSYNC_PASSTHROUGH &&
|
||||||
format_video_sync != VSYNC_DROP) {
|
ost->vsync_method != VSYNC_DROP) {
|
||||||
if (delta0 < -0.6) {
|
if (delta0 < -0.6) {
|
||||||
av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0);
|
av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0);
|
||||||
} else
|
} else
|
||||||
|
@ -1222,7 +1203,7 @@ static void do_video_out(OutputFile *of,
|
||||||
delta0 = 0;
|
delta0 = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (format_video_sync) {
|
switch (ost->vsync_method) {
|
||||||
case VSYNC_VSCFR:
|
case VSYNC_VSCFR:
|
||||||
if (ost->frame_number == 0 && delta0 >= 0.5) {
|
if (ost->frame_number == 0 && delta0 >= 0.5) {
|
||||||
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
|
av_log(NULL, AV_LOG_DEBUG, "Not duplicating %d initial frames\n", (int)lrintf(delta0));
|
||||||
|
|
|
@ -485,6 +485,7 @@ typedef struct OutputStream {
|
||||||
/* video only */
|
/* video only */
|
||||||
AVRational frame_rate;
|
AVRational frame_rate;
|
||||||
AVRational max_frame_rate;
|
AVRational max_frame_rate;
|
||||||
|
enum VideoSyncMethod vsync_method;
|
||||||
int is_cfr;
|
int is_cfr;
|
||||||
int force_fps;
|
int force_fps;
|
||||||
int top_field_first;
|
int top_field_first;
|
||||||
|
|
|
@ -1895,6 +1895,30 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
|
||||||
ost->top_field_first = -1;
|
ost->top_field_first = -1;
|
||||||
MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st);
|
MATCH_PER_STREAM_OPT(top_field_first, i, ost->top_field_first, oc, st);
|
||||||
|
|
||||||
|
ost->vsync_method = video_sync_method;
|
||||||
|
if (ost->vsync_method == VSYNC_AUTO) {
|
||||||
|
if (!strcmp(oc->oformat->name, "avi")) {
|
||||||
|
ost->vsync_method = VSYNC_VFR;
|
||||||
|
} else {
|
||||||
|
ost->vsync_method = (oc->oformat->flags & AVFMT_VARIABLE_FPS) ?
|
||||||
|
((oc->oformat->flags & AVFMT_NOTIMESTAMPS) ?
|
||||||
|
VSYNC_PASSTHROUGH : VSYNC_VFR) :
|
||||||
|
VSYNC_CFR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ost->source_index >= 0 && ost->vsync_method == VSYNC_CFR) {
|
||||||
|
const InputStream *ist = input_streams[ost->source_index];
|
||||||
|
const InputFile *ifile = input_files[ist->file_index];
|
||||||
|
|
||||||
|
if (ifile->nb_streams == 1 && ifile->input_ts_offset == 0)
|
||||||
|
ost->vsync_method = VSYNC_VSCFR;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ost->vsync_method == VSYNC_CFR && copy_ts) {
|
||||||
|
ost->vsync_method = VSYNC_VSCFR;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ost->is_cfr = (ost->vsync_method == VSYNC_CFR || ost->vsync_method == VSYNC_VSCFR);
|
||||||
|
|
||||||
ost->avfilter = get_ost_filters(o, oc, ost);
|
ost->avfilter = get_ost_filters(o, oc, ost);
|
||||||
if (!ost->avfilter)
|
if (!ost->avfilter)
|
||||||
|
|
Loading…
Reference in New Issue