[Libav-user] Looping a stream?

bsenftner at earthlink.net bsenftner at earthlink.net
Thu Feb 10 17:38:44 EET 2022


I've not updated my player to the latest version, but this seek logic has
worked for quite some time, and I expect it to work with the new version:

Github link to surrounding source and player project:
https://github.com/bsenftner/ffvideo/blob/master/ffvideolib_src/ffvideo.cpp

See the FFVideo::ProcessPacker() method. At the top of the function there is
a call to a seek handling function, and in the packet error handling code
near the bottom of the function is the setup for auto-seeking to the
beginning when reaching the end of the stream. 

Same project, a frame manager source with the HandleSeekRequest() method:
https://github.com/bsenftner/ffvideo/blob/master/ffvideolib_src/ffvideo_fram
eMgr.cpp

Basically, seek to the start when reaching the end. This video player has
been used in video security, with that looping code run for weeks at a time
while debugging memory issues in the larger application.

I hope this helps.
-Blake

-----Original Message-----
From: Libav-user <libav-user-bounces at ffmpeg.org> On Behalf Of John Regan via
Libav-user
Sent: Wednesday, February 9, 2022 5:14 PM
To: libav-user at ffmpeg.org
Cc: John Regan <john at jrjrtech.com>
Subject: [Libav-user] Looping a stream?

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));
    avcodec_flush_buffers(codecCtx);
}

if(packet.stream_index == videoStreamIndex) {
    avcodec_send_packet(codecCtx,packet);
    avcodec_receive_frame(codecCtx,tmpFrame);
    av_buffersrc_write_frame(bufferSrcCtx,tmpFrame);
    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,
-John
_______________________________________________
Libav-user mailing list
Libav-user at ffmpeg.org
https://ffmpeg.org/mailman/listinfo/libav-user

To unsubscribe, visit link above, or email libav-user-request at ffmpeg.org
with subject "unsubscribe".



More information about the Libav-user mailing list