简体   繁体   中英

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'".

I then tried putting it in one of my python paths listed in sys.path and again I got the same message.

I then opened .bashrc and added the home directory path and still got the same error message when I ran my script.

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. Pyav has the python bindings (small programms) to run ffmpeg. Best of all as conda also installs the needed binaries, it also installs an ffmpeg to use.

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

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 | -vsync 1 notes that their should be vertical synchronisation | -r is the frame rate of the movie | -qscale is the quality (1 being best and slowest) | -an -y no sound if I remeber correctly | 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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