Skip to content

Instantly share code, notes, and snippets.

@dvliman
Created April 3, 2022 22:17
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 dvliman/e604c2981bfb691803d84bd0b4858e39 to your computer and use it in GitHub Desktop.
Save dvliman/e604c2981bfb691803d84bd0b4858e39 to your computer and use it in GitHub Desktop.
(defn start-stream []
(record :encoder :connect-to-camera (make-event-details ...))
(manager/register :connect-to-camera
(sh/proc "ffmpeg" "-hide_banner" "-re" "-rtsp_transport" "tcp" "-i"
config/encoder-rtsp-endpoint
"-c:a" "aac" "-ar" "48000" "-b:a" "128k"
"-c:v" "h264" "-profile:v" "high"
"-g" "48" "-keyint_min" "48" "-sc_threshold" "0" "-b:v" "3072k"
"-maxrate" "3500k" "-vcodec" "libx264" "-bufsize" "3072k"
"-hls_time" "6"
"-hls_playlist_type" "event"
"-hls_segment_filename" segment-file-pattern
manifest-file-path))
(redirect-stdout-stderr :connect-to-camera hls-file-path)
;; it takes some time to pull from the RTSP stream and write to the m3u8 file
;; the HLS egress looks at the m3u8 file; if it can't find it, the process will exit - so wait for the file
(record :encoder :wait-for-manifest-file (make-event-details ...))
(record :encoder :egress (make-event-details ...))
(manager/register :egress
(sh/proc "ffmpeg" "-hide_banner" "-re" "-i" manifest-file-path
"-c:v" "copy" "-c:a" "aac" "-ar" "48000" "-b:a" "128k" "-f" "flv"
config/encoder-ingress-endpoint))
(redirect-stdout-stderr :egress egress-file-path))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment