summaryrefslogtreecommitdiff
path: root/fftools/ffmpeg_mux_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'fftools/ffmpeg_mux_init.c')
-rw-r--r--fftools/ffmpeg_mux_init.c36
1 files changed, 29 insertions, 7 deletions
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 6e19b98abd..a483fffa6e 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -828,6 +828,7 @@ static int new_stream_video(Muxer *mux, const OptionsContext *o,
static int new_stream_audio(Muxer *mux, const OptionsContext *o,
OutputStream *ost)
{
+ MuxStream *ms = ms_from_ost(ost);
AVFormatContext *oc = mux->fc;
AVStream *st = ost->st;
@@ -836,7 +837,6 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o,
int channels = 0;
char *layout = NULL;
char *sample_fmt = NULL;
- const char *apad = NULL;
MATCH_PER_STREAM_OPT(audio_channels, i, channels, oc, st);
if (channels) {
@@ -859,12 +859,7 @@ static int new_stream_audio(Muxer *mux, const OptionsContext *o,
MATCH_PER_STREAM_OPT(audio_sample_rate, i, audio_enc->sample_rate, oc, st);
- MATCH_PER_STREAM_OPT(apad, str, apad, oc, st);
- if (apad) {
- ost->apad = av_strdup(apad);
- if (!ost->apad)
- return AVERROR(ENOMEM);
- }
+ MATCH_PER_STREAM_OPT(apad, str, ms->apad, oc, st);
}
return 0;
@@ -1890,6 +1885,33 @@ static int create_streams(Muxer *mux, const OptionsContext *o)
}
}
+ // handle -apad
+ if (mux->of.shortest) {
+ int have_video = 0;
+
+ for (unsigned i = 0; i < mux->of.nb_streams; i++)
+ if (mux->of.streams[i]->type == AVMEDIA_TYPE_VIDEO) {
+ have_video = 1;
+ break;
+ }
+
+ for (unsigned i = 0; have_video && i < mux->of.nb_streams; i++) {
+ MuxStream *ms = ms_from_ost(mux->of.streams[i]);
+ OutputFilter *ofilter = ms->ost.filter;
+
+ if (ms->ost.type != AVMEDIA_TYPE_AUDIO || !ms->apad || !ofilter)
+ continue;
+
+ ofilter->apad = av_strdup(ms->apad);
+ if (!ofilter->apad)
+ return AVERROR(ENOMEM);
+ }
+ }
+ for (unsigned i = 0; i < mux->of.nb_streams; i++) {
+ MuxStream *ms = ms_from_ost(mux->of.streams[i]);
+ ms->apad = NULL;
+ }
+
if (!oc->nb_streams && !(oc->oformat->flags & AVFMT_NOSTREAMS)) {
av_dump_format(oc, nb_output_files - 1, oc->url, 1);
av_log(mux, AV_LOG_ERROR, "Output file does not contain any stream\n");