Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

File Path Issues #16

Closed
RollingStar opened this issue Feb 11, 2024 · 2 comments · Fixed by #15
Closed

File Path Issues #16

RollingStar opened this issue Feb 11, 2024 · 2 comments · Fixed by #15
Assignees
Labels
bug Something isn't working

Comments

@RollingStar
Copy link

First off, thanks for this. There are other discord scripts out there but none this robust.

Apologies if this pollutes your repo: I know I have scripts that work perfectly for me, that I have no interest in supporting for others. But in case this helps you or anyone else:

I am running on Windows 10 x64 and Python 3.12. My ffmpeg version is vintage 2023:

ffmpeg version 6.1-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
Hyper fast Audio and Video encoder
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

I can split these into separate issues if you want.

Config file conflicts with parser defaults

The argparse module at utils/arguments.py sets defaults (e.g. 8mb file max). i think it would be more intuitive to pull these from conf.json.

Poor parsing of paths on windows

I spent about an hour trying to track this down, with no luck. I originally was trying to drag a file from g:\ onto the batch file on my c:\ drive. The batch then looked for a config file in the folder on g:. I iterated on this error many times, trying to shave it into something more manageable. You can set a path type in argparse, but it's kind of annoying - the discussion is over my head but you can see more here and here

What eventually worked was hardcoding the config path and passing a fake config file in the command line. I kept seeing my conf.json getting overwritten. Presumably this was from the "with open()" code but I couldn't get to the bottom of that either. (You'd think it wouldn't happen with "r" mode, but idk.) You need to have the fake config file to trigger the init_from_config() part of the code path.

I also had to put the video file in the same folder as the script. Anything more complicated seemed fraught.


    def init_from_config(self, config_file: str) -> None:
        """
        Set the Class values from a json file
        :param config_file: path to a json file containing parameters for TwoPass()
        """
        # with open(cc.name) as f:
        import pathlib

        pp = pathlib.Path(r"c:/apps/ffmpeg4discord/conf.json")
        with open(pp, "r", encoding="utf-8") as f:

Discord free limit is now 25 MB

So the default should change accordingly.

Make audio codec configurable

So opus can be set.


These are subjective:

VP9 + Opus are maximum quality supported on discord

At the expense of encode time, VP9 and Opus are better than h264 and aac.

@zfleeman
Copy link
Owner

@RollingStar Thank you so much for filing the first issue! For real, I'm very excited about this.

For "Config file conflicts with parser defaults" and "Poor parsing of paths on windows", I need to add pathlib to the config file process. I didn't put a lot of effort making the config file process work, but your suggestions are valid and awesome. I'll work on that.

Discord free limit is now 25 MB
Wow, I had no idea! Admittedly, I pay the $3/mo for Discord Nitro basic, so I'm not up to date on the free limits. I will change this default.

And the VP9/Opus callouts are great. After this hits 0.1.0 on PyPI, I'll work on bringing webm back into this project. This whole thing started as a webm exercise, but after I learned that Discord webm files don't play on iOS, I switched everything x264 for the ease of it all. webm will be a feature that I add in soon.

If you could separate these into their own issues (VP9/Opus, Config Paths, and Argparse defaults), that might help me prioritize the development. I'll do it if I get a free moment tomorrow afternoon. I could work on this all day, I'm just struggling to find time for hobby code, ha.

@zfleeman
Copy link
Owner

zfleeman commented Feb 13, 2024

VP9 and audio codec selection will be handled in #17

I will use this ticket to track the config file pathing issues and as well as the work with the defaults.

@zfleeman zfleeman self-assigned this Feb 13, 2024
@RollingStar RollingStar changed the title Various issues File Path Issues Feb 13, 2024
@zfleeman zfleeman added the bug Something isn't working label Feb 16, 2024
@zfleeman zfleeman added this to the ffmpeg4discord 0.1.0 milestone Feb 16, 2024
@zfleeman zfleeman moved this from Todo to In Progress in ffmpeg4discord Expansion and Maturity Feb 21, 2024
@zfleeman zfleeman moved this from In Progress to Done in ffmpeg4discord Expansion and Maturity Feb 21, 2024
@zfleeman zfleeman linked a pull request Feb 21, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

2 participants