stream 对象创建时机

 
对于所有的文件格式,stream对象都是在probe函数探测到文件格式后调用相应的 AVInputFormat 的int (*read_header)(struct AVFormatContext *); 函数。

537 int avformat_open_input(AVFormatContext **ps, const char *filename,
 538                         AVInputFormat *fmt, AVDictionary **options)
 629 
 630     if (!(s->flags&AVFMT_FLAG_PRIV_OPT) && s->iformat->read_header)
 631         if ((ret = s->iformat->read_header(s)) < 0)
 632             goto fail;
For MKV
#0  avformat_new_stream (s=0x7fffe00008c0, c=0x0) at libavformat/utils.c:4456
#1  0x00000000007a1e89 in matroska_parse_tracks (s=0x7fffe00008c0) at libavformat/matroskadec.c:2199
#2  0x00000000007a4077 in matroska_read_header (s=0x7fffe00008c0) at libavformat/matroskadec.c:2657
#3  0x00000000008a1939 in avformat_open_input (ps=0x7fffe83b4d00, filename=0x423a060 "test.mkv", fmt=0x0, options=0x25e1410 <format_opts>) at libavformat/utils.c:631
For AVI 
#0  avformat_new_stream (s=0x7fffe00008c0, c=0x0) at libavformat/utils.c:4456
#1  0x000000000072970d in avi_read_header (s=0x7fffe00008c0) at libavformat/avidec.c:571
#2  0x00000000008a1939 in avformat_open_input (ps=0x7fffe83b4d00, filename=0x425a460 "/home/xw/Documents/videotest/mpeg1.avi", fmt=0x0, options=0x25e1410 <format_opts>) at libavformat/utils.c:631
For ts 
#0  avformat_new_stream (s=0x7fffe00008c0, c=0x0) at libavformat/utils.c:4456
#1  0x00000000007fd3b1 in pmt_cb (filter=0x7fffe0001040, section=0x7fffe0009500 "\002\260\027", section_len=26) at libavformat/mpegts.c:2075
#2  0x00000000007f8531 in write_section_data (ts=0x7fffe00174c0, tss1=0x7fffe0001040, buf=0x7fffe000f60d "\002\260\027", buf_size=183, is_start=1) at libavformat/mpegts.c:441
#3  0x00000000007fe2f1 in handle_packet (ts=0x7fffe00174c0, packet=0x7fffe000f608 "GO\377\020") at libavformat/mpegts.c:2394
#4  0x00000000007feb6e in handle_packets (ts=0x7fffe00174c0, nb_packets=26595) at libavformat/mpegts.c:2583
#5  0x00000000007ff1c3 in mpegts_read_header (s=0x7fffe00008c0) at libavformat/mpegts.c:2704
#6  0x00000000008a1939 in avformat_open_input (ps=0x7fffe83b4d00, filename=0x425d0f0 "/home/xw/Documents/videotest/tt.ts", fmt=0x0, options=0x25e1410 <format_opts>) at libavformat/utils.c:631
For mp3
#0  avformat_new_stream (s=0x7fffe00008c0, c=0x0) at libavformat/utils.c:4456
#1  0x00000000007ecf28 in mp3_read_header (s=0x7fffe00008c0) at libavformat/mp3dec.c:355
#2  0x00000000008a1939 in avformat_open_input (ps=0x7fffe83b4d00, filename=0x425d0f0 "/home/xw/Documents/videotest/tesss.mp3", fmt=0x0, options=0x25e1410 <format_opts>) at libavformat/utils.c:631