-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConcatOnly_fromStep3To4_DashCamPipeline.sh
74 lines (54 loc) · 2.15 KB
/
ConcatOnly_fromStep3To4_DashCamPipeline.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/bin/bash
######################################
## Written by: SOJA ##
### Example ##
### ./DashCamPipeline.sh avi 5 60 0 ##
##[format] [speed] [frame] [threads]##
######################################
ALL_START_TIME=$SECONDS
START_TIME=$SECONDS
# rm -r 2.NoAudio 3.Fast logs
mkdir -p 1.Do 2.NoAudio 3.Fast 4.Final logs
# --------------------------------- Variables ------------------------------------
MaxFrameRate=30
OriginalFrameRate=${3:-30}
Threads=${4:-0}
a=$(($OriginalFrameRate*${2:-4}))
NewFrameRate=$(( a < MaxFrameRate ? a : MaxFrameRate ))
speed=0.05
FileType=${1:-"AVI"}
now=$(date +"%m_%d_%Y__%H%M")
# ---------------------------------------------------------------------------------------
# echo -e "\nRemoving Audio..."
# cd 1.Do
# for f in *.$FileType; do
# echo -n '*'
# ffmpeg -i $PWD/$f -vcodec copy -an ../2.NoAudio/$f -threads $Threads 2>> ../logs/$now.log
# done
# ELAPSED_TIME=$(($SECONDS - $START_TIME))
# echo -e "\n\t-Done in $(($ELAPSED_TIME/60)) min $(($ELAPSED_TIME%60)) sec\n\n"
# START_TIME=$SECONDS
# echo -e "Fasten Video Tracks..."
# cd 2.NoAudio/
# for f in *.$FileType; do
# # for audio and Video
# # ffmpeg -i $PWD/$f -r $NewFrameRate -filter_complex "[0:v]setpts=$speed*PTS[v];[0:a]atempo=2.0[a]" -map "[v]" -map "[a]" ../3.Fast/$f 2>> ../logs/$now.log
# #only for video:
# echo -n '*'
# ffmpeg -i $PWD/$f -r $NewFrameRate -filter:v "setpts=$speed*PTS" ../3.Fast/$f -threads $Threads 2>> ../logs/$now.log
# done
# ELAPSED_TIME=$(($SECONDS - $START_TIME))
# echo -e "\n\t-Done in $(($ELAPSED_TIME/60)) min $(($ELAPSED_TIME%60)) sec\n\n"
# START_TIME=$SECONDS
echo -e "Concatinate all..."
cd 3.Fast
(for f in *.$FileType; do echo -e "file '$f'"; done) > list.txt
ffmpeg -f concat -safe 0 -i list.txt -c copy ../4.Final/RoadTrip_$now.$FileType -threads $Threads 2>> ../logs/$now.log
ELAPSED_TIME=$(($SECONDS - $START_TIME))
echo -e "\t-Done in $(($ELAPSED_TIME/60)) min $(($ELAPSED_TIME%60)) sec\n\n"
START_TIME=$SECONDS
echo -e "*** All Done! in ***"
ELAPSED_TIME=$(($SECONDS - $ALL_START_TIME))
echo -e "\t\t-Overall time: $(($ELAPSED_TIME/60)) min $(($ELAPSED_TIME%60)) sec\n"
cd ..
# rm -r 2.NoAudio 3.Fast