Skip to content

Commit

Permalink
Merge pull request #140 from deuteronomy-works/master
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
amoh-godwin authored Dec 5, 2021
2 parents 017bee3 + 5ae997f commit b5fe294
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 7 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ FFmpeg wrapper for python. It uses FFmpeg binary to provide both FFmpeg and FFpr

The beautiful thing about it is that it comes with its own FFmpeg executable. It is compressed, making it the smallest you can find. And becuase its cross-platform and python 3, it is the only option available for building cross-platform apps with ffmpeg in python.

## FFmpeg Version
Uses current FFmpeg version 4.4

## Installation
pip install pyffmpeg

Expand Down Expand Up @@ -45,3 +48,9 @@ NB: The above digits is just for illustration

## Wiki
The wiki can be located [here](https://github.com/deuteronomy-works/pyffmpeg/wiki)

## Legal
This library uses prebuilt binaries of <a href=http://ffmpeg.org>FFmpeg</a> licensed under the <a href=http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>LGPLv2.1</a> and can be downloaded at the following links:
* Mac - <a href="https://evermeet.cx/ffmpeg/">here</a>
* Linux - <a href="https://johnvansickle.com/ffmpeg/">here</a>
* Windows - <a href="https://www.gyan.dev/ffmpeg/builds/">here</a>
Binary file removed _test/f.mp3
Binary file not shown.
3 changes: 2 additions & 1 deletion local_probe_t_est.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@


print(f.duration)
print(f.metadata)
for x in f.metadata:
print(x, '\n')
6 changes: 4 additions & 2 deletions pyffmpeg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,10 @@ def convert(self, input_file, output_file):
print(msg.format(self.loglevel))
self.loglevel = 'fatal'

options = f"{self._ffmpeg_file} -loglevel {self.loglevel} "
options += f"{self._over_write} -i {inf} {out}"
options = "{} -loglevel {} "
options = options.format(self._ffmpeg_file, self.loglevel)
options += "{} -i {} {}"
options = options.format(self._over_write, inf, out)
outP = Popen(options, shell=True, stdin=PIPE, stdout=PIPE, stderr=PIPE)
self._ffmpeg_instances['convert'] = outP
self.error = str(outP.stderr.read(), 'utf-8')
Expand Down
13 changes: 12 additions & 1 deletion pyffmpeg/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import os
from platform import system
from lzma import decompress
from lzma import decompress, compress
from base64 import b64decode, b64encode


Expand Down Expand Up @@ -62,6 +62,17 @@ def load_ffmpeg_bin(self):

return self.ffmpeg_file

def convert_to_py(self, fn: str, target: str):

with open(fn, 'rb') as f_file:
raw = f_file.read()

compressed = compress(raw)
bs4 = b64encode(compressed)
smtm = 'contents='+str(bs4)

with open(target+'.py', 'w') as t_file:
t_file.write(smtm)

def fix_splashes(options):
if system().lower() == 'windows':
Expand Down
7 changes: 6 additions & 1 deletion pyffmpeg/pseudo_ffprobe.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def __init__(self, file_name=None):
self.start = 0
self.bitrate = 0
self.type = ''
self.metadata = [[0, 1], 1] # mock indeces
self.metadata = [[{}, {}], {}] # mock indeces
self.other_metadata = {}
self._other_metadata = []

Expand Down Expand Up @@ -77,6 +77,11 @@ def _extract_fps(self, stream):

def _extract_all(self, stdout):
# pick only streams, all of them

if 'misdetection possible' in stdout:
print('File corrupt or codecs not available for the file')
return

all_streams = stdout.split('Stream mapping')[0]
all_streams = all_streams.split('Input')[1]

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

setup(
name='pyffmpeg',
version='2.0.5.1',
version='2.1.0',
description='FFmpeg wrapper for python',
long_description=long_desc,
long_description_content_type='text/markdown',
Expand All @@ -16,7 +16,7 @@
classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Development Status :: 5 - Production/Stable",
"Development Status :: 4 - Beta",
"Intended Audience :: Developers",
"License :: OSI Approved :: Apache Software License",
"Operating System :: OS Independent",
Expand Down

0 comments on commit b5fe294

Please sign in to comment.