AlexAplin/nndownload

Specify ffmpeg requirement

Closed this issue · 3 comments

Just want to help if anyone runs into this problem. I clone git code from GitHub and installed the environment with conda using the command pip install -r requirements.txt, but ffmpeg wont be added to PATH (you can check by using the command ffmpeg -version in CMD. Which will cause an error where the video and the audio file can be downloaded but the merging process can't be done. And it will give a generic error message like:

  File "e:\Download\Doc\Python\nndownload\nndownload\ffmpeg_dl.py", line 55, in load_subprocess
    self.proc = subprocess.Popen(
  File "E:\miniconda3\envs\public_env\lib\subprocess.py", line 951, in __init__
    self._execute_child(args, executable, preexec_fn, close_fds,
  File "E:\miniconda3\envs\public_env\lib\subprocess.py", line 1436, in _execute_child
    hp, ht, pid, tid = _winapi.CreateProcess(executable, args,

...

  File "e:\Download\Tu_Lieu\Python\nndownload\nndownload\nndownload.py", line 1359, in perform_native_hls_dl
    raise FormatNotAvailableException("Failed to download video or audio stream") from exception
nndownload.nndownload.FormatNotAvailableException: Failed to download video or audio stream

since python can't find the ffmpeg path in the arguments give to subprocess, like this: ['ffmpeg', '-i', 'C:\\Users\\MyPC\\AppData\\Local\\Temp\\tmpabnjxon3\\Z2tdbYrgON8JZ7l9.ts', '-i', 'C:\\Users\\MyPC\\AppData\\Local\\Temp\\tmpabnjxon3\\0KaA3piUpW6e67A6.ts', '-map', '0', '-map', '1', '-acodec', 'copy', '-vcodec', 'copy', 'E:\\Download\\sm44065249.part.mp4', '-progress', '-', '-nostats', '-y'].

To fix this in a lazy way, you just need to uninstall the ffmpeg-python pip version and install from conda instead:

pip uninstall ffmpeg-python
conda install ffmpeg-python

ffmpeg-python is just a wrapper of ffmpeg, you're supposed to put ffmpeg executable in your path yourself.

It works for conda is likely because conda would install ffmpeg for you; which is the exception not the norm.

Correct, though it probably should be explained better in the docs.

I added a check for ffmpeg on the PATH only when a subprocess is opened and an explainer in the README. This lets other functions like Seiga work without it, so you'll only hit an exception when it's needed.

I didn't check too closely but might be possible to specify a path to the binary as well, in which case I'll add that as a flag option.