소스 검색

update script

David 10 년 전
부모
커밋
46d489b50a
1개의 변경된 파일11개의 추가작업 그리고 7개의 파일을 삭제
  1. 11 7
      front/fix-file.sh

+ 11 - 7
front/fix-file.sh

@@ -2,8 +2,8 @@
 
 set -e
 
-if [ $# -ne 2 ]; then
-	echo "usage: $0 in.mp4 out.mp4"
+if [ $# -ne 1 ]; then
+	echo "usage: $0 in.mp4"
 	exit 1
 fi
 
@@ -12,12 +12,14 @@ if [ ! -f "$1" ]; then
 	exit 1
 fi
 
-if [ -f "$2" ]; then
-	echo "$2 exists"
+tmpfile="$1.tmp"
+if [ -f "$tmpfile" ]; then
+	echo "$tmpfile exists"
 	exit 1
 fi
 
 
+mv "$1" "$tmpfile"
 audiofile=$(mktemp).aac
 videofile=$(mktemp).mp4
 
@@ -28,7 +30,9 @@ function finish {
 
 trap finish EXIT
 
-ffmpeg -hide_banner -analyzeduration 16M -i "$1" -c:v copy -an -f mp4 -y $videofile
-ffmpeg -hide_banner -analyzeduration 16M -i "$1" -c:a copy -vn -bsf:a aac_adtstoasc -y $audiofile
+ffmpeg -hide_banner -analyzeduration 16M -i "$tmpfile" -c:v copy -an -f mp4 -y $videofile
+ffmpeg -hide_banner -analyzeduration 16M -i "$tmpfile" -c:a copy -vn -bsf:a aac_adtstoasc -y $audiofile
 
-ffmpeg -hide_banner -i $audiofile -i $videofile -c copy -bsf:a aac_adtstoasc -y "$2"
+ffmpeg -hide_banner -i $audiofile -i $videofile -c copy -bsf:a aac_adtstoasc -y "$1"
+
+rm -f "$tmpfile" #no quiero borrarlo a menos que todo haya salido bien