upload the recorded files into the remote endpoint
This commit is contained in:
parent
5f0622c2f3
commit
2d18130103
1 changed files with 26 additions and 8 deletions
34
stream.sh
34
stream.sh
|
@ -5,14 +5,33 @@ source config
|
|||
SCAN_COUNT=0
|
||||
SCAN_ATTEMPTS=3
|
||||
FFMPEG_LOGLEVEL="repeat+level+info"
|
||||
REC_PATH="./rec/"
|
||||
|
||||
mkdir -p ./rec/
|
||||
###
|
||||
|
||||
mkdir -v -p $REC_PATH
|
||||
|
||||
cleanup() {
|
||||
adb_pid=$(ps aux | grep 'adb' | grep ${android} | awk '{print $2}');
|
||||
echo "] Killing adb services with pid=${adb_pid}"
|
||||
kill -9 ${adb_pid}
|
||||
exit
|
||||
# Terminate the adb services
|
||||
adb_pid=$(ps aux | grep 'adb' | grep ${android} | awk '{print $2}');
|
||||
echo "] Killing adb services with pid=${adb_pid}"
|
||||
kill -9 ${adb_pid}
|
||||
|
||||
# Scan for recorded files
|
||||
if [ $(find ${REC_PATH} -type f | wc -l) -eq 0 ] ; then
|
||||
echo ] No files to upload.
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Upload the recorded files
|
||||
echo "] Uploading streaming session ffff..."
|
||||
find ${REC_PATH} -type f -name '*.mp4' -print0 | while IFS= read -r -d '' file; do
|
||||
vodname=$(basename "$file")
|
||||
vod="$REC_PATH/$vodname"
|
||||
echo "] Uploading VOD $vod to ${vod_output} ..."
|
||||
curl -i -X POST -H "Authorization: Bearer ${vod_token}" -F "file=@rec/${vod}" ${vod_output}
|
||||
done
|
||||
exit
|
||||
}
|
||||
|
||||
# Trap interrupts and exit instead of continuing the loop
|
||||
|
@ -56,7 +75,6 @@ until is_correct_port || [[ $SCAN_COUNT -eq $SCAN_ATTEMPTS ]]; do
|
|||
done
|
||||
[[ $SCAN_COUNT -eq $SCAN_ATTEMPTS ]] && echo "] could not set the tcpip port :(" && (exit 1)
|
||||
|
||||
|
||||
###
|
||||
|
||||
adb disconnect
|
||||
|
@ -67,6 +85,7 @@ scrcpy -n \
|
|||
--camera-id=2 --camera-size=1920x1080 --camera-fps=30 --orientation=90 \
|
||||
--v4l2-sink=/dev/video5 &
|
||||
|
||||
# Endless loop which streams and record at the same time new file on each reconnect.
|
||||
while :
|
||||
do
|
||||
sleep 5
|
||||
|
@ -89,7 +108,6 @@ do
|
|||
-r:v 30 -g:v 120 -bf:v 3 -refs:v 16 \
|
||||
-f tee -map 0:0 -map 1:0 "[f=mpegts]${srt_output}|[f=mp4]rec/local_recording_${CURRENTDATE}.mp4"
|
||||
|
||||
#CURRENTDATE=`date +"%Y_%m_%d_%H_%M_%S"`
|
||||
echo "] ffmpeg end at ${CURRENTDATE}"
|
||||
echo "] Streaming finished. Sleeping 5 seconds and restarting stream. Ctrl+C to exit."
|
||||
done
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue