Added cli options. Fixed copy logic for directories
This commit is contained in:
parent
d80d426a68
commit
632653808b
@ -1,31 +1,46 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# ssh-encode FILE SSH-ALIAS
|
__usage="Usage: $(basename $0) FILE [ssh alias]
|
||||||
FILE=$1
|
|
||||||
OTHER=$2
|
|
||||||
EXTENSION=".new.mp4"
|
|
||||||
# probably best this file is on a tmpfs mount as to reduce
|
|
||||||
# rw wear
|
|
||||||
TEMP="/tmp/"
|
|
||||||
|
|
||||||
|
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.
|
||||||
|
"
|
||||||
|
|
||||||
if [[ -z $1 ]];
|
if [[ -z $1 ]];
|
||||||
then
|
then
|
||||||
|
echo "$__usage"
|
||||||
echo "Pass the file to encode as the first argument."
|
echo "Pass the file to encode as the first argument."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $2 ]];
|
if [[ -z $2 ]];
|
||||||
then
|
then
|
||||||
|
echo "$__usage"
|
||||||
echo "Pass the ssh alias of the remote device as the second argument."
|
echo "Pass the ssh alias of the remote device as the second argument."
|
||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
FILE=$1
|
||||||
|
BASE=$(basename $FILE)
|
||||||
|
OTHER=$2
|
||||||
|
EXTENSION=".new.mp4"
|
||||||
|
TEMP="/tmp/"
|
||||||
|
|
||||||
# move file to other's temp drive
|
# move file to other's temp drive
|
||||||
scp $FILE $OTHER:$TEMP
|
scp $FILE $OTHER:$TEMP
|
||||||
# use ffmpeg to encode on other computer
|
# use ffmpeg to encode on other computer
|
||||||
ssh $OTHER "ffmpeg -y -i $TEMP$FILE -vcodec h264_nvenc -acodec aac -pix_fmt yuv420p -g 15 -movflags frag_keyframe+empty_moov $TEMP$FILE$EXTENSION"
|
ssh $OTHER "ffmpeg -y -i $TEMP$BASE -vcodec hevc $TEMP$BASE$EXTENSION"
|
||||||
# move file back
|
# move file back
|
||||||
scp $OTHER:$TEMP$FILE$EXTENSION .
|
scp $OTHER:$TEMP$BASE$EXTENSION $FILE$EXTENSION
|
||||||
# delete temp file
|
# delete temp file
|
||||||
ssh $OTHER "rm $TEMP$FILE; rm $TEMP$FILE$EXTESION"
|
ssh $OTHER "rm $TEMP$FILE; rm $TEMP$FILE$EXTENSION"
|
||||||
|
|
||||||
|
if [[ $3 == "-d" ]];
|
||||||
|
rm $FILE
|
||||||
|
then
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user