2

I am trying to create any sort of command in python or shell to pull one specific frame from a video that is being played or streamed on vlc.

Imagine a scenario where I have a video file, I open it on VLC and I click play. I pull the first frame I encounter in python or using a shell command, do some processing, and when the processing is done, I capture another frame at the exact time that the video has reached.

Honestly, if I can even get VLC to provide for me the current "time" of a video I am playing (how many hours:minutes:seconds or whatever we have gone through in the movie), that would do and I can use ffmpeg.

I am running linux 14.04.

closed as unclear what you're asking by DrZoo, Burgi, DrMoishe Pippik, G-Man, Mike Fitzpatrick Oct 28 '17 at 1:03

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.

2

if I can even get VLC to provide for me the current "time" of a video I am playing…

This can be done. VLC provides many interfaces. Let's use telnet.


Step 1: enabling telnet in VLC

One-time on-demand method:

vlc --extraintf telnet --telnet-port 4212 --telnet-password "foobar" video_file_to_play.avi

Or permanent configuration. Run VLC, Tools -> Preferences (or Ctrl+P), then:

config1

and

config2

Note: this permanent method requires you to restart VLC.


Step 2: testing

Now you can control VLC with telnet. Type the right password when prompted. Example:

$ telnet localhost 4212
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
VLC media player 2.2.2 Weatherwax
Password: 
Welcome, Master
> get_time
30
>

As you can see, the command to retrieve current playing time is get_time. Type help to learn more VLC commands, quit to quit. Maybe you will find snapshot useful.


Step 3: using in a script

Quite a simple pipe. Here I use nc instead of telnet (and foobar is my password, use yours):

printf '%s\n' "foobar" "get_time" | nc localhost 4212

My VLC returns:

VLC media player 2.2.2 Weatherwax
Password: ����
Welcome, Master
87
> Bye-bye!

so I use head and tail to extract the relevant line only:

printf '%s\n' "foobar" "get_time" | nc localhost 4212 | head -n 4 | tail -n 1

Unfortunately the time resolution is 1 second. I haven't found a command to retrieve the current frame number or so.

Not the answer you're looking for? Browse other questions tagged or ask your own question.