faroit / stempeg

Python I/O for STEM audio files
https://faroit.github.io/stempeg
MIT License
96 stars 13 forks source link

Ffprobe command returns non-zero exit status 3221225478 #9

Closed vinspatel closed 5 years ago

vinspatel commented 5 years ago

I am running it on anaconda. It seems to work perfectly on colab. However on anaconda it fails.

The behavior is weird as well. I ran the command on bash and it runs correctly.

I have a loop which runs through all the stem files and it breaks after executing random iterations giving the error stated below. I believe this could be an multiprocessing issue. Could it be that that file is already being used by another process?

File "", line 1, in runfile('C:/Users/w1572032/.spyder-py3/temp.py', wdir='C:/Users/w1572032/.spyder-py3')

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile execfile(filename, namespace)

File "C:\ProgramData\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)

File "C:/Users/w1572032/.spyder-py3/temp.py", line 28, in t = np.copy(track.targets['vocals'].audio.T)

File "C:\ProgramData\Anaconda3\lib\site-packages\musdb\audio_classes.py", line 113, in audio audio = source.audio

File "C:\ProgramData\Anaconda3\lib\site-packages\musdb\audio_classes.py", line 47, in audio filename=self.path, stem_id=self.stem_id

File "C:\ProgramData\Anaconda3\lib\site-packages\stempeg\read.py", line 90, in read_stems FFinfo = FFMPEGInfo(filename)

File "C:\ProgramData\Anaconda3\lib\site-packages\stempeg\read.py", line 19, in init self.json_info = read_info(self.filename)

File "C:\ProgramData\Anaconda3\lib\site-packages\stempeg\read.py", line 54, in read_info out = sp.check_output(cmd)

File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 336, in check_output **kwargs).stdout

File "C:\ProgramData\Anaconda3\lib\subprocess.py", line 418, in run output=stdout, stderr=stderr)

CalledProcessError: Command '['ffprobe', 'C:\Users\w1572032\Desktop\musdb18\train\BigTroubles - Phantom.stem.mp4', '-v', 'error', '-print_format', 'json', '-show_format', '-show_streams']' returned non-zero exit status 3221225478.

faroit commented 5 years ago

Sorry for the late reply. did you solve it in the meantime?

vinspatel commented 5 years ago

No worries. I still haven't solved it yet. I looked into the inner code of the plugins. It is not creating temp file form ffmpeg execution. This happens with other ffmpeg based libraries as well such as librosa's load throws the same error when ran in loop. It could be a process management issue in windows i.e., it could be possible that file is still in use or such.

faroit commented 5 years ago

are you using python 2.7? Seems that there is a bug in the process call: https://bugs.python.org/issue9400

Otherwise I don't know how to reproduce, could you provide a minimal example where you iterate over the musdb tracks using multiprocessing?

faroit commented 5 years ago

I now found a workaround that might help. I added a functionality reuse the Info object, so that ffprobe is only called once if the stream configuration is the same for all tracks (like in musdb)

info = stempeg.Info("first_track.stem.mp4")
for i in range(tracks):
    S, _ = stempeg.read_stems("further_tracks.stem.mp4", info=info)

I will also add this to musdb and update the packages.

vinspatel commented 5 years ago

are you using python 2.7? Seems that there is a bug in the process call: https://bugs.python.org/issue9400

Otherwise I don't know how to reproduce, could you provide a minimal example where you iterate over the musdb tracks using multiprocessing?

Apologies for late reply, I was trying to do this on conda environment in windows: with necessary packages including libsndfile, ffmpeg, stempeg, musdb, etc.

mus = musdb.DB(root_dir=r"C:\Users\w1572032.INTRANET.002\Desktop\musdb18")
tracks = mus.load_mus_tracks(subsets=['train'])
for i, track in enumerate(tqdm(tracks)):
    t = np.copy(track.targets['vocals'].audio.T)
    xt = np.copy(track.targets['accompaniment'].audio.T)
faroit commented 5 years ago

but was this python 2.7 or 3?

and what do you think about the workaround?

vinspatel commented 5 years ago

I was using python 3.7.2 in specific. I will test it on the updated library and will let you know by tomorrow. Thanks a lot for your reply.

vinspatel commented 5 years ago

I have tested the updated library on musdb tracks and it works. Thanks

faroit commented 5 years ago

That's great! Thanks for your feedback. I will update musdb as well in the coming days