简体   繁体   English

Ubuntu 16.04 Python安装第三方模块ffmpeg-3.0.2

[英]Ubuntu 16.04 python installing 3rd party module ffmpeg-3.0.2

Have tried installing this package multiple times. 尝试多次安装此软件包。 Initially I installed it to a directory where I am running scripts that call it but I get an error message "ImportError: No module named 'ffmpeg'". 最初,我将其安装在运行脚本的目录中,但是会收到错误消息“ ImportError:没有名为'ffmpeg'的模块”。

I then tried putting it in one of my python paths listed in sys.path and again I got the same message. 然后,我尝试将其放在sys.path中列出的python路径之一中,再次得到相同的消息。

I then opened .bashrc and added the home directory path and still got the same error message when I ran my script. 然后,我打开.bashrc并添加了主目录路径,但在运行脚本时仍然收到相同的错误消息。

import sys
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import ffmpeg

from PIL import Image

img = sys.argv[1] # ignore this

im = Image.open(img) # ignore this
imarray = np.array(im) # ignore this

ffmpeg -i ('flame.avi') -f image2 -c:v mjpeg ('image-%d.jpg')
avconv -i ('flame.avi') -vsync ('1') -r ('100') ('image%03d.tif')

I'm really not sure where to go, what are my options here? 我真的不确定要去哪里,这里有什么选择? And what am I doing that is glaringly wrong? 我在做什么,这显然是错误的?

If you allready use Conda, than I would recommend installing pyav via Conda. 如果您已经使用Conda,那么我建议您通过Conda安装pyav。 Pyav has the python bindings (small programms) to run ffmpeg. Pyav具有运行ffmpeg的python绑定(小程序)。 Best of all as conda also installs the needed binaries, it also installs an ffmpeg to use. 最棒的是,conda还安装了所需的二进制文件,还安装了要使用的ffmpeg。

If you just want to split your movie into a series of images you can do this from the bash using ffmpeg or libav's avconv 如果您只想将电影分割成一系列图像,则可以使用ffmpeg或libav的avconv从bash中进行操作

avconv -i ./SOURCE_NAME.avi -vsync 1 -r FRAMES_PER_SECOND -qscale 1 -an -y './PATH/TO_FILES/frame_%4d.jpg'

where -i demarks the source file | -i标记源文件| -vsync 1 notes that their should be vertical synchronisation | -vsync 1注意它们应该是垂直同步| -r is the frame rate of the movie | -r是电影的帧速率| -qscale is the quality (1 being best and slowest) | -qscale是质量(1是最好和最慢)| -an -y no sound if I remeber correctly | -an -y如果我正确记住,则没有声音| then you give it the target destination where %4d means the frame number with 4 leading zeros, so files will be called frame_0001.jpg, frame_0002.jpg, etc. 然后将其指定为目标位置,其中%4d表示带有4个前导零的帧号,因此文件将称为frame_0001.jpg,frame_0002.jpg等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM