[Libav-user] rewind file

Info || Non-Lethal Applications info at non-lethal-applications.com
Wed Jun 18 15:04:39 CEST 2014

I’d say av_seek_frame (or avformat_seek_file) is what you’re after.

av_seek_frame(pFormatContext, -1, 0, AVSEEK_FLAG_BACKWARD);



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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://ffmpeg.org/pipermail/libav-user/attachments/20140618/6ce68124/attachment.html>

More information about the Libav-user mailing list