Save stream as client via code

*nix specific usage questions
robertbadea
New Cone
New Cone
Posts: 2
Joined: 08 Jun 2016 07:24

Save stream as client via code

Postby robertbadea » 08 Jun 2016 07:41

Hello everyone,

I have a vlc stream server via http on my windows laptop.
I would like to connect to it from linux and save the stream.

Could anyone point me in a direction from which i could do the following? (from the code, not from the interface)

- Save the stream, as it's manageable from interface:
Media -> open network stream -> convert -> source -> http from windows server, destination file : x - start.
(I connected to the stream from code, i just don't know how to tell it that i want to save the stream also)
EDIT: found this in another topic, can anyone confirm it's ok ? vlc link --sout-all --sout="#std{access=file,mux=ts,dst='/tmp/file.ts'}"

- Cut the destination file in splices of X minutes each ( can i do it without disconnecting from stream and reconnecting? )

- change the video output (tools - preferences -> video output). I expect that to be done at creation of instance, but what is the param for it,vout ?

Thank you for any indications.
Robert

kmf31
Cone that earned his stripes
Cone that earned his stripes
Posts: 308
Joined: 11 Mar 2007 21:47

Re: Save stream as client via code

Postby kmf31 » 08 Jun 2016 11:13

Hello everyone,

I have a vlc stream server via http on my windows laptop.
I would like to connect to it from linux and save the stream.

Could anyone point me in a direction from which i could do the following? (from the code, not from the interface)
I suppose you mean "from the command line" and not inside the vlc source code ?
- Save the stream, as it's manageable from interface:
Media -> open network stream -> convert -> source -> http from windows server, destination file : x - start.
(I connected to the stream from code, i just don't know how to tell it that i want to save the stream also)
EDIT: found this in another topic, can anyone confirm it's ok ? vlc link --sout-all --sout="#std{access=file,mux=ts,dst='/tmp/file.ts'}"
Yes this line is okay, i. e. you may need to replace /tmp/file.ts by the proper file location/name and if you want to use the ts-encapsulation (probably indeed the best choice for video streaming). Note in this way there is no parallel showing of the video. If you want the vlc interface to be invisible (no gui) you can add the option "-I dummy".
You can also play with the parameter "--network-caching=..." (default value 300 for 300 ms) and increase it (to 1000 or 2000 or ...) to reduce errors and get more reliable results.
- Cut the destination file in splices of X minutes each
Add to the above command line the parameter "--run-time=X" and also "--no-loop" and "vlc://quit" as last parameter, and write a shell script to call vlc in a loop and be careful to change each time the file name in the shell script (unless you want it be overwritten or appended). Note that in general if the recorded file already exists vlc can either erase it or append to the file (a bit dangerous if the formats do not match well). The choice between the two is somewhere in the preferences.
( can i do it without disconnecting from stream and reconnecting? )
If you do it directly as indicated abvoe you disconnect. However you might program one vlc instance that itself uses the http as input and streams output to udp without interruption and a second instance that reads the udp streaming and records to a file. This involves some modifications to the above command line. If you are careful to use a multicast IP number (e.g. 239.0.0.1 and NOT 127.0.0.1) for the local streaming you may even have an overlap between two records on different files, i.e. two vlc instances can simultaneously record the same udp stream (with 127.0.0.1 only ONE instance can record or view it !!!). In case of multicast you may also start a further vlc instance to view the upd stream directly (to control things etc.).

Possibly there also other solutions which more complicated command lines or using complicated playlists (also using shell-scripts).
- change the video output (tools - preferences -> video output). I expect that to be done at creation of instance, but what is the param for it,vout ?
simply "--vout=..." but you have to figure out what to put exactly, e.g. x11, xvideo or glx or opengl (I am not sure for the precise spelling and for the use with upper or lower case characters). Note that x11 is quite primitive (less efficient). Typical good choice is xvideo or glx/opengl in Linux. In any case this option only applies in case of direct video output (e. g. when viewing your recorded file) but it has no importance for the record command line above since in this case vlc does not show video.

robertbadea
New Cone
New Cone
Posts: 2
Joined: 08 Jun 2016 07:24

Re: Save stream as client via code

Postby robertbadea » 08 Jun 2016 12:20

Hello,

I would like to add something:
I suppose you mean "from the command line" and not inside the vlc source code ?
From the cpp application.
Note in this way there is no parallel showing of the video
At the convert screen i also have a checkable box 'Display the output'. This works and it displays the video while also recording it in a file - as tested from the interface. (If anyone knows the param for this one, that would be great)

Thank you for your answers, they were very helpful.

Regards,
Robert


Return to “VLC media player for Linux and friends Troubleshooting”

Who is online

Users browsing this forum: No registered users and 27 guests