Skip to content

Instantly share code, notes, and snippets.

@wesleytodd
Last active January 10, 2019 19:09
Show Gist options
  • Save wesleytodd/b2d5dbdb8b76bdc67c7f8ef7df56474b to your computer and use it in GitHub Desktop.
Save wesleytodd/b2d5dbdb8b76bdc67c7f8ef7df56474b to your computer and use it in GitHub Desktop.
Record a raspberry pi camera to an hls stream
#!/bin/bash
# record from the camera at 30fps and 24kbps
raspivid -o - -t 0 -fps 30 -b 24000000 -ih -n -pts | \
# pipe to ffmpeg, create a silent audio stream and segment to 10s hls segments
ffmpeg -y -re -f lavfi -i anullsrc=r=11515:cl=mono -thread_queue_size 512 -probesize 10000000 -f h264 -i - \
-acodec aac -strict experimental -c:v copy -f ssegment -segment_time 10 -segment_format mpegts \
-segment_list "seg/test.m3u8" -segment_list_size 720 -segment_list_flags live -segment_list_type m3u8 "seg/%08d.ts"
#!/bin/bash
# record rtsp from the camera at 30fps and 24kbps
raspivid -o - -t 0 -fps 30 -b 24000000 -ih -n -pts | \
# pipe to ffmpeg, create a silent audio stream and segment to 10s hls segments
ffmpeg -y -re -f lavfi -i anullsrc=r=11515:cl=mono -thread_queue_size 512 -probesize 10000000 -f h264 -i - -acodec aac -strict experimental \
-c:v copy \
-f ssegment -g 5 -segment_time 10 -segment_format mpegts -segment_list "seg1/test.m3u8" -segment_list_size 720 -segment_list_flags live -segment_list_type m3u8 "seg1/%08d.ts" \
-f ssegment -vf "scale=480:-1" -b:v 2k -g 5 -segment_time 10 -segment_format mpegts -segment_list "seg2/test.m3u8" -segment_list_size 720 -segment_list_flags live -segment_list_type m3u8 "seg2/%08d.ts"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment