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

Issue about not specifying the path to the ffmpeg package #218

Open
ZOMIN28 opened this issue May 25, 2022 · 0 comments
Open

Issue about not specifying the path to the ffmpeg package #218

ZOMIN28 opened this issue May 25, 2022 · 0 comments

Comments

@ZOMIN28
Copy link

ZOMIN28 commented May 25, 2022

1 Issues

When I use Augly to perform data enhancement operations on videos, I encounter this problem:

Compression Mode is disabled, Kindly enable it to access this function.

But I have installed ffmpeg and configured the environment. Then I tried to debug the code and found a bug.

When the function add_augmenter() calls WriteGear(),The value of parameter custom_ffmpeg is not specified. But later in the code, it is necessary to use its real value:

Line 215 in writegear.py:
    
            self.__ffmpeg = get_valid_ffmpeg_path(
                custom_ffmpeg,
                self.__os_windows,
                ffmpeg_download_path=__ffmpeg_download_path,
                logging=self.__logging,
            )

So that in function get_valid_ffmpeg_path(), the value returned is always False, which causes the program to fail to get the locally downloaded ffmpeg package and must download it again.

Line 885 in helper.py:

def get_valid_ffmpeg_path(
    custom_ffmpeg="", is_windows=False, ffmpeg_download_path="", logging=False
):
    """
    ## get_valid_ffmpeg_path

    Validate the given FFmpeg path/binaries, and returns a valid FFmpeg executable path.

    Parameters:
        custom_ffmpeg (string): path to custom FFmpeg executables
        is_windows (boolean): is running on Windows OS?
        ffmpeg_download_path (string): FFmpeg static binaries download location _(Windows only)_
        logging (bool): enables logging for its operations

    **Returns:** A valid FFmpeg executable path string.
    """
    final_path = ""
    if is_windows:
        # checks if current os is windows
        if custom_ffmpeg:
            # if custom FFmpeg path is given assign to local variable
            final_path += custom_ffmpeg
        else:
            # otherwise auto-download them
            try:
                if not (ffmpeg_download_path):
                    # otherwise save to Temp Directory
                    import tempfile

                    ffmpeg_download_path = tempfile.gettempdir()

                logging and logger.debug(
                    "FFmpeg Windows Download Path: {}".format(ffmpeg_download_path)
                )

                # download Binaries
                os_bit = (
                    ("win64" if platform.machine().endswith("64") else "win32")
                    if is_windows
                    else ""
                )
                _path = download_ffmpeg_binaries(
                    path=ffmpeg_download_path, os_windows=is_windows, os_bit=os_bit
                )
                # assign to local variable
                final_path += _path

2 Solution

Giving the path to the local ffmpeg package when use get_valid_ffmpeg_path(). Like this:

 self.__ffmpeg = get_valid_ffmpeg_path(
                "D:/workSoftware/anaconda/envs/augly/Library/bin/",
                self.__os_windows,
                ffmpeg_download_path=__ffmpeg_download_path,
                logging=self.__logging,
            )

Its path can be obtained using the following method:

import distutils
distutils.spawn.find_executable('ffmpeg')

This way you won't need to reinstall the ffmpeg package every time you use it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant