Closed methevoz closed 5 years ago
Hmmm... I can't say that I've seen this issue before, but my guess is that there might be a bug with the threading. Can you try explicitly setting the [--num-threads NUM_THREADS]
option to 1
or 2
form the command line and see if that still causes the issue?
I tried doing that and unfortunately it doesn't solve the issue, although changing the number of threads also changes which files get converted and which files do not, 2
threads giving the most successes as far as I can see. The process is still a bit random and there are slight differences between the end results of each run I attempt even with the same number of threads.
Note that I have the 3.4.6 version of ffmpeg installed if that's relevant.
EDIT: I tried re-doing everything with ffmpeg 4.2.1 and still have the issue, although results are a bit chaotic and vary with each run, regardless of threads or version.
Hi, I wrote a small piece of code that does the conversion with sox instead of ffmpeg and that worked fine for me. It's a lot slower but it gets the job done. Hope it helps anyone that may run into the same issues:
import os
import argparse
import subprocess
from distutils.util import strtobool
def flac_to_wav(in_folder):
extensions = ('.flac')
for root, _, files in os.walk(in_folder):
for file in files:
if file.endswith(extensions):
filename_wav = file.replace('.flac', '.wav')
subprocess.run(['sox', root+'/'+file, '-r',
'44100', '-c', '2', '-b', '16', root+'/'+filename_wav])
os.remove(root+'/'+file)
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--input-dir', '-i', type=str, required=True,
help='Base path to input directory. (Required)')
parser.add_argument('--verbose', '-v', type=lambda x:bool(strtobool(x)), default=False, required=False,
help='Whether to print messages while processing. (Optional)')
args = parser.parse_args()
flac_to_wav(args.input_dir)
Note that this version does not take an output directory but rather does the conversion "in place" by converting to .wav then deleting the original .flac file. I ran this on a copy of the original dataset so as to obtain the same result. Cheers.
Hey, I'm glad you were able to find a solution. I think I might also have a solution, but I haven't tested it yet. I'll test your and my solutions next week and merge them in. Thanks for checking it out.
Based off of this: https://stackoverflow.com/questions/33341303/ffmpeg-resource-temporarily-unavailable I was able to fix this issue by adding 'threads=1' to every call of ffmpeg.input() and ffmpeg.output(). The parameterized thread count still works, as it splits apart the work across all of the tracks, however, my change forces ffmpeg to use only one thread at a time when dealing with the conversion of one file. I am not sure if this is the right way to fix this, especially if @ethman experiences no problems with the code as it stands. These observations seem to suggest that ffmpeg does not use one thread by default, and this can cause issues for some systems.
Hello,
I recently downloaded the Slakh dataset for use in the context of my thesis on musical source separation. When trying to convert the data from .flac to .wav using the provided script (
flac_converter.py
inconversion/
) that I call with, at some point I keep getting the following error message repeatedly:
with different stems each time. After this a few huge chunks of tracks are skipped, and the script goes on to convert a few more tracks before stopping completely. I also get the following somewhere near the end:
In the end my terminal becomes unresponsive and I end up with a bunch of tracks that seem to be properly converted but with big chunks missing in the middle and in the end. Any idea what's going on here?