Giter VIP home page Giter VIP logo

Comments (15)

Zulko avatar Zulko commented on August 28, 2024

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.

almarklein avatar almarklein commented on August 28, 2024

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.

almarklein avatar almarklein commented on August 28, 2024

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.

Zulko avatar Zulko commented on August 28, 2024

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.

almarklein avatar almarklein commented on August 28, 2024

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.

Zulko avatar Zulko commented on August 28, 2024

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.

almarklein avatar almarklein commented on August 28, 2024

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.

Zulko avatar Zulko commented on August 28, 2024

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.

almarklein avatar almarklein commented on August 28, 2024

ffmpeg -v gives you that?

from moviepy.

Zulko avatar Zulko commented on August 28, 2024

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.

rainerfritz avatar rainerfritz commented on August 28, 2024

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.

Zulko avatar Zulko commented on August 28, 2024

@rainerfritz Can you paste the entire error message and the entire code you used ?

from moviepy.

rainerfritz avatar rainerfritz commented on August 28, 2024

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.

Zulko avatar Zulko commented on August 28, 2024

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.

rainerfritz avatar rainerfritz commented on August 28, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.