aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2013-05-08 23:43:19 +0200
committerMichael Niedermayer <michaelni@gmx.at>2013-05-08 23:55:06 +0200
commit33ff943f70f04035942a68c725f6cf3426df0677 (patch)
treee71c90d85ca1e32335ed01345d8c4e03854c5ca2
parent410905f7fd0d7f3274f3260aa508dc50e174105b (diff)
downloadffmpeg-33ff943f70f04035942a68c725f6cf3426df0677.tar.gz
ffmpeg: add -apad option which injects a apad filter only in the presence of video streams
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r--ffmpeg.c1
-rw-r--r--ffmpeg.h3
-rw-r--r--ffmpeg_filter.c15
-rw-r--r--ffmpeg_opt.c6
4 files changed, 25 insertions, 0 deletions
diff --git a/ffmpeg.c b/ffmpeg.c
index 1f61d29fbb..15c2a29371 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -3260,6 +3260,7 @@ static int transcode(void)
}
av_freep(&ost->st->codec->subtitle_header);
av_freep(&ost->forced_kf_pts);
+ av_freep(&ost->apad);
av_dict_free(&ost->opts);
av_dict_free(&ost->swr_opts);
av_dict_free(&ost->resample_opts);
diff --git a/ffmpeg.h b/ffmpeg.h
index 558c996789..24e6d47d0b 100644
--- a/ffmpeg.h
+++ b/ffmpeg.h
@@ -178,6 +178,8 @@ typedef struct OptionsContext {
int nb_passlogfiles;
SpecifierOpt *guess_layout_max;
int nb_guess_layout_max;
+ SpecifierOpt *apad;
+ int nb_apad;
} OptionsContext;
typedef struct InputFilter {
@@ -356,6 +358,7 @@ typedef struct OutputStream {
AVDictionary *opts;
AVDictionary *swr_opts;
AVDictionary *resample_opts;
+ char *apad;
int finished; /* no more packets should be written for this stream */
int unavailable; /* true if the steram is unavailable (possibly temporarily) */
int stream_copy;
diff --git a/ffmpeg_filter.c b/ffmpeg_filter.c
index 58581c20d7..4b5c6768af 100644
--- a/ffmpeg_filter.c
+++ b/ffmpeg_filter.c
@@ -424,6 +424,7 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
OutputStream *ost = ofilter->ost;
AVCodecContext *codec = ost->st->codec;
AVFilterContext *last_filter = out->filter_ctx;
+ OutputFile *of = output_files[ost->file_index];
int pad_idx = out->pad_idx;
char *sample_fmts, *sample_rates, *channel_layouts;
char name[255];
@@ -519,6 +520,20 @@ static int configure_output_audio_filter(FilterGraph *fg, OutputFilter *ofilter,
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);
if (ret < 0)
return ret;
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index c87bf01100..2aff60179c 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -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(apad, str, ost->apad, oc, st);
+ ost->apad = av_strdup(ost->apad);
+
ost->avfilter = get_ost_filters(o, oc, ost);
if (!ost->avfilter)
exit(1);
@@ -2642,6 +2645,9 @@ const OptionDef options[] = {
{ "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
OPT_OUTPUT, { .off = OFFSET(shortest) },
"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 },
"timestamp discontinuity delta threshold", "threshold" },
{ "dts_error_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_error_threshold },