8000 Support python3 · Powercoder64/ffmpeg-python@cd3d371 · GitHub
[go: up one dir, main page]

Skip to content

Commit cd3d371

Browse files
committed
Support python3
1 parent eb9e827 commit cd3d371

File tree

7 files changed

+19
-6
lines changed

7 files changed

+19
-6
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 8000 @@
11
.cache
22
dist/
33
ffmpeg/tests/sample_data/dummy2.mp4
4-
venv
4+
venv*

ffmpeg/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from . import _filters, _ffmpeg, _run
23
from ._filters import *
34
from ._ffmpeg import *

ffmpeg/_ffmpeg.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from .nodes import (
23
FilterNode,
34
GlobalNode,

ffmpeg/_filters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
from __future__ import unicode_literals
12
from .nodes import (
23
FilterNode,
34
operator,

ffmpeg/_run.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import unicode_literals
2+
3+
from past.builtins import basestring
14
import operator as _operator
25
import subprocess as _subprocess
36

@@ -13,6 +16,7 @@
1316
operator,
1417
OutputNode,
1518
)
19+
from functools import reduce
1620

1721
def _get_stream_name(name):
1822
return '[{}]'.format(name)

ffmpeg/nodes.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from __future__ import unicode_literals
2+
3+
from builtins import object
14
import hashlib
25
import json
36

@@ -18,15 +21,18 @@ def __repr__(self):
1821
formatted_props += ['{}={!r}'.format(key, self._kwargs[key]) for key in sorted(self._kwargs)]
1922
return '{}({})'.format(self._name, ','.join(formatted_props))
2023

24+
def __hash__(self):
25+
return int(self._hash, base=16)
26+
2127
def __eq__(self, other):
2228
return self._hash == other._hash
2329

2430
def _update_hash(self):
2531
props = {'args': self._args, 'kwargs': self._kwargs}
26-
my_hash = hashlib.md5(json.dumps(props, sort_keys=True)).hexdigest()
32+
my_hash = hashlib.md5(json.dumps(props, sort_keys=True).encode('utf-8')).hexdigest()
2733
parent_hashes = [parent._hash for parent in self._parents]
2834
hashes = parent_hashes + [my_hash]
29-
self._hash = hashlib.md5(','.join(hashes)).hexdigest()
35+
self._hash = hashlib.md5(','.join(hashes).encode('utf-8')).hexdigest()
3036

3137

3238
class InputNode(Node):

ffmpeg/tests/test_ffmpeg.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from ffmpeg.nodes import operator, FilterNode
1+
from __future__ import unicode_literals
22
import ffmpeg
33
import os
44
import pytest
@@ -72,12 +72,12 @@ def test_repr():
7272
trim3 = ffmpeg.trim(in_file, start_frame=50, end_frame=60)
7373
concatted = ffmpeg.concat(trim1, trim2, trim3)
7474
output = ffmpeg.output(concatted, 'dummy2.mp4')
75-
assert repr(in_file) == "input(filename='dummy.mp4')"
75+
assert repr(in_file) == "input(filename={!r})".format('dummy.mp4')
7676
assert repr(trim1) == "trim(end_frame=20,start_frame=10)"
7777
assert repr(trim2) == "trim(end_frame=40,start_frame=30)"
7878
assert repr(trim3) == "trim(end_frame=60,start_frame=50)"
7979
assert repr(concatted) == "concat(n=3)"
80-
assert repr(output) == "output(filename='dummy2.mp4')"
80+
assert repr(output) == "output(filename={!r})".format('dummy2.mp4')
8181

8282

8383
def test_get_args_simple():

0 commit comments

Comments
 (0)
0