8000 Add support for Python3 (fixes #10) by kkroening · Pull Request #12 · kkroening/ffmpeg-python · GitHub
[go: up one dir, main page]

Skip to content

Add support for Python3 (fixes #10) #12

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

Merged
merged 10 commits into from
Jun 16, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Support python3
  • Loading branch information
kkroening committed Jun 14, 2017
commit cd3d3715b8ed3d11290bd700822e8b37d8b9e873
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.cache
dist/
ffmpeg/tests/sample_data/dummy2.mp4
venv
venv*
1 change: 1 addition & 0 deletions ffmpeg/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
from . import _filters, _ffmpeg, _run
from ._filters import *
from ._ffmpeg import *
Expand Down
1 change: 1 addition & 0 deletions ffmpeg/_ffmpeg.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .nodes import (
FilterNode,
GlobalNode,
Expand Down
1 change: 1 addition & 0 deletions ffmpeg/_filters.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import unicode_literals
from .nodes import (
FilterNode,
operator,
Expand Down
4 changes: 4 additions & 0 deletions ffmpeg/_run.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import unicode_literals

from past.builtins import basestring
import operator as _operator
import subprocess as _subprocess

Expand All @@ -13,6 +16,7 @@
operator,
OutputNode,
)
from functools import reduce

def _get_stream_name(name):
return '[{}]'.format(name)
Expand Down
10 changes: 8 additions & 2 deletions ffmpeg/nodes.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from __future__ import unicode_literals

from builtins import object
import hashlib
import json

Expand All @@ -18,15 +21,18 @@ def __repr__(self):
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):
Expand Down
6 changes: 3 additions & 3 deletions ffmpeg/tests/test_ffmpeg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ffmpeg.nodes import operator, FilterNode
from __future__ import unicode_literals
import ffmpeg
import os
import pytest
Expand Down Expand Up @@ -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():
Expand Down
0