Skip to content

Commit

Permalink
Setup Script for Windows (#13)
Browse files Browse the repository at this point in the history
* initial setup script for windows users

* revised windows script and added readme

* only run when merged to main

* address MR comments
  • Loading branch information
zfleeman committed Jan 27, 2024
1 parent 2af6051 commit 5ff479e
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 4 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Docker Build and Push
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
push_to_registry:
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,24 @@ The `TwoPass()` Class showcases a 2-pass encoding methodology for the `ffmpeg-py
## Usage
You must first have `ffmpeg` installed on your system. `ffmpeg` needs to be registered in your PATH.

Install the required Python package, `ffmpeg-python` with:
Install the required Python packages, which includes `ffmpeg-python`, with:

```pip install ffmpeg-python```
```pip install -r requirements.txt```

Call the script with:

```python "C:/path/to/ffmpeg4discord.py" cool_clip.mp4```

The included Batch file for Windows users, `encode.bat`, allows for drag and drop functionality. Be sure to edit the Batch file before dragging your video files on top of it.

### Special install instructions for Windows users

If you do not have ffmpeg installed, you can use the included `windows_setup.py` file to do about 90% of the installation.

```python windows_setup.py```

This script downloads ffmpeg, extracts it into the current directory, and launches the Windows Environment Variable editor dialog. Follow the instructions printed out by the script. Don't worry, you got this.

## File name formatting
1) `000020.mp4`
- This clips and compresses the video from 00:00:20 to the end of the clip.
Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ffmpeg-python
pyperclip
36 changes: 36 additions & 0 deletions windows_setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# I know this is sloppy and kind of sucks, but I figured it would help installation at least a little bit.

from urllib.request import urlretrieve
import zipfile
import subprocess
import os
import pyperclip

# Get the current system-wide PATH
current_path = os.environ.get("PATH", "")

if "ffmpeg" in current_path:
raise SystemExit("ffmpeg is already present in your system PATH!")

curdir = os.getcwd()

print("Downloading ffmpeg to ffmpeg.zip...")
urlretrieve("https://www.gyan.dev/ffmpeg/builds/ffmpeg-release-essentials.zip", "ffmpeg.zip")
print("Done!\n")

print("Unzipping ffmpeg.zip...")
with zipfile.ZipFile("ffmpeg.zip", "r") as zip_ref:
zip_ref.extractall()
folder = f"{curdir}\\{zip_ref.namelist()[0][:-1]}\\bin"
print("Done!\n")

pyperclip.copy(folder)
print(f"'{folder}' has been copied to your clipboard.\n")

print("Launching environment variable editor.")
print("Add the copied ffmpeg folder path as an entry to the already-existing Path variable in the editor.")
print("Click the 'Ok' buttons to exit the dialog after you're done.")

subprocess.run(["rundll32", "sysdm.cpl,EditEnvironmentVariables"], check=True)

print("\nOpen a new Terminal window and type ffmpeg and hit enter to verify that the installation succeeded.")

0 comments on commit 5ff479e

Please sign in to comment.