facebookresearch / facebookresearch/AugLy

Issue about not specifying the path to the ffmpeg package

Open
#218 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.1k
Forks
312
PR merge metrics
No merged PRs in 30d

Description

### 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:

```python
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.

```python
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:

```python
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:

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

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.