IP Camera to Youtube & WebTorrent

Also using FFMpeg and GStreamer pushed a HLS stream to my NGINX webserver. From there it was picked up by the P2P enabled Clappr player and shared among viewers.

A HLS (or DASH) stream is basically a stream chopped into pieces. So you get a file structure on your NGINX server like this:

  • section1.ts
  • section2.ts
  • section3.ts
  • section4.ts
  • section5.ts
  • playlist.m3u8

FFMpeg example

ffmpeg -fflags nobuffer \
 -rtsp_transport tcp \
 -i rtsp://user:password@ip-address-camera:554/Streaming/channels/101 \
 -vsync 0 \
 -copyts \
 -vcodec copy \
 -movflags frag_keyframe+empty_moov \
 -an \
 -hls_flags delete_segments+append_list \
 -f segment \
 -segment_list_flags live \
 -segment_time 5 \
 -segment_list_size 20 \
 -segment_format mpegts \
 -segment_list /path/to/your/webserver/index.m3u8 \
 -segment_list_type m3u8 \
 /path/to/your/webserver/%d.ts

GStreamer example

gst-launch-1.0 -v -e rtspsrc protocols=tcp location=rtsp://user:password@ip-address-camera:554/Streaming/channels/101 latency=3000 ! queue ! rtph264depay ! h264parse config-interval=-1 ! mpegtsmux ! hlssink location=/path/to/your/webserver/%06d.ts playlist-location=/path/to/your/webserver/playlist.m3u8 max-files=30 target-duration=6 playlist-length=20
Pages: 1 2 3 4