Comments (15)
Thanks for the feedback. When you say you reinstalled ffmpeg, did you use the binary of the last version on the FFMPEG website ? What format are you video in ? Have you tried different video formats ? Could you try FFMPEG_VideoReader(filename, print_infos=True)
and paste the output ?
Edit: I don't think the package is Python3 compatible, this is next in my todo list (should not be problematic).
from moviepy.
Output of one example file:
ffmpeg version 0.8.9-6:0.8.9-0ubuntu0.13.10.1, Copyright (c) 2000-2013 the Libav developers
built on Nov 9 2013 19:09:46 with gcc 4.8.1
*** THIS PROGRAM IS DEPRECATED ***
This program is only provided for compatibility and will be removed in a future release. Please use avconv instead.
Input #0, avi, from '/home/almar/data/movs/MVI_1006.AVI':
Metadata:
creation_time : 2008-08-15 11:56:25
encoder : CanonMVI02
Duration: 00:00:10.59, start: 0.000000, bitrate: 7590 kb/s
Stream #0.0: Video: mjpeg, yuvj422p, 640x480, 15 tbr, 15 tbn, 15 tbc
Stream #0.1: Audio: pcm_u8, 11024 Hz, 1 channels, u8, 88 kb/s
Unable to find a suitable output format for 'pipe:'
I have tried a few different videos of different formats (.mpg. mp4, .wmv .AVI).
from moviepy.
As you see in last comment, the version that comes with Ubuntu 13.10 is quite old. When I try the latest version from the website it does work. woohoo!
Also, when I use -vcodec png
or bmp
, it works with my system version as well. Although you need a second library to convert the images to raw RGB values.
from moviepy.
Maybe I should really stress in the docs the importance of downloading FFMPEG from the site (all the Ubuntu/Debian users have this problem). I didn't get you last sentence, what did you mean exactly ?
from moviepy.
In the initialize() method, when I set '-vcodec', 'png'
(instead of rawvideo
) and then in read_frame() convert the bytes to raw RGB data, it works ok too. This would mean, that it could work with native Linux ffmpeg.
This could perhaps be a nice fallback, since many Linuxes come with ffmpeg (albeit an old version).
from moviepy.
Ah, I get it. And then convert to raw RBG using PIL for instance. Yes that would be a workaround, but with some inconveniences:
- It would make PIL (or other) mandatory, while here only numpy is required.
- It would make 'silently' the program be slower for these users.
- I am not sure if there are other commands in MoviePy that break with the former FFMPEG.
- Really the FFMPEG on Debian/Ubuntu is buggy (in many videos it adds a black stripe on the side of the video). See this video, on the right: http://www.youtube.com/watch?v=aC5CifkacSI
from moviepy.
Yes, you are right on these points.
Also, the png trick now only works for the first frame. Kind of makes sense, since you cannot know beforehand how large the file would be that ffmpeg will stream over the Pipe... it would need some extra work to split the returned bytes and use the remainder for the next image :( would add to code complexity.
Perhaps a check on ffmpeg version and give a warning if its < 1?
from moviepy.
That is a good Idea. I don't know how to do that exactly (my version number of FFMPEG is N-58039-gda9d360, it's strange) but I could at least spot the deprecated version of Debuntu and send a warning. Thanks !
from moviepy.
ffmpeg -v
gives you that?
from moviepy.
Yup (ffmpeg -version
, to be precise). And this is a perfectly
functional version (it's a binary I took from the website). I don't know
if I am the only one around with a crypted version number...
Le 29/01/2014 23:03, Almar Klein a Γ©crit :
|ffmpeg -v| gives you /that/?
β
Reply to this email directly or view it on GitHub
#8 (comment).
from moviepy.
when I use it like this: image = ffmpeg_read_image(filename)
then I get an error from ffmpeg:
Unable to find a suitable output format for 'pipe:'
where my inputfile is an mp4 with h264
from moviepy.
@rainerfritz Can you paste the entire error message and the entire code you used ?
from moviepy.
Code is here: http://dcs.co.at/files/ffmpeg_read_rgb.py
Error MSG is:
[NULL @ 0x342be60] Unable to find a suitable output format for 'pipe:'
pipe:: Invalid argument
ffmpeg is giving this error...
finaly I want to to read rgb values of the frames and putting them in a numpy array to work
with them...
from moviepy.
This isn't clear in the documentation, but ffmpeg_read_image is for image files (PNG, BMP etc.). It should work for movies too, but it can only get the first frame. It is strange that it doesn't work on your computer, it works on mine (Ubuntu). What is your version of FFMPEG ? Did you download it directly from the website ?
To get frames with the FFMPEG reader you do this:
reader = FFMPEG_VideoReader('v/f1.mp4')
for i in range(reader.nframes):
frame = reader.read_frame() # a WxHx3 numpy RGB array
# do stuff with the frame
You can also directly import MoviePy:
from moviepy.video.io.VideoFileClip import VideoFileClip
clip = VideoFileClip("myfile.mp4")
clip.get_frame(t) # gets the numpy array of the frame at time t
for frame in clip.iter_frames():
# do whatever you want with the numpy frame
from moviepy.
FFMPEG is V2.2 and compiled from the ffmpeg source. OS is Ubuntu 14.04
I'm thinking on applying a 3D LUT after reading the frames and writing the converted picture out to compress it then... that is the reason why I came to your module, because I want to read frame by frame a video file...
If I want to plot a frame with matplotlib I get also an error:
File "moviepy_test.py", line 6, in
clip.get_frame(t) # gets the numpy array of the frame at time t
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.7.21-py2.7.egg/moviepy/video/io/VideoFileClip.py", line 66, in
self.get_frame = lambda t: self.reader.get_frame(t)
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.7.21-py2.7.egg/moviepy/video/io/ffmpeg_reader.py", line 134, in get_frame
result = self.read_frame()
File "/usr/local/lib/python2.7/dist-packages/moviepy-0.2.1.7.21-py2.7.egg/moviepy/video/io/ffmpeg_reader.py", line 89, in read_frame
assert len(s) == nbytes
AssertionError
Code:
from moviepy.video.io.VideoFileClip import VideoFileClip
import matplotlib.pyplot as plt
t = '00:00:00:01'
clip = VideoFileClip("/media/rainer/LinuxData/GOPR1678.MP4")
clip.get_frame(t) # gets the numpy array of the frame at time t
for frame in clip.iter_frames():
# do whatever you want with the numpy frame
imgplot = plt.imshow(frame)
from moviepy.
Related Issues (20)
- No sound HOT 2
- how to keep the aspect ratio for my vertical video? HOT 5
- I cut 1800 seconds of audio, but the result is 1846 seconds. Why is this happening? How can I solve this problem?
- Resizable rounded rectangle
- Getting `AttributeError: 'NoneType' object has no attribute 'get_frame'` when trying to save a `CompositeVideoClip`
- Error When Generating a Long video and not getting the error when generating a shorter video HOT 1
- AttributeError: 'NoneType' object has no attribute 'get_frame' when calling write_videofile HOT 1
- Vertical MOV video to MP4 HOT 3
- yielding write_videofile progress HOT 5
- Output video without sound
- Inconsistent video duration before and after write_videofile HOT 1
- Audio glitching when concatenating with moviepy
- Error Using MoviePy in Django Project on Linux (Python 3.12, MoviePy 1.0.3)
- Adapt to setuptools v72 HOT 4
- How to obtain an AudioArrayClip or AudioFileClip object from a MP3 BytesIO object?
- CompositeAudioClip not compute duration
- Documentation in a PDF or any other downloadable format please?
- Incorrect Rendering of Bengali Ligatures in Subtitles Using MoviePy HOT 2
- How to set opacity in text_clip using Lambda HOT 1
- Moviepy unable to concatenate a long list of videos but is able to concatenate a short list of videos
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from moviepy.