From: Steven Baltakatei Sandoval Date: Thu, 22 Aug 2024 20:58:55 +0000 (+0000) Subject: feat(unitproc/bk_export_audio.sh):Process files via find X-Git-Url: https://zdv2.bktei.com/gitweb/BK-2020-03.git/commitdiff_plain/83eab65c2bca70d14e5a30e6f5ad2858a8eed4f1?ds=inline feat(unitproc/bk_export_audio.sh):Process files via find * feat(user/convert_file_to_flac.sh):Preserve metadata --- diff --git a/unitproc/bk_export_audio.sh b/unitproc/bk_export_audio.sh index bbf3f3d..927556e 100755 --- 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]) -# Version: 0.1.1 +# Version: 0.1.2 # Depends: bash 5.1.16, GNU Coreutils (8.32) # Plumbing @@ -309,11 +309,11 @@ main() { # 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)"; while [[ "$(count_jobs)" -ge $max_jobs ]]; do sleep 0.1; done; # limit jobs job "$file" "$dir_out" & - done; + done < <(find "$dir_in" -type f); # Announce completion while [[ "$(count_jobs)" -gt 0 ]]; do sleep 1; done; diff --git a/user/convert_file_to_flac.sh b/user/convert_file_to_flac.sh index cc6c621..cd20d2d 100755 --- a/user/convert_file_to_flac.sh +++ b/user/convert_file_to_flac.sh @@ -1,7 +1,7 @@ #!/usr/bin/env bash # Desc: Converts file readable by ffmpeg to FLAC audio file # Usage: convert_file_to_flac.sh [path] -# Version: 0.0.3 +# Version: 0.0.4 # Ref/Attrib: [1] Convert audio file to FLAC with ffmpeg? https://superuser.com/a/802126 # [2] How to specify flac compression level when converting with avconv? https://askubuntu.com/questions/544651/ # [3] How can I extract audio from video with ffmpeg? https://stackoverflow.com/a/27413824 @@ -217,7 +217,7 @@ main() { die "FATAL:Not an audio file:$1"; fi; # Convert file to FLAC. See [1], [2] - try ffmpeg -i "$1" -vn -c:a flac -compression_level 12 "$1".flac + try ffmpeg -i "$1" -vn -c:a flac -map_metadata 0 -compression_level 12 "$1".flac }; # main program main "$@";