简体   繁体   中英

Send seek command to running ffmpeg instance

I have created a video player using the ffmpeg libraries, but want to know if the same is possible using ffmpeg.exe and piping, specifically the seeking part. Is it possible to send seek command to a running ffmpeg.exe instance? Such a command is not present in the help but it does show the 'c' command which can be used to send commands to filters. I cannot find any further documentation however on how to address filters this way, all examples assuming command line parameters, nor if a filter can be used to seek in video.

Actually a seek command is kind of documented in the ffmpeg documentation :

Both movie and amovie support the following commands:

  • seek Perform seek using "av_seek_frame". The syntax is: seek stream_index|timestamp|flags

    • stream_index : If stream_index is -1, a default stream is selected, and timestamp is automatically converted from AV_TIME_BASE units to the stream specific time_base.
    • timestamp : Timestamp in AVStream.time_base units or, if no stream is specified, in AV_TIME_BASE units.
    • flags : Flags which select direction and seeking mode.
  • get_duration Get movie duration in AV_TIME_BASE units.

I have tried running a command like this:

ffmpeg -f lavfi -i 'movie=filename=myvid.mp4' -codec:v libx264 -an -f mpegts - > /dev/null

Then I press c and enter the command all -1 seek 0|3|0 , but no matter which combination I try, I get back the same error Command reply for stream 0: ret:-78 res:

I've also tried this command, but it gives the same error when trying to seek:

ffmpeg -i myvid.mp4 -codec:v libx264 -an -f mpegts - > /dev/null

There is very little information about the seek operation on the internet, but I managed to find this: http://ffmpeg.org/pipermail/ffmpeg-devel/2013-September/148070.html

Here he says that:

the "lavfi" demuxer has its own private filtergraph and provides no means (that i know of) to inject command from the outside of this filtergraph into it.

So all this indicates that may or may not be possible to seek on a running ffmpeg instance. At least those who may have succeeded with it have kept how to do it to themselves.

for those who want to send a filter argument

first as in docs to get a particular filter commands do :

ffmpeg -h filter=filtername

Note : only commands marked with T will work at runtime .

next press c then :

all -1 your_command value

If you hit a '?' while ffmpeg is running, you'll get all available options.

As of my locally installed version:

key    function
?      show this help
+      increase verbosity
-      decrease verbosity
c      Send command to first matching filter supporting it
C      Send/Que command to all matching filters
D      cycle through available debug modes
h      dump packets/hex press to cycle through the 3 states
q      quit
s      Show QP histogram

so basically, no.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM