Skip to content

Instantly share code, notes, and snippets.

@mauron85
Last active December 9, 2019 22:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mauron85/8e00ddf090b59da712c6298c24c21ca4 to your computer and use it in GitHub Desktop.
Save mauron85/8e00ddf090b59da712c6298c24c21ca4 to your computer and use it in GitHub Desktop.
Create multicast stream of two ip camera streams side-by-side
#!/bin/bash
#Watch multicast stream of two ip camera streams side-by-side in IINA player
url="udp://239.0.0.1:1234?ttl=13&pkt_size=1317"
ffmpeg -loglevel panic -re \
-i "rtmp://camera1.lan/bcs/channel0_ext.bcs?channel=0&stream=2&user=guest&password=guest123" \
-i "rtmp://camera2.lan/bcs/channel0_ext.bcs?channel=0&stream=2&user=guest&password=guest123" \
-filter_complex "nullsrc=size=1280x480 [base]; \
[0:v] setpts=PTS-STARTPTS, scale=640x480 [upperleft]; \
[1:v] setpts=PTS-STARTPTS, scale=640x480 [upperright]; \
[base][upperleft] overlay=shortest=0 [tmp1]; \
[tmp1][upperright] overlay=shortest=0:x=640" \
-s 1280x480 -vcodec libx264 -preset fast -crf 20 \
`#-x264opts keyint=50:bframes=0:ratetol=1.0:ref=1` \
`#-tune zerolatency -g 50 -r 25` \
-profile baseline \
-b:v 1M -minrate:v 1M -maxrate:v 1M -bufsize:v 3M \
-an -f mpegts "$url" &
pid=$!
/Applications/IINA.app/Contents/MacOS/iina-cli --keep-running $url
kill $pid
#Create mosaic of two camera streams side-by-side
ffmpeg -re -i "rtmp://camera1.lan/bcs/channel0_ext.bcs?channel=0&stream=2&user=guest&password=guest123" \
-i "rtmp://camera2.lan/bcs/channel0_ext.bcs?channel=0&stream=2&user=guest&password=guest123" \
-filter_complex "nullsrc=size=1280x480 [base]; \
[0:v] setpts=PTS-STARTPTS, scale=640x480 [upperleft]; \
[1:v] setpts=PTS-STARTPTS, scale=640x480 [upperright]; \
[base][upperleft] overlay=shortest=0 [tmp1]; \
[tmp1][upperright] overlay=shortest=0:x=640" \
-s 1280x480 -vcodec libx264 -preset fast -crf 20 \
`#-x264opts keyint=50:bframes=0:ratetol=1.0:ref=1` \
`#-tune zerolatency -g 50 -r 25` \
-profile baseline \
-b:v 1M -minrate:v 1M -maxrate:v 1M -bufsize:v 3M \
-an -f mpegts "udp://239.0.0.1:1234?ttl=13&pkt_size=1316"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment