oaubert / python-vlc

Python vlc bindings
GNU Lesser General Public License v2.1
382 stars 109 forks source link

Record RTSP stream #172

Open Coday-meric opened 3 years ago

Coday-meric commented 3 years ago

I have been trying for a while to record an RTSP stream with libVLC in python. I have a basic command that works with cvlc, but I am unable to do the same with libVLC.

Here is the cvlc command:

cvlc -I dummy rtsp://admin@192.168.31.56/0/av0 --sout="#transcode{vcodec=h264,acodec=mp3,vb=500,fps=30.0}:std{mux=mp4,dst=test.mp4,access=file}";

Here is where I am with python:

import vlc

rtsp_server = 'rtsp://admin@192.168.31.56/0/av0'
i = vlc.Instance("--sout=#transcode{vcodec=h264,acodec=mp3,vb=500,fps=30.0}:std{mux=mp4,dst=test.mp4,access=file}")
player = i.media_player_new()
player.set_mrl(rtsp_server)
player = vlc.MediaPlayer(rtsp_server)
player.play()
mrJean1 commented 3 years ago

Unable to reproduce the issue ...

import vlc
>>> rtsp = 'rtsp://admin@192.168.31.56/0/av0'
>>> i = vlc.Instance("-sout=#transcode{vcodec=h264,acodec=mp3,vb=500,fps=30.0}:std{mux=mp4,dst=test.mp4,access=file}")
>>> p = i.media_player_new()
>>> p.set_mrl(rtsp)
<vlc.Media object at 0x7fea77332490>
>>> p.play()
0
>>> [00007fea788141b0] live555 demux error: Failed to connect with rtsp://192.168.31.56:554/0/av0
[00007fea7a0144b0] satip stream error: Failed to connect to RTSP server 192.168.31.56:554
[00007fea7a0144b0] access_realrtsp stream error: cannot connect to 192.168.31.56:554
[00007fea7a0144b0] main stream error: Connection failed
[00007fea7a0144b0] main stream error: VLC could not connect to "192.168.31.56:554".
[00007fea77813cf0] main input error: Your input can't be opened
[00007fea77813cf0] main input error: VLC is unable to open the MRL 'rtsp://admin@192.168.31.56/0/av0'. Check the log for details.

One problem is that the rstp link/address is a local, non-routable IP address (198.168...) not existing anywhere else.

Coday-meric commented 3 years ago

Thanks you for your response, just a little question. This programme don't record the video in the requested folder and How run this programme but without a graphical interface.