omeryusufyagci / fast-music-remover

A C++ based, lightweight music and noise remover for YouTube and other internet media, using DeepFilterNet for audio enhancement.
MIT License
185 stars 20 forks source link

Testing: Perform Initial Tests on Windows #18

Closed omeryusufyagci closed 1 month ago

omeryusufyagci commented 1 month ago

We are looking to expand support to Windows users by providing an installable Windows release. Before we proceed to automate a Windows release pipeline, we need to confirm that the current project works well on a Windows environment.

This is a particularly good first issue to take, and a good opportunity to understand the inner workflow of the project. It will also pave the way to reach a greater audience.

Objectives:

IbrahimHamshari commented 1 month ago

Can you assign me this issue ?

omeryusufyagci commented 1 month ago

Hi @IbrahimHamshari, thanks for your interest!

I've assigned the issue to you. Please take note of each problem you encounter and provide updates to our documentation to ensure a seamless manual installation experience for our Windows users.

Feel free to reach out if you have any questions along the way

readysetlearn commented 1 month ago

Hi @omeryusufyagci

I can't get this to build on Windows 10. I tried with Visual Studio and MSYS2. They both gave errors regarding the inclusion of nlohmann/json.hpp in ConfigManager.h. I tried installing the mingw-w64-x86_64-nlohmann-json package in MSYS2 but it didn't help.

omeryusufyagci commented 1 month ago

Hi @readysetlearn thanks for reporting this. I'm expecting quite a few small issues like this to come up here. Let's revisit this with @IbrahimHamshari once his initial review is finished and proposes a set of manual installation instructions for Windows.

omeryusufyagci commented 1 month ago

Trying to test on a Mac, I've also run into some problems and just updated the documentation to include details about the ffmpeg path and installation instructions for the JSON library. We can add the Windows instructions in the same collapsable section under Prerequisites. Now it seems to be fine on MacOS and Linux.

Eventually we should provide an installation script, and detect the paths, update the config file ourselves, but for now let's try to document exhaustively.

IbrahimHamshari commented 1 month ago

Yeah, I also ran into some issues with that fixed it, but I have some path errors right now and I'm trying to fix them right now.

IbrahimHamshari commented 1 month ago

I've ran into some issues that I think requires deep knowledge about the code itself, how can I contact you to understand the project more ?

image

I managed to change the "/upload" to depend on the platform by changing this part of the code in the AudioProcessor.cpp file.

/******  228b48a9-06a0-43c6-86fc-31eab1e21ed4  *******/ AudioProcessor::AudioProcessor(
    const std::string &inputVideoPath, const std::string &outputAudioPath)
    : m_inputVideoPath(inputVideoPath),
      m_outputAudioPath(outputAudioPath),
      m_numChunks(DEFAULT_NUM_CHUNKS),
      m_overlapDuration(DEFAULT_OVERLAP_DURATION) {
    std::filesystem::path outputPath(outputAudioPath);

    m_outputDir = outputPath.parent_path().string();

    std::filesystem::path chunksDir = outputPath.parent_path() / "chunks";
    std::filesystem::path processedChunksDir = outputPath.parent_path() / "processed_chunks";
        m_chunksDir = chunksDir.string();
    m_processedChunksDir = processedChunksDir.string();
    /*
     * TODO: 
     * * numChunks (numThreads) should be configurable, as well as the overlap (which seems much less critical?)
     * * Need an ffmpeg utils to establish an API for extaction and probing
     */
}
omeryusufyagci commented 1 month ago

Thanks @IbrahimHamshari for sharing the details. Indeed, we have some work to do to support both both OSs without cluttering the code base. I have the rough game plan in my mind though:

  1. Update config.json with dedicated paths:

    "ffmpeg_path_unix": "/usr/bin/ffmpeg",
    "ffmpeg_path_windows": "C:\\ ...", 

    Same for the DeepFilter path, and we should put the default paths on Windows.

  2. Update the ConfigManager to support "1": We need to add getters here, e.g. getFFmpegPath(), which will return the correct value depending on the OS definition.

#ifdef _WIN32
    return getConfigValue("ffmpeg_path_windows");
#else
    return getConfigValue("ffmpeg_path_linux");
#endif
  1. Update the implementation wrt "2": Now we can cleanly take these values from the ConfigManager singleton, e.g. configManager.getFFmpegPath().

  2. Migrate to std::filesystem::path We already use this to manage paths, but this is an oversight from me that they're hardcoded here. Example of what I mean:

    // instead of
    m_chunksDir = m_outputDir + "/chunks";
    // use
    m_chunksDir = (std::filesystem::path(m_outputDir) / "chunks").string();

    Of course, to refactor all similar operations for other variables as well.

  3. I believe at this point it should work, but to improve the ease of use of the ffmpeg commands, we should also introduce a CommandBuilder. This is where I want to go with this:

// Instead of:
std::string ffmpegCommand = ffmpegPath + " -y -i \"" + m_inputVideoPath +
                            "\" -ar 48000 -ac 1 -c:a pcm_s16le \"" + m_outputAudioPath + "\"";

// we should do:
cmd.addArgument(ffmpegPath);
cmd.addFlag("-y");
cmd.addFlag("-i", input);
cmd.addFlag("-ar", "48000");
...
cmd.addArgument(output);

I didn't write down the CommandBuilder interface here, but I hope you get the idea.


There is a lot to unpack here, and your feedback has been great to identify so many issues. As a high level overview, I think this should work, and I'll try to take a look at this soon (tonight hopefully!).

Fyi, @andcscott about the CommandBuilder as it may affect the class you're writing.

IbrahimHamshari commented 1 month ago

Thanks @omeryusufyagci for the insight, I was able to fix the paths. But the problem right now is that "deep-filter-0.5.6-x86_64-unknown-linux-musl" is not suitable for window, I'm not sure though when I try to execute a command on it this happens image this error happens when trying to process a video image I'm using the mingw64 to compile and build the cpp project btw.

omeryusufyagci commented 1 month ago

@IbrahimHamshari you found another update needed for the config file! That is a linux executable, so we have to ensure to use a windows binary here. Could you please try with this Windows binary?

You'll need to move the downloaded file under the res directory and update the config.json to point to this path. This should resolve the primary problem.

Can you locate MediaProcessor binary under build/? It may be an artifact of the problem above.

IbrahimHamshari commented 1 month ago

Yeah, I can locate it. and it works as expected. But for some reason, the app can't locate it. image

omeryusufyagci commented 1 month ago

Could you try to append the .exe extension here?

I see that you tested with ./MediaProcessor; your shell could be smart enough to add the .exe extension, but the system might not recognize the file.

IbrahimHamshari commented 1 month ago

Yeah I tried that, same issue.

omeryusufyagci commented 1 month ago

Could you please share the full logs in text form, from the start of the backend server? Thanks

IbrahimHamshari commented 1 month ago

Here is the log file: log.txt or if you prefer it textual

 * Serving Flask app 'app'
 * Debug mode: on
WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead.
 * Running on http://127.0.0.1:8080
Press CTRL+C to quit
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 285-544-593
127.0.0.1 - - [04/Oct/2024 17:06:26] "GET / HTTP/1.1" 200 -
[youtube] Extracting URL: https://www.youtube.com/watch?v=TNhKAJwlj04 
[youtube] TNhKAJwlj04: Downloading webpage
[youtube] TNhKAJwlj04: Downloading ios player API JSON 
[youtube] TNhKAJwlj04: Downloading web creator player API JSON 
[youtube] TNhKAJwlj04: Downloading m3u8 information 
[youtube] Extracting URL: https://www.youtube.com/watch?v=TNhKAJwlj04 
[youtube] TNhKAJwlj04: Downloading webpage
[youtube] TNhKAJwlj04: Downloading ios player API JSON 
[youtube] TNhKAJwlj04: Downloading web creator player API JSON 
[youtube] TNhKAJwlj04: Downloading m3u8 information 
[info] TNhKAJwlj04: Downloading 1 format(s): 313+251 
[download] uploads\_BREATHE____Official_Launch_Video_-_Legends_of_Runeterra.webm has already been downloaded 
ERROR:root:Error processing video: Command failed with return code 1:
'MediaProcessor' is not recognized as an internal or external command,
operable program or batch file.

Error: Failed to process chunk with DeepFilterNet: C:\Users\acer\Desktop\Issues\fast-music-remover\uploads\chunks\chunk_0.wav
Command failed with return code 1:
'MediaProcessor' is not recognized as an internal or external command,
operable program or batch file.

Error: Failed to process chunk with DeepFilterNet: C:\Users\acer\Desktop\Issues\fast-music-remover\uploads\chunks\chunk_1.wav
Command failed with return code 1:
'MediaProcessor' is not recognized as an internal or external command,
operable program or batch file.

Error: Failed to process chunk with DeepFilterNet: C:\Users\acer\Desktop\Issues\fast-music-remover\uploads\chunks\chunk_2.wav
Command failed with return code 1:
'MediaProcessor' is not recognized as an internal or external command,
operable program or batch file.

Error: Failed to process chunk with DeepFilterNet: C:\Users\acer\Desktop\Issues\fast-music-remover\uploads\chunks\chunk_3.wav
Command failed with return code 1:
'MediaProcessor' is not recognized as an internal or external command,
operable program or batch file.

Error: Failed to process chunk with DeepFilterNet: C:\Users\acer\Desktop\Issues\fast-music-remover\uploads\chunks\chunk_4.wav
Command failed with return code 1:
'MediaProcessor' is not recognized as an internal or external command,
operable program or batch file.

Error: Failed to process chunk with DeepFilterNet: C:\Users\acer\Desktop\Issues\fast-music-remover\uploads\chunks\chunk_5.wav
Command failed with return code -2:
ffmpeg version N-117304-g358fdf3083-20241003 Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 14.2.0 (crosstool-NG 1.26.0.106_ed12fa6)
  configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-config=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw32 --enable-gpl --enable-version3 --disable-debug --disable-w32threads --enable-pthreads --enable-iconv --enable-zlib --enable-libfreetype --enable-libfribidi --enable-gmp --enable-libxml2 --enable-lzma --enable-fontconfig --enable-libharfbuzz --enable-libvorbis --enable-opencl --disable-libpulse --enable-libvmaf --disable-libxcb --disable-xlib --enable-amf --enable-libaom --enable-libaribb24 --enable-avisynth --enable-chromaprint --enable-libdav1d --enable-libdavs2 --enable-libdvdread --enable-libdvdnav --disable-libfdk-aac --enable-ffnvcodec --enable-cuda-llvm --enable-frei0r --enable-libgme --enable-libkvazaar --enable-libaribcaption --enable-libass --enable-libbluray --enable-libjxl --enable-libmp3lame --enable-libopus --enable-librist --enable-libssh --enable-libtheora --enable-libvpx --enable-libwebp --enable-libzmq --enable-lv2 --enable-libvpl --enable-openal --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopenmpt --enable-librav1e --enable-librubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --enable-libsvtav1 --enable-libtwolame --enable-libuavs3d --disable-libdrm --enable-vaapi --enable-libvidstab --enable-vulkan --enable-libshaderc --enable-libplacebo --enable-libvvenc --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libzimg --enable-libzvbi --extra-cflags=-DLIBTWOLAME_STATIC --extra-cxxflags= --extra-libs=-lgomp --extra-ldflags=-pthread --extra-ldexeflags= --cc=x86_64-w64-mingw32-gcc --cxx=x86_64-w64-mingw32-g++ --ar=x86_64-w64-mingw32-gcc-ar --ranlib=x86_64-w64-mingw32-gcc-ranlib --nm=x86_64-w64-mingw32-gcc-nm --extra-version=20241003
  libavutil      59. 41.100 / 59. 41.100
  libavcodec     61. 21.100 / 61. 21.100
  libavformat    61.  9.100 / 61.  9.100
  libavdevice    61.  4.100 / 61.  4.100
  libavfilter    10.  6.100 / 10.  6.100
  libswscale      8.  4.100 /  8.  4.100
  libswresample   5.  4.100 /  5.  4.100
  libpostproc    58.  4.100 / 58.  4.100
[in#0 @ 000001dee667ea80] Error opening input: No such file or directory
Error opening input file C:\Users\acer\Desktop\Issues\fast-music-remover\uploads\processed_chunks\chunk_0.wav.
Error opening input files: No such file or directory

Error: Failed to merge back processed audio chunks with crossfading.
Failed to extract vocals.

127.0.0.1 - - [04/Oct/2024 17:06:49] "POST / HTTP/1.1" 200 -
INFO:werkzeug:127.0.0.1 - - [04/Oct/2024 17:06:49] "POST / HTTP/1.1" 200 -
omeryusufyagci commented 1 month ago

Have you edited the "./" part of that subprocess call? That's unix syntax; it should be something like MediaProcessor\\build\\MediaProcessor.exe (tbt). I'd try to os.listdir where you're calling the binary, and perhaps run it with abs path. Is your fork up to date? If above doesn't help, could you push your work-in-progress version? It will help to understand better.