Skip to content

Instantly share code, notes, and snippets.

@rhee-elten
Last active August 21, 2024 04:59
Show Gist options
  • Save rhee-elten/566be98345a95cad67f053f565462333 to your computer and use it in GitHub Desktop.
Save rhee-elten/566be98345a95cad67f053f565462333 to your computer and use it in GitHub Desktop.
###########################################
# video streaming using gst or vc.txt
# gist: https://gist.github.com/rhee-elten/566be98345a95cad67f053f565462333
###########################################
[gst]
# run-gst-8080-http.bash
set -x
gst-launch-1.0 v4l2src ! \
video/x-raw, width=640, height=480, framerate=20/1 ! \
videocrop top=0 left=160 right=160 bottom=0 ! \
videoconvert ! \
x264enc tune=zerolatency bitrate=2000 speed-preset=ultrafast key-int-max=2 ! \
video/x-h264,profile=main ! \
h264parse config-interval=1 ! \
mpegtsmux ! \
tcpserversink host=0.0.0.0 port=8080
[vlc/linux]
# run-stream-8080-http.bash
set -x
#v4l2-ctl -d /dev/video0 --set-fmt-video=width=640,height=480 && (v4l2-ctl --all | grep "Width/Height")
cvlc -v \
v4l2://:video-dev=/dev/video0:width=640:height=480:fps=20.0 \
--sout="#transcode{vfilter=croppadd{cropleft=160,cropright=160},vcodec=h264,scale=1,vb=2000,acodec=none,venc=x264{profile=main,keyint=2,bframes=2,ref=1,ratetol=1.0}}:std{access=http,dst=:8080/stream.ts,mux=ts,low-delay=1,caching=15}" \
--no-sout-all \
--sout-keep
[vlc/windows]
# run-stream-8080-http.bat
start "VLC" "c:\program files\videolan\vlc\vlc.exe" -vvv --intf=rc ^
dshow:// ^
:dshow-adev="None" ^
:dshow-size="640x480" ^
:dshow-fps="20.0" ^
--sout="#transcode{vfilter=croppadd{cropleft=160,cropright=160},vcodec=h264,scale=1,vb=2000,acodec=none,venc=x264{profile=main,keyint=2,bframes=2,ref=1,ratetol=1.0}}:std{access=http,mux=ts,dst=:8080/stream.ts,low-delay=1,caching=15}" ^
--no-sout-all ^
--sout-keep
[vlc/windows]
# run-stream-9090-http.bat
start "VLC" "c:\program files\videolan\vlc\vlc.exe" -vvv --intf=rc ^
resources\7.mp4 ^
resources\6.mp4 ^
resources\4.mp4 ^
resources\1.mp4 ^
--loop ^
--video-filter="croppadd{cropbottom=100}" ^
--sout="#transcode{vfilter=croppadd{cropbottom=60},vcodec=h264,scale=1,vb=2000,acodec=none,venc=x264{profile=main,keyint=2,bframes=2,ref=1,ratetol=1.0}}:std{access=http,mux=ts,dst=:9090/stream.ts,low-delay=1,caching=15}" ^
--no-sout-all ^
--sout-keep
[vlc/windows/rtsp]
# run-stream-8554-rtsp.bat
start "VLC" "c:\program files\videolan\vlc\vlc.exe" -vvv --intf=rc ^
dshow:// ^
--dshow-size="640x480" ^
--dshow-fps="30.0" ^
--sub-source="marq{marquee=%%H:%%M:%%S,position=4}" ^
--sout="#duplicate{dst=transcode{sfilter=marq{marquee=%%H:%%M:%%S,position=4},vcodec=h264,scale=1,vb=2000,acodec=none,venc=x264{keyint=50,ref=1,ratetol=1.0}}}:rtp{sdp=rtsp://:8554/out.h264}" ^
--no-sout-all ^
--sout-keep
[v4l2-ctl/set resolution/format]
v4l2-ctl
v4l2-ctl -d /dev/video0 --list-formats-ext
v4l2-ctl --all -d /dev/video0
v4l2-ctl --list-devices
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment