I think I got the reason. after I switch video track only, the audio and video track belongs to different program; so both program are downloaded. that means 4 track of stream (stream_index) reach me, though I select one audio and one video track only.
I think it will be good to change audio track as well when video track is changed, to use single program only. 2016-07-01 13:20 GMT+08:00 Halley Zhao <aihua.halley.z...@gmail.com>: > I tried ffplay on Ubuntu15.10, not expected result. seems buggy: > ffplay.c, 3160, got packet with stream_index: 0 > ffplay.c, 3160, got packet with stream_index: 2 > ffplay.c, 3160, got packet with stream_index: 4 > ffplay.c, 3160, got packet with stream_index: 0 > ffplay.c, 3160, got packet with stream_index: 2 > ffplay.c, 3160, got packet with stream_index: 4 > ffplay.c, 3160, got packet with stream_index: 0 > ffplay.c, 3160, got packet with stream_index: 2 > > > 2016-07-01 9:22 GMT+08:00 Halley Zhao <aihua.halley.z...@gmail.com>: > >> I tried it; but got unexpected result. >> the pkt of discarded stream (stream_index) is still got from >> av_read_frame(). >> >> my code is here: >> https://github.com/halleyzhao/player-ffmpeg-yami/blob/m3u8/player.c >> >> ## the code piece is here: >> #define MAX_TRACK_COUNT 10 >> uint32_t video_tracks[MAX_TRACK_COUNT], video_track_count = 0; >> uint32_t audio_tracks[MAX_TRACK_COUNT], audio_track_count = 0; >> for (i = 0; i < pFormat->nb_streams; i++) { >> if (pFormat->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO) >> { >> video_tracks[video_track_count++] = i; >> } else if (pFormat->streams[i]->codec->codec_type == >> AVMEDIA_TYPE_AUDIO) { >> audio_tracks[audio_track_count++] = i; >> } >> pFormat->streams[i]->discard = AVDISCARD_ALL; >> } >> >> if (video_track_count) { >> video_track_index = 0; >> video_stream_index = video_tracks[video_track_index]; >> pFormat->streams[video_stream_index]->discard = AVDISCARD_DEFAULT; >> } >> if (audio_track_count) { >> audio_track_index = 0; >> audio_stream_index = audio_tracks[audio_track_index]; >> pFormat->streams[audio_stream_index]->discard = AVDISCARD_DEFAULT; >> } >> ## and the result is here: video track has index 0/2/4. when I set 0 >> stream to AVDISCARD_DEFAULT and 2/4 to AVDISCARDALL, the pkt with >> stream_index 2/4 still reach me. >> player.c, 114, got pkt with stream_index: 0 >> player.c, 114, got pkt with stream_index: 2 >> player.c, 114, got pkt with stream_index: 4 >> player.c, 114, got pkt with stream_index: 0 >> player.c, 114, got pkt with stream_index: 2 >> player.c, 114, got pkt with stream_index: 4 >> player.c, 114, got pkt with stream_index: 0 >> player.c, 114, got pkt with stream_index: 2 >> player.c, 114, got pkt with stream_index: 3 >> player.c, 114, got pkt with stream_index: 3 >> player.c, 114, got pkt with stream_index: 4 >> player.c, 114, got pkt with stream_index: 5 >> player.c, 114, got pkt with stream_index: 5 >> >> 2016-06-29 19:25 GMT+08:00 aihua zhao <aihua.halley.z...@gmail.com>: >> >>> thanks, seems the right clue to follow. >>> >>> I don't know much about ffmpeg, after went through avplay.c. I think I >>> should do the following steps >>> 1. discard all stream by default. >>> refer to decode_thread() >>> for (i = 0; i < ic->nb_streams; i++) >>> ic->streams[i]->discard = AVDISCARD_ALL; >>> 2. enable the desired stream only >>> refer to stream_component_open() >>> ic->streams[stream_index]->discard = AVDISCARD_DEFAULT; >>> >>> thanks for your help. >>> >>> 2016-06-29 10:01 GMT+08:00 Steven Liu <lingjiujia...@gmail.com>: >>> >>>> 2016-06-29 8:36 GMT+08:00 aihua zhao <aihua.halley.z...@gmail.com>: >>>> >>>> > thanks. >>>> > >>>> > Yes, readahead the list is must. >>>> > but during playback, I found ffmpeg downloads each content of the list >>>> > -- av_read_frame() returns me each content with different >>>> stream_index. >>>> > I'm expecting av_read_frame() returns me the interested stream only. >>>> > I haven't found a way to do so; or said, is there ffmpeg interface to >>>> > specify a dedicate stream (stream_index) to download. >>>> > >>>> > i'm looking into hls.c; there is recheck_discard_flags(), seems it is >>>> > designed to do some policy like this. >>>> > but I haven't found one top level interface of ffmpeg for it. >>>> > recheck_discard_flags() is called once only during hls_read_packet() >>>> when >>>> > c->first_packet is set -- this flag is set in hls_read_header() only. >>>> > >>>> > >>>> > 2016-06-28 22:22 GMT+08:00 Steven Liu <lingjiujia...@gmail.com>: >>>> > >>>> > > 2016-06-28 14:26 GMT+08:00 aihua zhao <aihua.halley.z...@gmail.com >>>> >: >>>> > > >>>> > > > Hi Experts: >>>> > > > >>>> > > > I use ffmpeg to parse/demux media content, and created a player >>>> basing >>>> > on >>>> > > > it. >>>> > > > >>>> > > > here is a m3u8 content: >>>> > > > >>>> > > > >>>> > > >>>> > >>>> http://asp.cntv.lxdns.com/asp/hls/main/0303000a/3/default/438eb7a818b246c187e72f1cd4e1bc4c/main.m3u8 >>>> > > > < >>>> > > > >>>> > > >>>> > >>>> http://asp.cntv.lxdns.com/asp/hls/main/0303000a/3/default/438eb7a818b246c187e72f1cd4e1bc4c/main.m3u8?maxbr=1200 >>>> > > > > >>>> > > > there are three video track in it. >>>> > > > >>>> > > > I found all video/audio tracks are downloaded during playback, >>>> and I >>>> > can >>>> > > > switch different track on the fly. >>>> > > > however, it consumes much bandwidth since all tracks are >>>> downloaded. >>>> > > > >>>> > > > even when I append bandwidth to the url; still the same result: >>>> > > > >>>> > > > >>>> > > >>>> > >>>> http://asp.cntv.lxdns.com/asp/hls/main/0303000a/3/default/438eb7a818b246c187e72f1cd4e1bc4c/main.m3u8?maxbr=1200 >>>> > > > >>>> > > > Is there any way to download the specified track only to save >>>> > bandwidth? >>>> > > > >>>> > > > thanks >>>> > > > >>>> > > >>>> > > Hi Aihua Zhao, >>>> > > >>>> > > If you haven't read the m3u8 file and parse the playlist, and >>>> read >>>> > > the sub m3u8 playlist, how do you get the info of the mpegts? >>>> > > >>>> > > So it's must readahead the list and list all of the track for >>>> > choose. >>>> > you mean the function looks like "stream_cycle_channel" in ffplay? >>>> > >>>> _______________________________________________ >>>> ffmpeg-devel mailing list >>>> ffmpeg-devel@ffmpeg.org >>>> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >>>> >>> >>> >> > _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel