Signed-off-by: Michael Niedermayer <michaelni@gmx.at>tags/n2.0
@@ -3260,6 +3260,7 @@ static int transcode(void) | |||||
} | } | ||||
av_freep(&ost->st->codec->subtitle_header); | av_freep(&ost->st->codec->subtitle_header); | ||||
av_freep(&ost->forced_kf_pts); | av_freep(&ost->forced_kf_pts); | ||||
av_freep(&ost->apad); | |||||
av_dict_free(&ost->opts); | av_dict_free(&ost->opts); | ||||
av_dict_free(&ost->swr_opts); | av_dict_free(&ost->swr_opts); | ||||
av_dict_free(&ost->resample_opts); | av_dict_free(&ost->resample_opts); | ||||
@@ -178,6 +178,8 @@ typedef struct OptionsContext { | |||||
int nb_passlogfiles; | int nb_passlogfiles; | ||||
SpecifierOpt *guess_layout_max; | SpecifierOpt *guess_layout_max; | ||||
int nb_guess_layout_max; | int nb_guess_layout_max; | ||||
SpecifierOpt *apad; | |||||
int nb_apad; | |||||
} OptionsContext; | } OptionsContext; | ||||
typedef struct InputFilter { | typedef struct InputFilter { | ||||
@@ -356,6 +358,7 @@ typedef struct OutputStream { | |||||
AVDictionary *opts; | AVDictionary *opts; | ||||
AVDictionary *swr_opts; | AVDictionary *swr_opts; | ||||
AVDictionary *resample_opts; | AVDictionary *resample_opts; | ||||
char *apad; | |||||
int finished; /* no more packets should be written for this stream */ | int finished; /* no more packets should be written for this stream */ | ||||
int unavailable; /* true if the steram is unavailable (possibly temporarily) */ | int unavailable; /* true if the steram is unavailable (possibly temporarily) */ | ||||
int stream_copy; | int stream_copy; | ||||
@@ -424,6 +424,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, | |||||
OutputStream *ost = ofilter->ost; | OutputStream *ost = ofilter->ost; | ||||
AVCodecContext *codec = ost->st->codec; | AVCodecContext *codec = ost->st->codec; | ||||
AVFilterContext *last_filter = out->filter_ctx; | AVFilterContext *last_filter = out->filter_ctx; | ||||
OutputFile *of = output_files[ost->file_index]; | |||||
int pad_idx = out->pad_idx; | int pad_idx = out->pad_idx; | ||||
char *sample_fmts, *sample_rates, *channel_layouts; | char *sample_fmts, *sample_rates, *channel_layouts; | ||||
char name[255]; | char name[255]; | ||||
@@ -519,6 +520,20 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter, | |||||
AUTO_INSERT_FILTER("-vol", "volume", args); | AUTO_INSERT_FILTER("-vol", "volume", args); | ||||
} | } | ||||
if (ost->apad && of->shortest) { | |||||
char args[256]; | |||||
int i; | |||||
for (i=0; i<of->ctx->nb_streams; i++) | |||||
if (of->ctx->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) | |||||
break; | |||||
if (i<of->ctx->nb_streams) { | |||||
snprintf(args, sizeof(args), "%s", ost->apad); | |||||
AUTO_INSERT_FILTER("-apad", "apad", args); | |||||
} | |||||
} | |||||
ret = insert_trim(ost, &last_filter, &pad_idx); | ret = insert_trim(ost, &last_filter, &pad_idx); | ||||
if (ret < 0) | if (ret < 0) | ||||
return ret; | return ret; | ||||
@@ -1334,6 +1334,9 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in | |||||
MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st); | MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st); | ||||
MATCH_PER_STREAM_OPT(apad, str, ost->apad, oc, st); | |||||
ost->apad = av_strdup(ost->apad); | |||||
ost->avfilter = get_ost_filters(o, oc, ost); | ost->avfilter = get_ost_filters(o, oc, ost); | ||||
if (!ost->avfilter) | if (!ost->avfilter) | ||||
exit(1); | exit(1); | ||||
@@ -2642,6 +2645,9 @@ const OptionDef options[] = { | |||||
{ "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET | | { "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET | | ||||
OPT_OUTPUT, { .off = OFFSET(shortest) }, | OPT_OUTPUT, { .off = OFFSET(shortest) }, | ||||
"finish encoding within shortest input" }, | "finish encoding within shortest input" }, | ||||
{ "apad", OPT_STRING | HAS_ARG | OPT_SPEC | | |||||
OPT_OUTPUT, { .off = OFFSET(apad) }, | |||||
"audio pad", "" }, | |||||
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_delta_threshold }, | { "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_delta_threshold }, | ||||
"timestamp discontinuity delta threshold", "threshold" }, | "timestamp discontinuity delta threshold", "threshold" }, | ||||
{ "dts_error_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_error_threshold }, | { "dts_error_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_error_threshold }, | ||||