2023-10-05 12:04:14 +00:00
|
|
|
#!/bin/bash
|
2023-12-30 23:03:08 +00:00
|
|
|
__usage="Usage: $(basename $0) FILE [ssh alias]
|
|
|
|
Options:
|
|
|
|
[FILE], Input video file
|
|
|
|
[ssh alias], The alias setup in ~/.ssh/config (default location)
|
|
|
|
See: ssh_config(5)
|
|
|
|
-d, Delete origional file
|
|
|
|
Notes:
|
|
|
|
The file will be copied to the remote computer and then the new file movied to the local computer.
|
|
|
|
This can use lots of bandwidth. Plan accordingly.
|
|
|
|
"
|
2023-08-14 10:04:50 +00:00
|
|
|
|
|
|
|
if [[ -z $1 ]];
|
|
|
|
then
|
2023-12-30 23:03:08 +00:00
|
|
|
echo "$__usage"
|
2023-08-14 10:04:50 +00:00
|
|
|
echo "Pass the file to encode as the first argument."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z $2 ]];
|
|
|
|
then
|
2023-12-30 23:03:08 +00:00
|
|
|
echo "$__usage"
|
2023-08-14 10:04:50 +00:00
|
|
|
echo "Pass the ssh alias of the remote device as the second argument."
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
|
2023-12-30 23:03:08 +00:00
|
|
|
FILE=$1
|
2023-12-30 23:30:57 +00:00
|
|
|
BASE=$(basename "$FILE")
|
2023-12-30 23:03:08 +00:00
|
|
|
OTHER=$2
|
|
|
|
EXTENSION=".new.mp4"
|
2023-12-30 23:30:57 +00:00
|
|
|
TEMP="/tmp/" # don't put in a dir with spaces
|
2023-12-30 23:03:08 +00:00
|
|
|
|
2023-08-14 10:04:50 +00:00
|
|
|
# move file to other's temp drive
|
2023-12-30 23:30:57 +00:00
|
|
|
scp "$FILE" $OTHER:$TEMP
|
2023-08-14 10:04:50 +00:00
|
|
|
# use ffmpeg to encode on other computer
|
2023-12-30 23:30:57 +00:00
|
|
|
ssh $OTHER "ffmpeg -y -i $TEMP\"$BASE\" -vcodec hevc -filter:v scale=-2:720 $TEMP\"$BASE\"$EXTENSION"
|
2023-08-14 10:04:50 +00:00
|
|
|
# move file back
|
2023-12-30 23:30:57 +00:00
|
|
|
scp $OTHER:$TEMP"$BASE"$EXTENSION "$FILE"$EXTENSION
|
2023-08-14 10:04:50 +00:00
|
|
|
# delete temp file
|
2023-12-30 23:30:57 +00:00
|
|
|
ssh $OTHER "rm $TEMP\"$FILE\"; rm $TEMP\"$FILE\"$EXTENSION"
|
2023-12-30 23:03:08 +00:00
|
|
|
|
|
|
|
if [[ $3 == "-d" ]];
|
|
|
|
rm $FILE
|
|
|
|
then
|
2023-08-14 10:04:50 +00:00
|
|
|
|