Skip to content

Commit

Permalink
Merge pull request #56 from BombasticTom/ffmpeg-integration
Browse files Browse the repository at this point in the history
FFmpeg integration.
Windows build downloaders will have FFmpeg built-in to their archive and not need to download it externally.
  • Loading branch information
tposejank authored Jun 2, 2024
2 parents c02aca6 + 47b27eb commit 01260fa
Show file tree
Hide file tree
Showing 11 changed files with 277 additions and 24 deletions.
12 changes: 6 additions & 6 deletions .github/workflows/pr-builds.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
include:
- os: windows-latest
icon: icon.ico
ext:
command: pyinstaller build.spec
- os: macos-latest
icon: icon.icns
ext:
command: pyinstaller --onefile psychtobase/main.py --icon=icon.icns --noconsole -n "FNF Porter"
- os: ubuntu-latest
icon: ""
ext:
command: pyinstaller --onefile psychtobase/main.py --noconsole -n "FNF Porter"

steps:
- uses: actions/checkout@v4
Expand All @@ -43,9 +43,9 @@ jobs:
pip install pyinstaller numpy pydub luaparser pyqt6 pillow
- name: Build with PyInstaller
run: |
pyinstaller --onefile psychtobase/main.py --icon=${{ matrix.icon }} --noconsole -n "FNF Porter pullrequest-${{ github.event.pull_request.number }}"
${{matrix.command}}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: FNF_Porter_Build_${{ matrix.os }}
path: dist/*${{ matrix.ext }}
name: FNF_Porter_Build_${{ matrix.os }}_PR_${{ github.event.pull_request.number }}
path: dist/*
12 changes: 6 additions & 6 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@ jobs:
include:
- os: windows-latest
icon: icon.ico
ext:
command: pyinstaller build.spec
- os: macos-latest
icon: icon.icns
ext:
command: pyinstaller --onefile psychtobase/main.py --icon=icon.icns --noconsole -n "FNF Porter"
- os: ubuntu-latest
icon: ""
ext:
command: pyinstaller --onefile psychtobase/main.py --noconsole -n "FNF Porter"

steps:
- uses: actions/checkout@v4
Expand All @@ -43,9 +43,9 @@ jobs:
pip install pyinstaller numpy pydub luaparser pyqt6 pillow
- name: Build with PyInstaller
run: |
pyinstaller --onefile psychtobase/main.py --icon=${{ matrix.icon }} --noconsole -n "FNF Porter actions-${{ github.run_number }}"
${{matrix.command}}
- name: Upload build artifact
uses: actions/upload-artifact@v4
with:
name: FNF_Porter_Build_${{ matrix.os }}
path: dist/*${{ matrix.ext }}
name: FNF_Porter_Build_${{ matrix.os }}_Actions_${{ github.run_number }}
path: dist/*
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ fnf-porter.log
## PyInstaller
build/
dist/
*.spec

## FNF Porter files
**/logs/*
Expand Down
169 changes: 169 additions & 0 deletions FFMPEG-LICENSE

Large diffs are not rendered by default.

22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
![Window icon](big-icon.webp)
![Window icon](images/big-icon.webp)
# Friday Night Funkin' Mod Porter

Ports FNF mods between engines using Python. Right now, there's only support for Psych Engine to the Base Game, but new modes are coming soon! It has a GUI, cross-platform support, and logs (check the logs folder).

## Download
Go to the [releases tab](https://github.com/gusborg88/fnf-porter/releases) for slightly older versions. Read the dependencies section if you want to build it yourself.

For an alternative stable source, use our [GameBanana](https://gamebanana.com/tools/16982)

For latest compilations, go to the [actions tab](https://github.com/gusborg88/fnf-porter/actions)

## Issues?
Report it in the [issues tab](https://github.com/gusborg88/fnf-porter/issues/).

Expand All @@ -14,21 +18,27 @@ Check if it **already exists** before reporting though!
Also, logs are saved to your logs folder, so make sure to read them.

## Contributing
Thanks for contributing! You'll need to install [Python](https://www.python.org/downloads/) ofc, and the other dependencies listed in the next section. You can build after this by running [build.bat](build.bat). If you have questions about the code, ask the team.
Thanks for contributing! You'll need to install [Python](https://www.python.org/downloads/) ofc, and the other dependencies listed in the next section. You can build after this by running [`build.bat`](build.bat). If you have questions about the code, ask the team.

## Dependencies
You can simply run dependency-install.bat to install all of these at once. You have to go to [python.org](https://www.python.org/downloads/) and get Python first, though.
You can simply run `dependency-install.bat` to install all of these at once. You have to go to [python.org](https://www.python.org/downloads/) and get Python first, though.
- luaparser
- numpy
- pillow
- pydub
- pyinstaller
- PyQt6
You can start the window by running main.py
You can start the window by running `psychtobase/main.py`,
or alternatively run `build.bat` to build the application yourself.

Note that your build won't have a signature/key/what ever you call it, so Windows Defender will probably delete it. Github actions makes builds that don't have this issue, so use these instead.

## License
FNF Porter is licensed under CC-BY-NC 4.0. That means you can modify it, but you have to credit the authors (Gusborg, tposejank, BombasticTom & VocalFan), and you can't make ANY money from it. Because this doesn't use any assets from FNF, it's license doesn't apply here.
FNF Porter is licensed under CC-BY-NC 4.0. That means you can modify it, but you have to credit the authors (Gusborg, tposejank, BombasticTom & VocalFan), and you can't make ANY money from it. Because this doesn't use any assets from Funkin' Crew, their license doesn't apply here.

Read [LICENSE](LICENSE) for fancy legal words

This program uses FFmpeg, a free software made for manipulating all sorts of media throught codecs.
FFmpeg is protected under the LGPL v2.1 License.

Read [LICENSE](https://github.com/gusborg88/fnf-porter/blob/main/LICENSE) for fancy legal words
Read [FFmpeg's license](FFMPEG-LICENSE)
4 changes: 1 addition & 3 deletions build.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
pyinstaller --onefile --icon=icon.ico -n "FNF Porter" psychtobase/main.py
cd dist
"FNF Porter.exe"
pyinstaller build.spec
52 changes: 52 additions & 0 deletions build.spec
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# -*- mode: python ; coding: utf-8 -*-


a = Analysis(
['psychtobase\\main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
noarchive=False,
optimize=0,
)
pyz = PYZ(a.pure)

import platform
iconArr = []

if platform.system() == 'Darwin':
iconArr = ['icon.icns']
elif platform.system() == 'Windows':
iconArr = ['icon.ico']

exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
name='FNF Porter',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=False,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
icon=iconArr,
)

import shutil
if platform.system() == 'Windows':
shutil.copyfile('ffmpeg.exe', '{0}/ffmpeg.exe'.format(DISTPATH))
shutil.copyfile('FFMPEG-LICENSE', '{0}/FFMPEG_LICENSE.txt'.format(DISTPATH))
Binary file added ffmpeg.exe
Binary file not shown.
Binary file added images/big-icon.webp
Binary file not shown.
25 changes: 25 additions & 0 deletions psychtobase/src/tools/VocalSplit.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
import logging
from pathlib import Path
import numpy as np

from pydub import AudioSegment
import platform

def assignFfmpeg(audiosegment:AudioSegment):
if platform.system() == 'Windows':
ffmpeg_path = Path('ffmpeg.exe')

if Path.exists(ffmpeg_path):
ffmpeg_to_use = str(ffmpeg_path.resolve()).replace('\\', '/').replace('.exe', '')
print('FFmpeg for AudioSegment: ' + ffmpeg_to_use)
audiosegment.converter = ffmpeg_to_use
else:
logging.warn('FFmpeg path does not exist')
else:
logging.info('No effect, your platform is not Windows:' + platform.system())

def assignFfmpegBulk(audiosegments:list):
for audiosegment in audiosegments:
assignFfmpeg(audiosegment)

def vocalsplit(chart, bpm, origin, path, key, characters):
beatLength = (60 / bpm) * 1000
Expand Down Expand Up @@ -35,10 +54,14 @@ def vocalsplit(chart, bpm, origin, path, key, characters):

songSteps += section.get('lengthInSteps', 16)

assignFfmpegBulk([AudioSegment])

originalVocals = AudioSegment.from_ogg(origin + "Voices.ogg")
vocalsBF = AudioSegment.empty()
vocalsOpponent = AudioSegment.empty()

assignFfmpegBulk([vocalsBF, vocalsOpponent])

arr = np.array(sectionDirs)

arr = arr[arr[:,0].argsort()]
Expand All @@ -51,6 +74,8 @@ def vocalsplit(chart, bpm, origin, path, key, characters):
chunk = originalVocals[section_start_time:next_section_time]
silence = AudioSegment.silent(duration=len(chunk))

# assignFfmpeg(silence)

if arr[i, 2] or arr[i, 1] == False: # Duet or not must hit
vocalsOpponent += chunk
vocalsBF += silence
Expand Down
4 changes: 2 additions & 2 deletions psychtobase/src/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

_windowTitleSuffix = f"v{Constants.VERSION} [BETA]"
_defaultsFile = '.defaults'
_vocalSplitEnabledByDefault = False
_vocalSplitEnabledByDefault = platform.system() == 'Windows'

app = QApplication([])
class SimpleDialog(QDialog):
Expand Down Expand Up @@ -613,7 +613,7 @@ def init():

#work in progress
#Window.throwError(self=QDialog, text='d', actual_error_text='poooop')
print('pooop')
# print('pooop')

app.exec()

Expand Down

0 comments on commit 01260fa

Please sign in to comment.