Page 1 of 1

script for extracting fragment of a video

Posted: 16 Mar 2011 00:18
by pbergon
Dear all,

I´m sorry but I´ve just registered in the forum and it´s the first time I´m trying to develop a script with VLC.

For my degree project i need a script to extract a fragment of a video. The script would have as input the video and the time of beginning and ending of the fragment to extract. For instance as an input: (video.flv, beginning time: 0:25, ending time: 0:56)

Can anybody help me with a piece of useful information, some code would be perfect ;)?

I would be very very grateful.

Regards

Re: script for extracting fragment of a video

Posted: 16 Mar 2011 09:54
by pbergon
I´ve been reading the forum and i´ve not seen posts about how to extract video segments automatically with a script.

Please, please, can anybody give me some example code or some information about how to do that.

It is very important

Thank you all very very much.

Re: script for extracting fragment of a video

Posted: 16 Mar 2011 15:49
by mario123
Hi,

You can try something like this:
vlc "d:\source.avi" :start-time=140 :stop-time=160 :sout=#transcode{vcodec=h264}:file{dst=dest.mp4} vlc://quit

It starts your vlc player, starts playing source.avi from position 140 (seconds) until position 160 (seconds), dumps it in a file dest.mp4 and closes the vlc player.

Re: script for extracting fragment of a video

Posted: 16 Mar 2011 16:56
by pbergon
Hi Mario,

thank you very very much for your answer.

I´m sorry but I´m not sure about how using your code. I´m on my first steps with VLC and I still don´t know very well how it works... I think it is a command line to introduce in the console, but what I really need is a script. I´m working with Windows.

I mean, the situation would be:

I received a petition with some parameters (the video source, start-time and stop-time). My script generates the code with these parameters (similar to your code line) and finally returns the new file.

Could you help me a little more :)? Maybe a dummies handbook?

You can´t imagine how helpful would it be...

Re: script for extracting fragment of a video

Posted: 17 Mar 2011 08:33
by mario123
Hi pbergon.

I don't write scripts myself, I use VLC in C# and C++ programs. So I can't present you a working script. But I suppose you use the same activeX API like I do. And yes, my previous example is a command line. But you can use command line parameters with the vlc.playlist.add() function (use the option parameter of this function) or the setVariable() function in the old version of the VLC plugin. I tested the command line example, it works for me. I did not test it with the vlc.playlist.add() function. So I don't know that it works but in your case, I would try something like that.