hey @vaporeon_ is there a good way to parallelize the following bash script I'm using to convert FLACs to MP3s?
#!/usr/bin/env bash
find "./${1}" | while read -r file; do
case $(file -b "${file}") in
'FLAC '*)
echo "${file}"
ffmpeg -nostdin -i "${file}" -ab 320k -map_metadata 0 -id3v2_version 3 "${file%flac}mp3" -v 16
;;
*)
;;
esac
done
@vaporeon_ a little searching tells me that audio encoding is typically handled with a single thread
@wallhackio Initialize i to 0 before starting that entire pipeline, of course
@vaporeon_ for some reason this will quit before finishing all of the files...
@wallhackio Is it the "tail", the last up to nproc-1 files, which are not waited for because the counter never reaches nproc? And you can put another wait at the end of the script to await them. Or is there an error?
@vaporeon_ I'm not getting any errors. I am very conbfused
@wallhackio Screenshot of whatever output you're getting?
@vaporeon_ It was some weird issue with WSL.
If you run bash from a windows terminal, it briefly opens a WSL instance to execute the command. For some reason this closed early
I used a WSL terminal directly instead of running bash from a windows terminal and it works just fine now
@wallhackio Reported for using Microsoft Windows ![]()
@vaporeon_ yeah
@wallhackio Hm, assuming the audio files are mostly of similar length, does something like this work? I didn't test it, but you get the idea, right?