avconv: move bitstream filters to options context.

Change syntax -- -[vas]bsf are replaced by -bsf:[stream specifier], the
argument is now a comma-separated list of bitstream filters.
This commit is contained in:
Anton Khirnov 2011-08-31 08:45:25 +02:00
parent f480532822
commit d821cbe2ff
2 changed files with 33 additions and 49 deletions

View File

@ -183,10 +183,6 @@ static unsigned int allocated_audio_out_size, allocated_audio_buf_size;
static short *samples; static short *samples;
static AVBitStreamFilterContext *video_bitstream_filters=NULL;
static AVBitStreamFilterContext *audio_bitstream_filters=NULL;
static AVBitStreamFilterContext *subtitle_bitstream_filters=NULL;
#define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass" #define DEFAULT_PASS_LOGFILENAME_PREFIX "av2pass"
typedef struct InputStream { typedef struct InputStream {
@ -328,6 +324,8 @@ typedef struct OptionsContext {
int nb_metadata; int nb_metadata;
SpecifierOpt *max_frames; SpecifierOpt *max_frames;
int nb_max_frames; int nb_max_frames;
SpecifierOpt *bitstream_filters;
int nb_bitstream_filters;
} OptionsContext; } OptionsContext;
#define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\ #define MATCH_PER_STREAM_OPT(name, type, outvar, fmtctx, st)\
@ -3064,6 +3062,8 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0); AVStream *st = av_new_stream(oc, oc->nb_streams < nb_streamid_map ? streamid_map[oc->nb_streams] : 0);
int idx = oc->nb_streams - 1; int idx = oc->nb_streams - 1;
int64_t max_frames = INT64_MAX; int64_t max_frames = INT64_MAX;
char *bsf = NULL, *next;
AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
if (!st) { if (!st) {
av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n"); av_log(NULL, AV_LOG_ERROR, "Could not alloc stream.\n");
@ -3088,6 +3088,23 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st); MATCH_PER_STREAM_OPT(max_frames, i64, max_frames, oc, st);
ost->max_frames = max_frames; ost->max_frames = max_frames;
MATCH_PER_STREAM_OPT(bitstream_filters, str, bsf, oc, st);
while (bsf) {
if (next = strchr(bsf, ','))
*next++ = 0;
if (!(bsfc = av_bitstream_filter_init(bsf))) {
av_log(NULL, AV_LOG_ERROR, "Unknown bitstream filter %s\n", bsf);
exit_program(1);
}
if (bsfc_prev)
bsfc_prev->next = bsfc;
else
ost->bitstream_filters = bsfc;
bsfc_prev = bsfc;
bsf = next;
}
ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL); ost->sws_flags = av_get_int(sws_opts, "sws_flags", NULL);
return ost; return ost;
} }
@ -3109,9 +3126,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
#endif #endif
} }
ost->bitstream_filters = video_bitstream_filters;
video_bitstream_filters= NULL;
video_enc = st->codec; video_enc = st->codec;
if(video_codec_tag) if(video_codec_tag)
@ -3212,9 +3226,6 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc)
ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO); ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO);
st = ost->st; st = ost->st;
ost->bitstream_filters = audio_bitstream_filters;
audio_bitstream_filters= NULL;
audio_enc = st->codec; audio_enc = st->codec;
audio_enc->codec_type = AVMEDIA_TYPE_AUDIO; audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
@ -3282,9 +3293,6 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc)
st = ost->st; st = ost->st;
subtitle_enc = st->codec; subtitle_enc = st->codec;
ost->bitstream_filters = subtitle_bitstream_filters;
subtitle_bitstream_filters= NULL;
subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE; subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
if(subtitle_codec_tag) if(subtitle_codec_tag)
@ -4008,27 +4016,6 @@ static int opt_vstats(const char *opt, const char *arg)
return opt_vstats_file(opt, filename); return opt_vstats_file(opt, filename);
} }
static int opt_bsf(const char *opt, const char *arg)
{
AVBitStreamFilterContext *bsfc= av_bitstream_filter_init(arg); //FIXME split name and args for filter at '='
AVBitStreamFilterContext **bsfp;
if(!bsfc){
fprintf(stderr, "Unknown bitstream filter %s\n", arg);
exit_program(1);
}
bsfp= *opt == 'v' ? &video_bitstream_filters :
*opt == 'a' ? &audio_bitstream_filters :
&subtitle_bitstream_filters;
while(*bsfp)
bsfp= &(*bsfp)->next;
*bsfp= bsfc;
return 0;
}
static int opt_video_frames(OptionsContext *o, const char *opt, const char *arg) static int opt_video_frames(OptionsContext *o, const char *opt, const char *arg)
{ {
return parse_option(o, "frames:v", arg, options); return parse_option(o, "frames:v", arg, options);
@ -4146,9 +4133,7 @@ static const OptionDef options[] = {
{ "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_max_delay}, "set the maximum demux-decode delay", "seconds" }, { "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_max_delay}, "set the maximum demux-decode delay", "seconds" },
{ "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_preload}, "set the initial demux-decode delay", "seconds" }, { "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT, {(void*)&mux_preload}, "set the initial demux-decode delay", "seconds" },
{ "absf", HAS_ARG | OPT_AUDIO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" }, { "bsf", HAS_ARG | OPT_STRING | OPT_SPEC, {.off = OFFSET(bitstream_filters)}, "A comma-separated list of bitstream filters", "bitstream_filters" },
{ "vbsf", HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
{ "sbsf", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
/* data codec support */ /* data codec support */
{ "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {(void*)opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" }, { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {(void*)opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" },

View File

@ -567,11 +567,6 @@ Intra_dc_precision.
Force video tag/fourcc. Force video tag/fourcc.
@item -qphist @item -qphist
Show QP histogram. Show QP histogram.
@item -vbsf @var{bitstream_filter}
Bitstream filters available are "dump_extra", "remove_extra", "noise", "h264_mp4toannexb", "imxdump", "mjpegadump", "mjpeg2jpeg".
@example
avconv -i h264.mp4 -c:v copy -vbsf h264_mp4toannexb -an out.h264
@end example
@item -force_key_frames @var{time}[,@var{time}...] @item -force_key_frames @var{time}[,@var{time}...]
Force key frames at the specified timestamps, more precisely at the first Force key frames at the specified timestamps, more precisely at the first
frames after each specified time. frames after each specified time.
@ -632,8 +627,6 @@ Voice Over
@item ka @item ka
Karaoke Karaoke
@end table @end table
@item -absf @var{bitstream_filter}
Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp", "mp3decomp".
@end table @end table
@section Subtitle options: @section Subtitle options:
@ -645,11 +638,6 @@ Set the subtitle codec. This is an alias for @code{-codec:s}.
Set the ISO 639 language code (3 letters) of the current subtitle stream. Set the ISO 639 language code (3 letters) of the current subtitle stream.
@item -sn @item -sn
Disable subtitle recording. Disable subtitle recording.
@item -sbsf @var{bitstream_filter}
Bitstream filters available are "mov2textsub", "text2movsub".
@example
avconv -i file.mov -an -vn -sbsf mov2textsub -c:s copy -f rawvideo sub.txt
@end example
@end table @end table
@section Audio/Video grab options @section Audio/Video grab options
@ -812,6 +800,17 @@ an output mpegts file:
@example @example
avconv -i infile -streamid 0:33 -streamid 1:36 out.ts avconv -i infile -streamid 0:33 -streamid 1:36 out.ts
@end example @end example
@item -bsf[:@var{stream_specifier}] @var{bitstream_filters}
Set bitstream filters for matching streams. @var{bistream_filters} is
a comma-separated list of bitstream filters. Use the @code{-bsfs} option
to get the list of bitstream filters.
@example
avconv -i h264.mp4 -c:v copy -vbsf h264_mp4toannexb -an out.h264
@end example
@example
avconv -i file.mov -an -vn -sbsf mov2textsub -c:s copy -f rawvideo sub.txt
@end example
@end table @end table
@c man end OPTIONS @c man end OPTIONS