[Libav-user] rewind file
Adam Billyard
adambillyard at googlemail.com
Wed Jun 18 15:49:32 CEST 2014
Surely the problem is that AVPacket is buffering B and P frames for you - all of which are referenced to decode video. Those refs are released once they're used, so it will be non-trivial to 'decode again'.
On 18 Jun 2014, at 14:31, Slash <slashpm at gmail.com> wrote:
> Thanks. I have tried it just now but unfortunately it won't enter the second while loop (so it doesn't seem to decode anything for the 2nd time..)
>
> Now I have also tried avformat_seek_file(pFormatCtx, -1, 0, 0, 0, AVSEEK_FLAG_BACKWARD); (correct usage?) and it makes no difference.
>
> Is it maybe the case that once the whole file is decoded, you cannot go back?
>
>
> On 18 June 2014 15:04, Info || Non-Lethal Applications <info at non-lethal-applications.com> wrote:
> I’d say av_seek_frame (or avformat_seek_file) is what you’re after.
>
> av_seek_frame(pFormatContext, -1, 0, AVSEEK_FLAG_BACKWARD);
>
> Best,
>
> Flo
>
> On 18 Jun 2014, at 14:54, Slash <slashpm at gmail.com> wrote:
>
>> Hello,
>>
>> I'm developing a crypto-related application using h264 streams (only video). I'd like to decode the frames multiple times after changing some info in them (dct, mv, whatever), so the decoded result is always different a little bit but I always want to deal with same input file.
>>
>> I followed the tutorial here (tutorial01.c): https://github.com/chelyaev/ffmpeg-tutorial
>>
>> so the decoding code in question looks like this:
>>
>> while (av_read_frame(pFormatCtx, &packet) >= 0) {
>> // Is this a packet from the video stream?
>> if (packet.stream_index == videoStream) {
>> // Decode video frame
>> avcodec_decode_video2(pCodecCtx, pFrame, &frameFinished, &packet);
>> }
>> }
>> // Free the packet that was allocated by av_read_frame
>> av_free_packet(&packet);
>> }
>>
>> After this while loop, all the frames are decoded. What I want is to change something and then redo the previous while loop to decode the frames again. How can I start it all over again?
>>
>> I have tried using av_seek_frame(pFormatCtx, videoStream, 0, AVSEEK_FLAG_ANY) to jump back to the beginning but apparently I didn't get any new decoded data so it is not doing what I need.
>>
>> Thanks for help.
>> _______________________________________________
>> Libav-user mailing list
>> Libav-user at ffmpeg.org
>> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
>
>
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140618/2949a03c/attachment.html>
More information about the Libav-user
mailing list