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:
parent
eb9e8270cd
commit
cd3d3715b8
2
.gitignore
vendored
2
.gitignore
vendored
@ -1,4 +1,4 @@
|
|||||||
.cache
|
.cache
|
||||||
dist/
|
dist/
|
||||||
ffmpeg/tests/sample_data/dummy2.mp4
|
ffmpeg/tests/sample_data/dummy2.mp4
|
||||||
venv
|
venv*
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from . import _filters, _ffmpeg, _run
|
from . import _filters, _ffmpeg, _run
|
||||||
from ._filters import *
|
from ._filters import *
|
||||||
from ._ffmpeg import *
|
from ._ffmpeg import *
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from .nodes import (
|
from .nodes import (
|
||||||
FilterNode,
|
FilterNode,
|
||||||
GlobalNode,
|
GlobalNode,
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
from .nodes import (
|
from .nodes import (
|
||||||
FilterNode,
|
FilterNode,
|
||||||
operator,
|
operator,
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from past.builtins import basestring
|
||||||
import operator as _operator
|
import operator as _operator
|
||||||
import subprocess as _subprocess
|
import subprocess as _subprocess
|
||||||
|
|
||||||
@ -13,6 +16,7 @@ from .nodes import (
|
|||||||
operator,
|
operator,
|
||||||
OutputNode,
|
OutputNode,
|
||||||
)
|
)
|
||||||
|
from functools import reduce
|
||||||
|
|
||||||
def _get_stream_name(name):
|
def _get_stream_name(name):
|
||||||
return '[{}]'.format(name)
|
return '[{}]'.format(name)
|
||||||
|
@ -1,3 +1,6 @@
|
|||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
|
from builtins import object
|
||||||
import hashlib
|
import hashlib
|
||||||
import json
|
import json
|
||||||
|
|
||||||
@ -18,15 +21,18 @@ class Node(object):
|
|||||||
formatted_props += ['{}={!r}'.format(key, self._kwargs[key]) for key in sorted(self._kwargs)]
|
formatted_props += ['{}={!r}'.format(key, self._kwargs[key]) for key in sorted(self._kwargs)]
|
||||||
return '{}({})'.format(self._name, ','.join(formatted_props))
|
return '{}({})'.format(self._name, ','.join(formatted_props))
|
||||||
|
|
||||||
|
def __hash__(self):
|
||||||
|
return int(self._hash, base=16)
|
||||||
|
|
||||||
def __eq__(self, other):
|
def __eq__(self, other):
|
||||||
return self._hash == other._hash
|
return self._hash == other._hash
|
||||||
|
|
||||||
def _update_hash(self):
|
def _update_hash(self):
|
||||||
props = {'args': self._args, 'kwargs': self._kwargs}
|
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]
|
parent_hashes = [parent._hash for parent in self._parents]
|
||||||
hashes = parent_hashes + [my_hash]
|
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):
|
class InputNode(Node):
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
from ffmpeg.nodes import operator, FilterNode
|
from __future__ import unicode_literals
|
||||||
import ffmpeg
|
import ffmpeg
|
||||||
import os
|
import os
|
||||||
import pytest
|
import pytest
|
||||||
@ -72,12 +72,12 @@ def test_repr():
|
|||||||
trim3 = ffmpeg.trim(in_file, start_frame=50, end_frame=60)
|
trim3 = ffmpeg.trim(in_file, start_frame=50, end_frame=60)
|
||||||
concatted = ffmpeg.concat(trim1, trim2, trim3)
|
concatted = ffmpeg.concat(trim1, trim2, trim3)
|
||||||
output = ffmpeg.output(concatted, 'dummy2.mp4')
|
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(trim1) == "trim(end_frame=20,start_frame=10)"
|
||||||
assert repr(trim2) == "trim(end_frame=40,start_frame=30)"
|
assert repr(trim2) == "trim(end_frame=40,start_frame=30)"
|
||||||
assert repr(trim3) == "trim(end_frame=60,start_frame=50)"
|
assert repr(trim3) == "trim(end_frame=60,start_frame=50)"
|
||||||
assert repr(concatted) == "concat(n=3)"
|
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():
|
def test_get_args_simple():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user