-
Notifications
You must be signed in to change notification settings - Fork 0
/
clean-video
executable file
·24 lines (17 loc) · 1.14 KB
/
clean-video
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
ffmpeg -y -i "$1" -c:v copy -c:a aac -b:a 640k compatible-video.mp4
ffmpeg -y -i compatible-video.mp4 -c:v none -c:a copy audio.aac
whisper_timestamped audio.aac --model medium.en --language en --accurate --output_format srt --output_dir .
cleanvid -i compatible-video.mp4 -s audio.aac.words.srt -p 0 -a '-c:a aac -b:a 640k' -o pass-1.mp4
rm compatible-video.mp4
# another pass (uncomment if you want potentially higher accuracy)
ffmpeg -y -i pass-1.mp4 -c:v none -c:a copy audio.aac
whisper_timestamped audio.aac --model medium.en --language en --accurate --output_format srt --output_dir .
cleanvid -i pass-1.mp4 -s audio.aac.words.srt -p 0 -a '-c:a aac -b:a 640k' -o pass-2.mp4
rm pass-1.mp4
# try mono audio (seems like stereo/surround sound may mess up the detection)
ffmpeg -y -i pass-2.mp4 -c:v none -b:a 640k -ac 1 audio.aac
whisper_timestamped audio.aac --model medium.en --language en --accurate --output_format srt --output_dir .
cleanvid -i pass-2.mp4 -s audio.aac.words.srt -p 0 -a '-c:a aac -b:a 640k' -o "${1%.*}-clean.mp4"
# remove unused files
rm audio.aac.srt audio.aac.words.srt audio.aac.words_clean.srt audio.aac pass-2.mp4