Compare commits

..

No commits in common. "2d1813010387e8ca845920e0054f34e5419c3e14" and "fa300b030f1c059e3f4ed0d3600886f18d1ead6c" have entirely different histories.

2 changed files with 14 additions and 29 deletions

View file

@ -1,7 +1,10 @@
# videostreamer # videostreamer
### setup apps ### setup ffmpeg
`sudo apt install scrcpy ffmpeg curl` `sudo apt install ffmpeg`
### setup scrcpy
`sudo apt install scrcpy`
### setup v4l2 loopback ### setup v4l2 loopback
`sudo apt install v4l2loopback-dkms v4l2loopback-utils` `sudo apt install v4l2loopback-dkms v4l2loopback-utils`

View file

@ -5,33 +5,14 @@ source config
SCAN_COUNT=0 SCAN_COUNT=0
SCAN_ATTEMPTS=3 SCAN_ATTEMPTS=3
FFMPEG_LOGLEVEL="repeat+level+info" FFMPEG_LOGLEVEL="repeat+level+info"
REC_PATH="./rec/"
### mkdir -p ./rec/
mkdir -v -p $REC_PATH
cleanup() { cleanup() {
# Terminate the adb services adb_pid=$(ps aux | grep 'adb' | grep ${android} | awk '{print $2}');
adb_pid=$(ps aux | grep 'adb' | grep ${android} | awk '{print $2}'); echo "] Killing adb services with pid=${adb_pid}"
echo "] Killing adb services with pid=${adb_pid}" kill -9 ${adb_pid}
kill -9 ${adb_pid} exit
# 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 # Trap interrupts and exit instead of continuing the loop
@ -75,6 +56,7 @@ until is_correct_port || [[ $SCAN_COUNT -eq $SCAN_ATTEMPTS ]]; do
done done
[[ $SCAN_COUNT -eq $SCAN_ATTEMPTS ]] && echo "] could not set the tcpip port :(" && (exit 1) [[ $SCAN_COUNT -eq $SCAN_ATTEMPTS ]] && echo "] could not set the tcpip port :(" && (exit 1)
### ###
adb disconnect adb disconnect
@ -85,11 +67,10 @@ scrcpy -n \
--camera-id=2 --camera-size=1920x1080 --camera-fps=30 --orientation=90 \ --camera-id=2 --camera-size=1920x1080 --camera-fps=30 --orientation=90 \
--v4l2-sink=/dev/video5 & --v4l2-sink=/dev/video5 &
# Endless loop which streams and record at the same time new file on each reconnect.
while : while :
do do
sleep 5 sleep 5
CURRENTDATE=`date +"%Y_%m_%d_%H_%M_%S"` CURRENTDATE=`date +"%Y_%m_%d_%T"`
echo "] ffmpeg start at ${CURRENTDATE}" echo "] ffmpeg start at ${CURRENTDATE}"
#calf plugins #calf plugins
@ -108,6 +89,7 @@ do
-r:v 30 -g:v 120 -bf:v 3 -refs:v 16 \ -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" -f tee -map 0:0 -map 1:0 "[f=mpegts]${srt_output}|[f=mp4]rec/local_recording_${CURRENTDATE}.mp4"
echo "] Streaming finished. Sleeping 5 seconds and restarting stream. Ctrl+C to exit." #CURRENTDATE=`date +"%Y_%m_%d_%T"`
echo "] ffmpeg end at ${CURRENTDATE}"
done done