Hi, I try to save the keyframes. I found which frames are keyframes.
I wrote two function to seek where the keyframes are. One of them is
with av_seek_frame and the other is with url_seek ..but none of them
work.
Here in this function pFormatCtx->pb->pos values of frames are in
"keyFrames" array.. but my function doesn't work.
for(i=0;i=0){
pFormatCtx->pb->pos=packet.pos;
if(pFormatCtx->pb->pos == keyFrames[i]){
int64_t byteposition = pFormatCtx->pb->pos;
url_seek(pFormatCtx->pb,byteposition,SEEK_SET);
avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished,
&packet);
SaveFrame(pFrame, pCodecCtx->width, pCodecCtx->height,i++);
break;
}
av_free_packet(&packet);
}
Here in this function, "keyframes" array hold the number of which
frames are keyframe..In this function framefinished is 0 and
avcodec_decode_video returns -1. I think maybe I calculate timestamp
wrong but I couldn't find why?! (index is length of the "keyframe"
array..)
for(i=0;i<index+1;i++){
int64_t timeStamp = (int64_t)((pFormatCtx->duration) /
framecount)*keyFrames[i]/1000;
av_seek_frame(pFormatCtx,-1,timeStamp,AVSEEK_FLAG_ANY);
while(av_read_frame(pFormatCtx, &packet)>=0){
if (packet.pts >= timeStamp){
int t=avcodec_decode_video2(pCodecCtx, pFrame,
&frameFinished,&packet);
if (frameFinished){
SaveFrame(pFrame, pCodecCtx->width, pCodecCtx-
>height,keyFrames[i]);
break;
}
}
av_free_packet(&packet);
}
}
Can you help me with one of these functions?? Thank you..
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en