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

[Request] Automatically install ffms2 #34

Open
moi15moi opened this issue Sep 4, 2022 · 5 comments
Open

[Request] Automatically install ffms2 #34

moi15moi opened this issue Sep 4, 2022 · 5 comments

Comments

@moi15moi
Copy link

moi15moi commented Sep 4, 2022

It would be nice if when we install this tool, it could also install ffms2.

It make it user friendly and when a another program need this tool, it does not need to ask the user to install ffms2 by themself.

@moi15moi
Copy link
Author

@rr- Is there any problem with my request?

@CoffeeStraw
Copy link

Hi, I am interested in this feature as well!
To specify, I think that a "local" installation of ffms2 is preferable (so, have a version of ffms2 inside the library folder), as users may have their own ffms2 already installed somewhere else.

@rr-
Copy link
Collaborator

rr- commented Sep 18, 2022

cc @Luni-4

@Luni-4
Copy link
Member

Luni-4 commented Sep 21, 2022

Hi, sorry for the late reply! Yeah, it is a good request, but currently I don't have time to implement it, PRs accepted though!

@moi15moi
Copy link
Author

moi15moi commented Sep 22, 2022

I won't do it.
I already have try locally, but I can't do nothing work really well.

But, here is what I did to download the latest ffms2 releases:

import ffms2
import json
import os
import re
import requests
import struct
from pyunpack import Archive

# Get ffms2 download url
ffms2Url = requests.get('https://api.github.com/repos/FFMS/ffms2/releases/latest')
ffms2Json = json.loads(ffms2Url.text)
ffms2UrlDownload = ffms2Json["assets"][0]["browser_download_url"]

# Download ffms2
response = requests.get(ffms2UrlDownload)
fname = re.findall("filename=(.+)", response.headers['content-disposition'])[0]
open(fname, "wb").write(response.content)

# Extract ffms2
Archive(fname).extractall(".")

# Get directory where ffms2.dll, ffms2.lib and ffmsindex.exe are
cpuArchitecture = "x64" if struct.calcsize("P")*8 == 64 else "x86"
ffms2Files = "./" + os.path.splitext(fname)[0] + "/" + cpuArchitecture # won't work with posix path

# Copy ffms2 files to pyffms2 directory
fileNames = os.listdir(ffms2Files)
for fileName in fileNames:
    shutil.move(os.path.join(ffms2Files, fileName), os.path.dirname((ffms2.__file__)))

PS, it need these two dependancy to unzip the file

pip install pyunpack
pip install patool

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

4 participants