本文主要是介绍ffmpeg接收网络流AVFormatContext设置,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
在使用ffmpeg接收网络ts流时,如不对AVFormatContext作设置,则在执行avformat_find_stream_info时会出现等待时间过长的情况。
需设置的两个参数为probesize,max_analyze_duration,分别代表为确定输入格式而从输入读取的最大数据大小以及从输入avformat_find_stream_info()中读取数据的最大持续时间,将其设置足够大即可。
/*** @deprecated deprecated in favor of probesize2*/unsigned int probesize;/*** @deprecated deprecated in favor of max_analyze_duration2*/attribute_deprecatedint max_analyze_duration;
/*** Maximum duration (in AV_TIME_BASE units) of the data read* from input in avformat_find_stream_info().* Demuxing only, set by the caller before avformat_find_stream_info()* via AVOptions (NO direct access).* Can be set to 0 to let avformat choose using a heuristic.*/int64_t max_analyze_duration2;/*** Maximum size of the data read from input for determining* the input container format.* Demuxing only, set by the caller before avformat_open_input()* via AVOptions (NO direct access).*/int64_t probesize2;
AVFormatContext结构如下:
typedef struct AVFormatContext {/*** A class for logging and @ref avoptions. Set by avformat_alloc_context().* Exports (de)muxer private options if they exist.*/const AVClass *av_class;/*** The input container format.** Demuxing only, set by avformat_open_input().*/struct AVInputFormat *iformat;/*** The output container format.** Muxing only, must be set by the caller before avformat_write_header().*/struct AVOutputFormat *oformat;/*** Format private data. This is an AVOptions-enabled struct* if and only if iformat/oformat.priv_class is not NULL.** - muxing: set by avformat_write_header()* - demuxing: set by avformat_open_input()*/void *priv_data;/*** I/O context.** - demuxing: either set by the user before avformat_open_input() (then* the user must close it manually) or set by avformat_open_input().* - muxing: set by the user before avformat_write_header(). The caller must* take care of closing / freeing the IO context.** Do NOT set this field if AVFMT_NOFILE flag is set in* iformat/oformat.flags. In such a case, the (de)muxer will handle* I/O in some other way and this field will be NULL.*/AVIOContext *pb;/* stream info *//*** Flags signalling stream properties. A combination of AVFMTCTX_*.* Set by libavformat.*/int ctx_flags;/*** Number of elements in AVFormatContext.streams.** Set by avformat_new_stream(), must not be modified by any other code.*/unsigned int nb_streams;/*** A list of all streams in the file. New streams are created with* avformat_new_stream().** - demuxing: streams are created by libavformat in avformat_open_input().* If AVFMTCTX_NOHEADER is set in ctx_flags, then new streams may also* appear in av_read_frame().* - muxing: streams are created by the user before avformat_write_header().** Freed by libavformat in avformat_free_context().*/AVStream **streams;/*** input or output filename** - demuxing: set by avformat_open_input()* - muxing: may be set by the caller before avformat_write_header()*/char filename[1024];/*** Position of the first frame of the component, in* AV_TIME_BASE fractional seconds. NEVER set
这篇关于ffmpeg接收网络流AVFormatContext设置的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!