[Libav-user] Unable to decode AVPacket that are retrieved from AVPacketList.
sithruk sana
get2jils at gmail.com
Wed May 21 18:00:16 CEST 2014
Dear all,
I have been implementing the video [ only] player in android using SDL
and ffmpeg.
I followed the below approach [from dranger tutorial ]
1) There is a linked list with each node of type AVPacketList
AVPacketList *firstNode=NULL, *lastNode=NULL;
2) There are two threads:
ReadPacket - Reads packet from av_read_frame, and stores in the
linked list.
FrameDisplay - Reads packet from Linked list , decodes the same if
complete packet is received. Pushes specific event to SDL to render the
frame.
3) Main Function:
kick starts two threads ReadPacket, FrameDisplay.
*Issue:*
How can i pass to and from queue ? what is the correct way of doing ?
In ReadPacket thread:
AVPacket pkt1, *rpacket=&pkt1;
if ( av_read_frame(pFormatCtx, rpacket) >= 0) {
if (packet.stream_index == videoStream) {
// Creating new node to push..
AVPacketList *newNode =
av_malloc(sizeof(AVPacketList));
newNode->pkt = *rpacket;
newNode->next = NULL;
// pushing newNode.
}
In FrameDisplay Thread:
1) Reading node from queue
2) take the packet like:
AVPacket *pkt;
*pkt = newNode->pkt;
3) Decode Now:
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, pkt);
if (frameFinished) {
// I AM UNABLE TO REACH HERE...
}
*It is the right way to copy the AVPacket structure to and from ?*
ie: While copying newNode->pkt = *rpacket;
While retrieving AVPacket *pkt = newNode->pkt ?
*Surprisingly, instead of keeping the AVPacket in the queue, if i directly
decode, i could able to decode successfully.*
Kindly point out what went wrong ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140521/5d0df4da/attachment.html>
More information about the Libav-user
mailing list