Video streaming vlc

Материал из ALT Linux Wiki

Сервер ретрансляции:

cvlc http://99.99.99.99:8083/stream.flv --ipv4-timeout=1000  --loop --sout '#duplicate{dst=std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8092/stream.flv},dst="transcode{vcodec=none,acodec=mp4a,ab=96}:std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8093/stream.flv}"}'

Скрипт запуска:

#/usr/sbin/bash
echo "**********************************************************"
echo "Для того, чтобы прекратить трансляцию -- закройте ЭТО окно! "
echo "**********************************************************"

echo "**********************************************************"
echo "Если Вы видите эту надпись, но трансляция не идет"
echo "-- закройте ЭТО окно и запустите трансляцию снова."
echo "**********************************************************"

echo "**********************************************************"
echo "Для проверки трансляции запустите в терминале"
echo "vlc http://127.0.0.1:8081/stream.flv"
echo "**********************************************************"
#echo date() >> use.log
#sleep 30
LD_PRELOAD=/usr/lib/libv4l/v4l1compat.so cvlc --vlm-conf mosaic.vlm

Сам mosaic.vlm для одной камеры:

# Comment the following line if you don't want to reset your VLM configuration
del all

# Background options
new   bg broadcast enabled
setup bg input     "fake://" option "fake-file=background.png"
setup bg output    "#transcode{vcodec=h264,keyint=40,vb=320,width=640,height=480,sfilter=mosaic}:bridge-in{offset=50}:duplicate{dst=std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8081/stream.flv},dst=std{access=file,mux=ffmpeg{mux=flv},dst=stream.flv}}"
  1. Mosaic options

setup bg option mosaic-alpha=255 setup bg option mosaic-height=480 setup bg option mosaic-width=640 setup bg option mosaic-align=1 setup bg option mosaic-xoffset=0 setup bg option mosaic-yoffset=0 setup bg option mosaic-vborder=0 setup bg option mosaic-hborder=0 setup bg option mosaic-position=1 setup bg option mosaic-rows=1 setup bg option mosaic-cols=1 setup bg option mosaic-order=cam1 setup bg option mosaic-delay=0 setup bg option mosaic-keep-picture

  1. Input options

new cam1 broadcast setup cam1 input "v4l2:///dev/video0:width=640:height=480" setup cam1 option v4l2-brightness=115 setup cam1 option no-sout-audio setup cam1 output "#mosaic-bridge{id=cam1},select=video,dst=bridge-out{id=1}}" setup cam1 enabled


new audio broadcast enabled setup audio input alsa://hw:1,0 setup audio output #transcode{acodec=mp4a,samplerate=44100,ab=112}:bridge-out


  1. Launch everything

control audio play control bg play control cam1 play

  1. end of mosaic batch


Для трех камер:

  1. Comment the following line if you don't want to reset your VLM configuration

del all

  1. Background options

new bg broadcast enabled setup bg input "fake://" option "fake-file=background.png" setup bg output "#transcode{vcodec=h264,keyint=40,vb=256, ab=112,fps=12,5,width=960,height=240,sfilter=mosaic}:bridge-in{offset=50}:duplicate{dst=std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:8082/stream.flv},dst=std{access=file,mux=ffmpeg{mux=flv},dst=stream.flv}}"

  1. Mosaic options

setup bg option mosaic-alpha=255 setup bg option mosaic-height=240 setup bg option mosaic-width=960 setup bg option mosaic-align=1 setup bg option mosaic-xoffset=0 setup bg option mosaic-yoffset=0 setup bg option mosaic-vborder=0 setup bg option mosaic-hborder=0 setup bg option mosaic-position=1 setup bg option mosaic-rows=1 setup bg option mosaic-cols=3 setup bg option mosaic-order=cam3,cam2,cam1 setup bg option mosaic-delay=0 setup bg option mosaic-keep-picture

  1. Input options

new cam1 broadcast setup cam1 input "v4l2:///dev/video0:width=320:height=240" setup cam1 option v4l2-brightness=100 setup cam1 option no-sout-audio setup cam1 output "#mosaic-bridge{id=cam1},select=video,dst=bridge-out{id=1}}" setup cam1 enabled

new cam2 broadcast setup cam2 input "v4l2:///dev/video1:width=320:height=240"

  1. setup cam2 option v4l2-brightness=100

setup cam2 option no-sout-audio setup cam2 output "#mosaic-bridge{id=cam2},select=video,dst=bridge-out{id=2}}" setup cam2 enabled

new cam3 broadcast setup cam3 input "v4l2:///dev/video2:width=320:height=240"

  1. setup cam3 option v4l2-brightness=100

setup cam3 option no-sout-audio setup cam3 output "#mosaic-bridge{id=cam3},select=video,dst=bridge-out{id=3}}" setup cam3 enabled

  1. new audio1 broadcast enabled
  2. setup audio1 input alsa://hw:0,0
  3. setup audio1 output #transcode{acodec=mp4a,samplerate=44100,ab=112}:bridge-out

new audio2 broadcast enabled setup audio2 input alsa://hw:0,0 setup audio2 output #transcode{acodec=mp4a,samplerate=44100,ab=96}:bridge-out


  1. Launch everything
  1. control audio1 play

control audio2 play control bg play control cam1 play control cam2 play control cam3 play

  1. end of mosaic batch