1
0
mirror of https://github.com/kkroening/ffmpeg-python.git synced 2025-04-06 04:15:44 +08:00

Support python3

This commit is contained in:
Karl Kroening 2017-06-13 19:37:14 -06:00
parent eb9e8270cd
commit cd3d3715b8
7 changed files with 19 additions and 6 deletions

2
.gitignore vendored

@ -1,4 +1,4 @@
.cache
dist/
ffmpeg/tests/sample_data/dummy2.mp4
venv
venv*

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from . import _filters, _ffmpeg, _run
from ._filters import *
from ._ffmpeg import *

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .nodes import (
FilterNode,
GlobalNode,

@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .nodes import (
FilterNode,
operator,

@ -1,3 +1,6 @@
from __future__ import unicode_literals
from past.builtins import basestring
import operator as _operator
import subprocess as _subprocess
@ -13,6 +16,7 @@ from .nodes import (
operator,
OutputNode,
)
from functools import reduce
def _get_stream_name(name):
return '[{}]'.format(name)

@ -1,3 +1,6 @@
from __future__ import unicode_literals
from builtins import object
import hashlib
import json
@ -18,15 +21,18 @@ class Node(object):
formatted_props += ['{}={!r}'.format(key, self._kwargs[key]) for key in sorted(self._kwargs)]
return '{}({})'.format(self._name, ','.join(formatted_props))
def __hash__(self):
return int(self._hash, base=16)
def __eq__(self, other):
return self._hash == other._hash
def _update_hash(self):
props = {'args': self._args, 'kwargs': self._kwargs}
my_hash = hashlib.md5(json.dumps(props, sort_keys=True)).hexdigest()
my_hash = hashlib.md5(json.dumps(props, sort_keys=True).encode('utf-8')).hexdigest()
parent_hashes = [parent._hash for parent in self._parents]
hashes = parent_hashes + [my_hash]
self._hash = hashlib.md5(','.join(hashes)).hexdigest()
self._hash = hashlib.md5(','.join(hashes).encode('utf-8')).hexdigest()
class InputNode(Node):

@ -1,4 +1,4 @@
from ffmpeg.nodes import operator, FilterNode
from __future__ import unicode_literals
import ffmpeg
import os
import pytest
@ -72,12 +72,12 @@ def test_repr():
trim3 = ffmpeg.trim(in_file, start_frame=50, end_frame=60)
concatted = ffmpeg.concat(trim1, trim2, trim3)
output = ffmpeg.output(concatted, 'dummy2.mp4')
assert repr(in_file) == "input(filename='dummy.mp4')"
assert repr(in_file) == "input(filename={!r})".format('dummy.mp4')
assert repr(trim1) == "trim(end_frame=20,start_frame=10)"
assert repr(trim2) == "trim(end_frame=40,start_frame=30)"
assert repr(trim3) == "trim(end_frame=60,start_frame=50)"
assert repr(concatted) == "concat(n=3)"
assert repr(output) == "output(filename='dummy2.mp4')"
assert repr(output) == "output(filename={!r})".format('dummy2.mp4')
def test_get_args_simple():