On Sat, 07 Jun 2008 13:47:14 -0400, Konstantin Gorskov
<[EMAIL PROTECTED]> wrote:
>
>> Just to cover the obvious... you aren't passing audio (or subtitle)
>> packets to the video decoder are you?
>>
> No, here is more of the code :
> else if (pkt->stream_index == is->video_stream) {
[...]
> while(av_read_frame(ic, pkt)>=0)
[...]
>
> As You can see, I'm working with video stream. Audio is decoded before,
> and I can hear a bit of it playing before crash. No subtitles are
> present.
Well, not quite. The stream is a mixture of audio and video packets, in
no particular sequence. You test to see that the packet is a video
packet, but then overwrite that packet with a new packet (which could be
video OR audio OR subtitle, or other kinds of data even) and then try to
decode it as if it were video.
av_read_frame gives you the next packet in the stream. Also, keep in mind
that the AVPacket object does always not own this data: it is merely a
struct giving you pointers to data owned by the demuxer.
The code sequence needs to be
while(av_read_frame(ic, pkt)>=0) {
if (pkt->stream_index == /*whatever*/) {
else if (pkt->stream_index == /*whatever*/) {
else if (pkt->stream_index == /*whatever*/) {
etc
av_free_packet(pkt)
}
and it is up to you to write the code you want to possibly decode it, copy
the packet to use later, or do whatever with its contents. But, the above
sequence must be used.
-Mike
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user