VLC save stream to file

I was just stuck in creating a batch file to record a stream from CCTV. Previously, this worked on a Ubuntu server in code as follows:

cvlc -d --sout "#transcode{vcodec=FLV1,vb=512,fps=3,acodec=none,sfilter=marq{marquee=' %d.%m.%Y %H.%M.%S',opacity=200,size=20}}:std{access=file,mux=ffmpeg{mux=flv},dst=/storage/surveillance/$date/${name[$i]}/$curdate.flv}" --ttl=127 "http:// cameralogin@camerapassword @cam_ip/cgi-bin/cmd/encoder?&${analog[$i]}&GET_STREAM" --http-reconnect --http-continuous --sout-mux-caching=1500 --udp-caching=6000 --tcp-caching=6000 

I got an HTTP stream from the camera in MJPG, which I can open from cmd using this

 vlc.exe "http:// cameralogin@camerapassword @cam_ip/cgi-bin/cmd/encoder?&$CHANNEL=1&GET_STREAM" 

But I am stuck when I try to save it to a file, adding this to the previous command:

 --sout "#transcode{vcodec=FLV1,vb=512,fps=3,acodec=none,sfilter=marq{marquee=' %date% %time%',opacity=200,size=20}}:std{access=file,mux=ffmpeg{mux=flv},dst=%archive%\%name%\%date%\%time%.flv}" 

VLC opens, but there is no output video and file in the path. Drive F is a local hard drive, login and password are directly to the camera. The package is opened from the local administrator.

The full file is as follows:

 :: Set encoding for cyrillyc symvols @chcp 866 :: Some vars for easy edit in future :: Choosing cam :: set analog=CHANNEL=1 set analog=CHANNEL=2 :: set analog=CHANNEL=3 :: set analog=CHANNEL=4 :: Choose folder to save :: set name="2 " set name="1 " :: set name="_" :: set name="1  2" :: Path to archive set archive="F:\Archive\" :: Move to vlc.exe folder cd "c:\Program Files (x86)\VideoLAN\VLC" :: Record Video vlc.exe --sout "#transcode{vcodec=FLV1,vb=512,fps=3,acodec=none,sfilter=marq{marquee=' %date% %time%',opacity=200,size=20}}:std{access=file,mux=ffmpeg{mux=flv},dst=%archive%\%name%\%date%\%time%.flv}" --ttl=127 "http:// cameralogin@camerapassword @cam_ip/cgi-bin/cmd/encoder?&$%analog%&GET_STREAM" --http-reconnect --http-continuous --sout-mux-caching=1500 --udp-caching=6000 --tcp-caching=6000 
+5
source share
1 answer

Your VLC command is incorrect: it must be in the format "initial capture - transcode", and not vice versa. Pls follow Streaming examples of HowTo / Command Line , see Also FLV Support . In addition, the output of the command depends on the version of VLC used. The old version of VLC2.2.2 may work better with Cmd and allows you to use the VLM configuration file without output errors.

As a rule, before trying to start VLC from a package, try using the same transcoding options in Windows via the VLC GUI and see if the output can be captured and transcoded correctly and what the CPU load will be. Below are examples of transcode , more here . Consider transcoding to H264 or later codecs for a smaller file size.

In the case of high CPU utilization, as an alternative, try the latest version of FFMpeg Zeranoe for Windows due to the frequent decrease in processor load and improving the quality of transcoding compare with VLC. Browse their forum for the right example recoding commands. Note. VLC also uses the FFMPEG package, but an older version. Windows FFMPEG uses DirectShow to capture the input of a USB webcam, so typical commands are different from Linux versions, but may look similar to IPCams.

For your specific IPCam model, a very basic batch batch stream launched from the FFMPEG \ bin folder might look like this (untested, but works for my IPCam model with a modified URL string):

 @echo off ffmpeg -f mjpeg -i ^ "http://login: password@cam _ip/cgi-bin/cmd/encoder?&$CHANNEL=1&GET_STREAM" ^ -vcodec flv -q:v 1 -an K:\Videos\output.flv exit /b 

Another typical example of an IPCam Foscam MJPEG capture command:

 ffmpeg -f mjpeg -i "http://Cam_IP:8080/videostream.cgi?user=[login]&pwd=[password]" ^ -vcodec flv -q:v 1 -an K:\Videos\output.flv 

Check the Internet Connection Database to correctly record URLs depending on your IPCam model. See Also Transcoding MJPEG to FLV or MP4 .

+1
source

Source: https://habr.com/ru/post/1246541/


All Articles