Message ID | 75acde42-0192-4baa-41dc-2956ab6d3993@gyani.pro |
---|---|
State | Accepted |
Headers | show |
On 04-09-2019 03:47 PM, Gyan wrote: > > > On 02-09-2019 09:24 PM, Michael Niedermayer wrote: >> On Sat, Aug 31, 2019 at 08:28:51PM +0530, Gyan wrote: >>> A user observed that stream_loop didn't work with very short FLV files. >>> seek_to_start in ffmpeg.c calls av_seek_frame with no flags; FLV >>> seek only >>> works with RTMP protocol so lavf falls back on seek_frame_generic which >>> searches forward, skipping a GOP. With files with two index entries in >>> stream, the file doesn't loop at all. >>> >>> I switched to avformat_seek_file which will set the BACKWARDS flag when >>> seeking to start of file. stream_loop works and no frames are dropped. >>> >>> FATE passes. >>> >>> Gyan >>> ffmpeg.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> c79dc6d27a9c8c1bd0cffa2d251b2aa7caf23bf3 >>> 0001-ffmpeg-switch-to-avformat_seek_file-for-stream_loop.patch >>> From 4af64f612c65378f0a220284ca99ad033ece8cd3 Mon Sep 17 00:00:00 2001 >>> From: Gyan Doshi <ffmpeg@gyani.pro> >>> Date: Sat, 31 Aug 2019 19:45:58 +0530 >>> Subject: [PATCH] ffmpeg: switch to avformat_seek_file for stream_loop >>> >>> Fixes stream_loop with very short files where seeking is generic index >>> search >>> --- >>> fftools/ffmpeg.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >> probably ok >> >> it also might make sense to add the testcase to fate as you mentioned >> "short" >> > > New patches attached. Will send file to samples-request. Test sample uploaded. Plan to push tonight. Gyan
On Wed, Sep 04, 2019 at 03:47:50PM +0530, Gyan wrote: > > > On 02-09-2019 09:24 PM, Michael Niedermayer wrote: > >On Sat, Aug 31, 2019 at 08:28:51PM +0530, Gyan wrote: > >>A user observed that stream_loop didn't work with very short FLV files. > >>seek_to_start in ffmpeg.c calls av_seek_frame with no flags; FLV seek only > >>works with RTMP protocol so lavf falls back on seek_frame_generic which > >>searches forward, skipping a GOP. With files with two index entries in > >>stream, the file doesn't loop at all. > >> > >>I switched to avformat_seek_file which will set the BACKWARDS flag when > >>seeking to start of file. stream_loop works and no frames are dropped. > >> > >>FATE passes. > >> > >>Gyan > >> ffmpeg.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >>c79dc6d27a9c8c1bd0cffa2d251b2aa7caf23bf3 0001-ffmpeg-switch-to-avformat_seek_file-for-stream_loop.patch > >> From 4af64f612c65378f0a220284ca99ad033ece8cd3 Mon Sep 17 00:00:00 2001 > >>From: Gyan Doshi <ffmpeg@gyani.pro> > >>Date: Sat, 31 Aug 2019 19:45:58 +0530 > >>Subject: [PATCH] ffmpeg: switch to avformat_seek_file for stream_loop > >> > >>Fixes stream_loop with very short files where seeking is generic index > >>search > >>--- > >> fftools/ffmpeg.c | 2 +- > >> 1 file changed, 1 insertion(+), 1 deletion(-) > >probably ok > > > >it also might make sense to add the testcase to fate as you mentioned "short" > > > > New patches attached. Will send file to samples-request. > > Gyan > ffmpeg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > a05d0f2f099a64aa3d749a6fbd0617c0bf24ab3b 0001-ffmpeg-switch-to-avformat_seek_file-for-stream_loop.patch > From 953c9c11d90aa69121825284d5f6bf0c34793b2d Mon Sep 17 00:00:00 2001 > From: Gyan Doshi <ffmpeg@gyani.pro> > Date: Sat, 31 Aug 2019 19:45:58 +0530 > Subject: [PATCH 1/2] ffmpeg: switch to avformat_seek_file for stream_loop > > Fixes stream_loop with very short files where seeking is generic index > search > --- > fftools/ffmpeg.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Tested on x86 linux 32/64bit, mingw 32/64, qemu mips & arm Thanks [...]
On 05-09-2019 10:50 PM, Michael Niedermayer wrote: > On Wed, Sep 04, 2019 at 03:47:50PM +0530, Gyan wrote: >> >> On 02-09-2019 09:24 PM, Michael Niedermayer wrote: >>> On Sat, Aug 31, 2019 at 08:28:51PM +0530, Gyan wrote: >>>> A user observed that stream_loop didn't work with very short FLV files. >>>> seek_to_start in ffmpeg.c calls av_seek_frame with no flags; FLV seek only >>>> works with RTMP protocol so lavf falls back on seek_frame_generic which >>>> searches forward, skipping a GOP. With files with two index entries in >>>> stream, the file doesn't loop at all. >>>> >>>> I switched to avformat_seek_file which will set the BACKWARDS flag when >>>> seeking to start of file. stream_loop works and no frames are dropped. >>>> >>>> FATE passes. >>>> >>>> Gyan >>>> ffmpeg.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>>> c79dc6d27a9c8c1bd0cffa2d251b2aa7caf23bf3 0001-ffmpeg-switch-to-avformat_seek_file-for-stream_loop.patch >>>> From 4af64f612c65378f0a220284ca99ad033ece8cd3 Mon Sep 17 00:00:00 2001 >>>> From: Gyan Doshi <ffmpeg@gyani.pro> >>>> Date: Sat, 31 Aug 2019 19:45:58 +0530 >>>> Subject: [PATCH] ffmpeg: switch to avformat_seek_file for stream_loop >>>> >>>> Fixes stream_loop with very short files where seeking is generic index >>>> search >>>> --- >>>> fftools/ffmpeg.c | 2 +- >>>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> probably ok >>> >>> it also might make sense to add the testcase to fate as you mentioned "short" >>> >> New patches attached. Will send file to samples-request. >> >> Gyan >> ffmpeg.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> a05d0f2f099a64aa3d749a6fbd0617c0bf24ab3b 0001-ffmpeg-switch-to-avformat_seek_file-for-stream_loop.patch >> From 953c9c11d90aa69121825284d5f6bf0c34793b2d Mon Sep 17 00:00:00 2001 >> From: Gyan Doshi <ffmpeg@gyani.pro> >> Date: Sat, 31 Aug 2019 19:45:58 +0530 >> Subject: [PATCH 1/2] ffmpeg: switch to avformat_seek_file for stream_loop >> >> Fixes stream_loop with very short files where seeking is generic index >> search >> --- >> fftools/ffmpeg.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) > Tested on x86 linux 32/64bit, mingw 32/64, qemu mips & arm Pushed as fa697aa92f5dfebda11d53db971ec4ac6c517008 and 2b66c757d6aa3a9feee4d25b587becd366c868f1 Thanks, Gyan
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 01f04103cf..b6ecb89893 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -4195,7 +4195,7 @@ static int seek_to_start(InputFile *ifile, AVFormatContext *is) int i, ret, has_audio = 0; int64_t duration = 0; - ret = av_seek_frame(is, -1, is->start_time, 0); + ret = avformat_seek_file(is, -1, INT64_MIN, is->start_time, is->start_time, 0); if (ret < 0) return ret;