Search code examples
ffmpegvideo-streamingdecodeencode

Can ffmpeg seek when using an input stream (or url)?


I've been using ffmpeg quite a lot in the past few weeks, and recently I've encountered a very annoying issue - when I use ffmpeg with an input stream (usually, just a url as the input) and try to set a start time (with -ss option), I always get a warn message that says "could not seek to position: XXX".

Then, ffmpeg just starts to download the file, and it ouputs nothing until it has downloaded enough data and got to my desired start time.

I'll give an example:

I use this command to execute ffmpeg:

ffmpeg -ss 50 -re -i https://ascent.usbank.com/acp/videos/041114ascent.flv -b:a 128k -ac 2 -acodec libvorbis -b:v 1024k -vcodec libtheora -strict 2 -preset ultrafast -tune zerolatency -pix_fmt yuv420p -f ogg pipe:1

and I get the warn message

https://ascent.usbank.com/acp/videos/041114ascent.flv: could not seek to position 50.000

Then, it takes about 30 seconds until ffmpeg starts to output data to stdout. And when I try this with longer videos (and longer seek times), it takes even longer.

My question is, what can I do? I guess it's impossible for ffmpeg to seek when it haven't got the whole input stream... Am I wrong? Or is there any other solution?

Of course I try to avoid downloading the entire file from the web...

Thanks in advance!

Roee.


Solution

  • I guess you can't do really anything about it other than to buffer the FLV locally and (eventually) seek that.

    Whether or not a http resource allows seeking largely depends on the capabilities of the server, unfortunately...