kkroening / ffmpeg-python

Python bindings for FFmpeg - with complex filtering support
Apache License 2.0
9.99k stars 886 forks source link

Library problem under python 2.7 #166

Open eeerrrwwwuuu opened 5 years ago

eeerrrwwwuuu commented 5 years ago

Hello, I'm trying to import ffmpeg into python script, but it looks like I have syntax problem.

import ffmpeg
stream = ffmpeg.input('input.mp4')
stream = ffmpeg.hflip(stream)
stream = ffmpeg.output(stream, 'output.mp4')
ffmpeg.run(stream)

I get syntax error

  File "pipe_stream.py", line 29, in <module>
    import ffmpeg
  File "/home/nvidia/.local/lib/python2.7/site-packages/ffmpeg/__init__.py", line 1, in <module>
    from .ffmpeg import FFmpegError
  File "/home/nvidia/.local/lib/python2.7/site-packages/ffmpeg/ffmpeg.py", line 52
    self._input_files.append(FFmpeg._File(url=url, options={**options, **kwargs}))
                                                             ^
SyntaxError: invalid syntax
sknick commented 5 years ago

Same here.

153957 commented 5 years ago

This should work fine in Python 3.x. So if you can upgrade to Python 3 that could solve it for now (you should upgrade this year anyway).

sknick commented 5 years ago

Ya, we have begun that transition but there are of course legacy things around... I would recommend you at least make the Python 3 only restriction clearer in the documentation (maybe it is, but I didn't see it).

153957 commented 5 years ago

You are correct, the code is also tested with Python 2.7 on Travis: https://github.com/kkroening/ffmpeg-python/blob/master/.travis.yml#L11

But not this cases it would seem..

kkroening commented 5 years ago

The error doesn't look like it came from this ffmpeg-python library. How did you install ffmpeg-python?

Note that it's pip install ffmpeg-python, not pip install ffmpeg or whatever.

Taysssir commented 3 years ago

The same problem for me, it works fine with Python3 but not with 2.7