参数的设置最终都是设置到对应的解复?器,?如:
mpegts.c,如下:

文章插图
flvdec.c,如下:

文章插图
avformat_find_stream_info()
在打开了?件后,就可以从AVFormatContext中读取流信息了 。?般调?avformat_find_stream_info获取完整的流信息 。为什么在调?了avformat_open_input后,仍然需要调?avformat_find_stream_info才能获取正确的流信息呢?看下注释:
/** * Read packets of a media file to get stream information. This * is useful for file formats with no headers such as MPEG. This * function also computes the real framerate in case of MPEG-2 repeat * frame mode. * The logical file position is not changed by this function; * examined packets may be buffered for later processing. ** @param ic media file handle * @param options If non-NULL, an ic.nb_streams long array of pointers to * dictionaries, where i-th member contains options for* codec corresponding to i-th stream. * On return each dictionary will be filled with options that were not found. * @return >=0 if OK, AVERROR_xxx on error ** @note this function isn't guaranteed to open all the codecs, so* options being non-empty at return is a perfectly normal behavior.** @todo Let the user decide somehow what information is needed so that* we do not waste time getting stuff the user does not need. */int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options);该函数是通过读取媒体?件的部分数据来分析流信息 。在?些缺少头信息的封装下特别有?,?如说MPEG(这?应该说ts更准确)(FLV?件也是需要读取packet 分析流信息) 。?被读取?以分析流信息的数据可能被缓存,供av_read_frame时使?,在播放时并不会跳过这部分packet的读取 。检测是否指定播放起始时间
如果指定时间则seek到指定位置avformat_seek_file 。可以通过 ffplay -ss 设置起始时间,时间格式hh:mm:ss,?如ffplay -ss 00:00:30 test.flv 则是从30秒的起始位置开始播放 。
具体调?流程,可以在av_opt_seek 函数打断点进?测试 。
{ "ss", HAS_ARG, { .func_arg = opt_seek }, "seek to a given position in seconds", "pos" },{ "t", HAS_ARG, { .func_arg = opt_duration }, "play "duration" sec onds of audio/video", "duration" },/* if seeking requested, we execute it *//* 5. 检测是否指定播放起始时间 */if (start_time != AV_NOPTS_VALUE) {int64_t timestamp;timestamp = start_time;/* add the stream start time */if (ic->start_time != AV_NOPTS_VALUE)timestamp += ic->start_time;// seek的指定的位置开始播放ret = avformat_seek_file(ic, -1, INT64_MIN, timestamp, INT64_MAX , 0);if (ret < 0) {av_log(NULL, AV_LOG_WARNING, "%s: could not seek to position %0.3fn",is->filename, (double)timestamp / AV_TIME_BASE);}} 2路音频,一路国语语音,一路粤语语音 。

文章插图
设置ast,可以选择是哪一路音频播放 。在这里去配置 。比如这里指定0,就是播放粤语 。指定1,就是国语了 。

文章插图
这些是视频和音频参数 。

文章插图
具体现在那个流进?播放我们有两种策略:
在播放起始指定对应的流 。
ffplay是通过通过命令可以指定流 。使用ast是指定音频流,使用vst是指定视频流,使用sst是指定字幕流 。
{ "ast", OPT_STRING | HAS_ARG | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_AUDIO] }, "select desired audio stream", "stream_specifier" },{ "vst", OPT_STRING | HAS_ARG | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_VIDEO] }, "select desired video stream", "stream_specifier" },{ "sst", OPT_STRING | HAS_ARG | OPT_EXPERT, { &wanted_stream_spec[AVMEDIA_TYPE_SUBTITLE] }, "select desired subtitle stream", "stream_specifier" },可以通过如下选择:-ast n 指定?频流(?如我们在看电影时,有些电影可以?持普通话和英?切换,此时可以?该命令进?选择) 。
-vst n 指定视频流 。
-vst n 指定字幕流 。
把对应的index值记录到st_index[AVMEDIA_TYPE_NB]; 。
使?缺省的流进?播放 。
如果我们没有指定,则ffplay主要是通过 av_find_best_stream 来选择,自动去匹配,其原型为:
推荐阅读
- 海盐奶茶做法,奶茶的详细做法
- 苏州园林的特点解析
- 关于住宅风水朝向解析
- 电动车电池寿命探究与解析
- 孕囊超过23厘米药流会怎样
- 青岛市|好找工作但对口率超低?汉语言文学专业到底是什么样的呢?
- HttpClient三个超时时间详解
- 负载均衡解析与Nginx实战
- 康熙王朝人物关系结构 康熙王朝人物解析
- 央视|今年以来线下的空调、洗衣机、冰箱都变贵了 央视:均价涨超10%
