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:
		
							parent
							
								
									f480532822
								
							
						
					
					
						commit
						d821cbe2ff
					
				
							
								
								
									
										59
									
								
								avconv.c
									
									
									
									
									
								
							
							
						
						
									
										59
									
								
								avconv.c
									
									
									
									
									
								
							@ -183,10 +183,6 @@ static unsigned int allocated_audio_out_size, allocated_audio_buf_size;
 | 
			
		||||
 | 
			
		||||
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"
 | 
			
		||||
 | 
			
		||||
typedef struct InputStream {
 | 
			
		||||
@ -328,6 +324,8 @@ typedef struct OptionsContext {
 | 
			
		||||
    int        nb_metadata;
 | 
			
		||||
    SpecifierOpt *max_frames;
 | 
			
		||||
    int        nb_max_frames;
 | 
			
		||||
    SpecifierOpt *bitstream_filters;
 | 
			
		||||
    int        nb_bitstream_filters;
 | 
			
		||||
} OptionsContext;
 | 
			
		||||
 | 
			
		||||
#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);
 | 
			
		||||
    int idx      = oc->nb_streams - 1;
 | 
			
		||||
    int64_t max_frames = INT64_MAX;
 | 
			
		||||
    char *bsf = NULL, *next;
 | 
			
		||||
    AVBitStreamFilterContext *bsfc, *bsfc_prev = NULL;
 | 
			
		||||
 | 
			
		||||
    if (!st) {
 | 
			
		||||
        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);
 | 
			
		||||
    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);
 | 
			
		||||
    return ost;
 | 
			
		||||
}
 | 
			
		||||
@ -3109,9 +3126,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc)
 | 
			
		||||
#endif
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    ost->bitstream_filters = video_bitstream_filters;
 | 
			
		||||
    video_bitstream_filters= NULL;
 | 
			
		||||
 | 
			
		||||
    video_enc = st->codec;
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
    st  = ost->st;
 | 
			
		||||
 | 
			
		||||
    ost->bitstream_filters = audio_bitstream_filters;
 | 
			
		||||
    audio_bitstream_filters= NULL;
 | 
			
		||||
 | 
			
		||||
    audio_enc = st->codec;
 | 
			
		||||
    audio_enc->codec_type = AVMEDIA_TYPE_AUDIO;
 | 
			
		||||
 | 
			
		||||
@ -3282,9 +3293,6 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc)
 | 
			
		||||
    st  = ost->st;
 | 
			
		||||
    subtitle_enc = st->codec;
 | 
			
		||||
 | 
			
		||||
    ost->bitstream_filters = subtitle_bitstream_filters;
 | 
			
		||||
    subtitle_bitstream_filters= NULL;
 | 
			
		||||
 | 
			
		||||
    subtitle_enc->codec_type = AVMEDIA_TYPE_SUBTITLE;
 | 
			
		||||
 | 
			
		||||
    if(subtitle_codec_tag)
 | 
			
		||||
@ -4008,27 +4016,6 @@ static int opt_vstats(const char *opt, const char *arg)
 | 
			
		||||
    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)
 | 
			
		||||
{
 | 
			
		||||
    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" },
 | 
			
		||||
    { "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" },
 | 
			
		||||
    { "vbsf", HAS_ARG | OPT_VIDEO | OPT_EXPERT, {(void*)opt_bsf}, "", "bitstream_filter" },
 | 
			
		||||
    { "sbsf", HAS_ARG | OPT_SUBTITLE | 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" },
 | 
			
		||||
 | 
			
		||||
    /* data codec support */
 | 
			
		||||
    { "dcodec", HAS_ARG | OPT_DATA | OPT_FUNC2, {(void*)opt_data_codec}, "force data codec ('copy' to copy stream)", "codec" },
 | 
			
		||||
 | 
			
		||||
@ -567,11 +567,6 @@ Intra_dc_precision.
 | 
			
		||||
Force video tag/fourcc.
 | 
			
		||||
@item -qphist
 | 
			
		||||
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}...]
 | 
			
		||||
Force key frames at the specified timestamps, more precisely at the first
 | 
			
		||||
frames after each specified time.
 | 
			
		||||
@ -632,8 +627,6 @@ Voice Over
 | 
			
		||||
@item ka
 | 
			
		||||
Karaoke
 | 
			
		||||
@end table
 | 
			
		||||
@item -absf @var{bitstream_filter}
 | 
			
		||||
Bitstream filters available are "dump_extra", "remove_extra", "noise", "mp3comp", "mp3decomp".
 | 
			
		||||
@end table
 | 
			
		||||
 | 
			
		||||
@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.
 | 
			
		||||
@item -sn
 | 
			
		||||
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
 | 
			
		||||
 | 
			
		||||
@section Audio/Video grab options
 | 
			
		||||
@ -812,6 +800,17 @@ an output mpegts file:
 | 
			
		||||
@example
 | 
			
		||||
avconv -i infile -streamid 0:33 -streamid 1:36 out.ts
 | 
			
		||||
@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
 | 
			
		||||
@c man end OPTIONS
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user