Skip to content

Commit 882ec93

Browse files
committed
feat: allow specifying extra ffmpeg args, mainly for hev1 -> hvc1
1 parent de966e6 commit 882ec93

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ type Input struct {
4141
// URL is the connection string for this stream, like "rtsp://user:pass@host:1234/path/here?parameters=sample"
4242
URL string `json:"url"`
4343

44+
// ExtraFFMPEGArgs passed after each `-f {format}` section.
45+
// As an example, specify `"extra_ffmpeg_args": "-tag:v hvc1"` to make your hev1 cameras playable on iOS
46+
ExtraFFMPEGArgs string `json:"extra_ffmpeg_args"`
47+
4448
// RecordingAgeLimitHours is the amount of hours of recordings to keep.
4549
// If 0, disabled.
4650
// If 1, keep recordings from the last 60 minutes.
@@ -934,6 +938,7 @@ func record(ctx context.Context, stream *Stream) {
934938
cmd.Env,
935939
"RTSP_SOURCE="+stream.Input.URL,
936940
"RTSP_NAME="+stream.Input.ID,
941+
"RTSP_EXTRA_ARGS="+stream.Input.ExtraFFMPEGArgs,
937942
)
938943
// ffmpeg is writing all output to stderr for me
939944
cmd.Stderr = &OpeningForWritingWriter{

rtsp-to-hls.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ SOURCE="$RTSP_SOURCE"
1212
# some reasonably-unique name
1313
NAME=${RTSP_NAME:-cctv}
1414

15+
EXTRA_ARGS=${RTSP_EXTRA_ARGS:-}
16+
1517
# ffmpeg doesn't autocreate directories
1618
mkdir -p "media/$NAME/stream/segments" # stream directory is 100% temporary and can be removed for cleaning
1719
mkdir -p "media/$NAME/archive" # archive directory is more permanent, should only remove old files
@@ -33,7 +35,7 @@ ffmpeg -loglevel level \
3335
-rtsp_transport tcp \
3436
-re \
3537
-i "$SOURCE" \
36-
-f hls \
38+
-f hls $EXTRA_ARGS \
3739
-fps_mode passthrough \
3840
-copyts -vcodec copy -acodec copy \
3941
-movflags frag_keyframe+empty_moov \
@@ -45,7 +47,7 @@ ffmpeg -loglevel level \
4547
-strftime 1 \
4648
-hls_segment_filename "media/$NAME/stream/segments/$NAME-%06d-%F-%H-%M-%S.ts" \
4749
"media/$NAME/stream/$NAME.m3u8" \
48-
-f segment \
50+
-f segment $EXTRA_ARGS \
4951
-segment_time $SEGMENT_TIME \
5052
-segment_atclocktime 1 \
5153
-segment_wrap $SEGMENT_WRAP \

0 commit comments

Comments
 (0)