projects
/
BK-2020-03.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
feat(user/bkotslu):Retrieve OTS files from storage if older
[BK-2020-03.git]
/
unitproc
/
bk_export_audio.sh
diff --git
a/unitproc/bk_export_audio.sh
b/unitproc/bk_export_audio.sh
index 1100811e3a7515016b7bc3841394a722f955a1c0..140a63dd8027dd974edd33225410af81bfe02b1d 100755
(executable)
--- a/
unitproc/bk_export_audio.sh
+++ b/
unitproc/bk_export_audio.sh
@@
-1,7
+1,7
@@
#!/bin/bash
# Desc: Extracts audio from video files
# Usage: bk_export_audio.sh [input_dir] ([output_dir])
#!/bin/bash
# Desc: Extracts audio from video files
# Usage: bk_export_audio.sh [input_dir] ([output_dir])
-# Version: 0.1.
0
+# Version: 0.1.
3
# Depends: bash 5.1.16, GNU Coreutils (8.32)
# Plumbing
# Depends: bash 5.1.16, GNU Coreutils (8.32)
# Plumbing
@@
-226,14
+226,18
@@
extract_audio_file() {
# arg2: desired output file extension
# arg3: output dir path
# Output: audio file at path [arg3]/[arg1].[arg2]
# arg2: desired output file extension
# arg3: output dir path
# Output: audio file at path [arg3]/[arg1].[arg2]
- local file_in file_in_ext dir_out file_in_basename;
+ local file_in file_in_ext dir_out file_in_basename
path_out
;
file_in="$1";
file_in_ext="$2";
dir_out="$3";
file_in="$1";
file_in_ext="$2";
dir_out="$3";
+ file_in_basename="$(basename "$file_in")";
+ path_out="$dir_out"/"$file_in_basename"."$file_in_ext";
+
+ # Skip if output file already exists.
+ if [[ -f "$path_out" ]]; then return 1; fi;
# Extract audio file
# Extract audio file
- file_in_basename="$(basename "$file_in")";
- ffmpeg -i "$file_in" -vn -acodec copy "$dir_out"/"$file_in_basename"."$file_in_ext";
+ ffmpeg -i "$file_in" -vn -acodec copy "$path_out";
} # Create audio file from video file
count_jobs() {
# Desc: Count and return total number of jobs
} # Create audio file from video file
count_jobs() {
# Desc: Count and return total number of jobs
@@
-305,11
+309,11
@@
main() {
# Do work
yell "DEBUG:dir_in:$dir_in":
yell "DEBUG:dir_out:$dir_out";
# Do work
yell "DEBUG:dir_in:$dir_in":
yell "DEBUG:dir_out:$dir_out";
-
for file in "$dir_in"/*
; do
+
while read -r file
; do
yell "DEBUG:count_jobs:$(count_jobs)";
yell "DEBUG:count_jobs:$(count_jobs)";
- while [[ "$(count_jobs)" -ge $max_jobs ]]; do sleep 0.
1; done; # limit jobs
+ while [[ "$(count_jobs)" -ge $max_jobs ]]; do sleep 0.
01s; done; # limit jobs
job "$file" "$dir_out" &
job "$file" "$dir_out" &
- done;
+ done
< <(find "$dir_in" -type f)
;
# Announce completion
while [[ "$(count_jobs)" -gt 0 ]]; do sleep 1; done;
# Announce completion
while [[ "$(count_jobs)" -gt 0 ]]; do sleep 1; done;