[Libav-user] Looping a stream?

John Regan john at jrjrtech.com
Thu Feb 10 02:13:54 EET 2022

Hi there, I was hoping somebody could offer advice on how to loop a
video with libavformat/libavcodec.

I have a filter graph created, so my core decoding code is basically:

if( (err = av_read_frame(inputCtx, packet)) < 0) {
    if(err != AVERROR_EOF) {
        /* handle errors, return */
    avformat_seek_file(inputCtx,videoStreamIndex, 0, 0, 0, 0));

if(packet.stream_index == videoStreamIndex) {
    if(av_buffersink_get_frame(bufferSinkCrx,frame) >= 0) {
        /* we have a frame */

I'm not sure if there's steps that need to be taken to reset the filter
graph? Like is there a timestamp discontinuity?

It seems like this should work - but I'm missing something, it seems
like the buffersink_get_frame stops producing frames after I reset.

Thank you in advance,

More information about the Libav-user mailing list