Skip to content

Instantly share code, notes, and snippets.

@widgetii
Created February 17, 2020 10:42
Show Gist options
  • Save widgetii/ec275524dd621cd55774c952bee4c622 to your computer and use it in GitHub Desktop.
Save widgetii/ec275524dd621cd55774c952bee4c622 to your computer and use it in GitHub Desktop.
#!/bin/sh
[ $# -eq 0 ] && { echo "Usage: $0 TOKEN rtsp://... <name>"; exit 1; }
TOKEN="$1"
SOURCE="$2"
NAME=${3:-cctv}
#ARCHIVE=${ARCHIVE:-archive}
HLS_TIME=${HLS_TIME:-5}
HLS_LIST_SIZE=${HLS_LIST_SIZE:-5}
ffmpeg -i "$SOURCE" \
-stream_loop -1 \
-i 10SecSilence.aac \
-f hls \
-vsync 0 -copyts -vcodec copy -acodec copy \
-movflags frag_keyframe+empty_moov \
-hls_flags delete_segments+append_list \
-hls_time $HLS_TIME \
-hls_list_size $HLS_LIST_SIZE \
-method PUT \
"https://a.upload.youtube.com/http_upload_hls?cid=${TOKEN}&copy=0&file=index.m3u8"
# append this to also enable archiving
# \
# -f segment \
# -segment_time 300 \
# -segment_atclocktime 1 \
# -strftime 1 \
# -vcodec copy -acodec copy \
# -map 0 \
# "$ARCHIVE/$NAME-%F-%H-%M-%S.mp4"
@widgetii
Copy link
Author

widgetii commented Jun 5, 2020

to build ffmpeg use:

./configure \
  --enable-cross-compile --cross-prefix=${CROSS_TOOLS} --arch=arm \
  --target-os=linux \
  --disable-iconv \
  --disable-swresample \
  --disable-avdevice \
  --disable-filters \
  --disable-swscale --disable-ffprobe \
  --enable-small \
  --disable-muxers --enable-muxer=hls \
  --disable-demuxers \
  --enable-demuxer=aac,h265 \
  --enable-demuxer=rtp,rtsp,sdp \
  --disable-parsers --enable-parser=h265,aac,hls \
  --disable-decoders --enable-decoder=h265,aac,hls \
  --disable-encoders \
  --disable-protocols --enable-protocol=http,https,rtp,rtsp,file \
  --enable-mbedtls --enable-version3 \
  --extra-cflags="-I$HOME/git/mbedtls/mbedtls-2.16.6/_install/include" --extra-ldflags="-L$HOME/git/mbedtls/mbedtls-2.16.6/_install/lib" \
  --disable-bsfs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment