Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VideoFileClip instance has no attribute 'reader' #512

Closed
nataliaperina opened this issue Mar 27, 2017 · 14 comments
Closed

VideoFileClip instance has no attribute 'reader' #512

nataliaperina opened this issue Mar 27, 2017 · 14 comments

Comments

@nataliaperina
Copy link

nataliaperina commented Mar 27, 2017

I am trying just a simple program to read in a video file:

from moviepy.editor import VideoFileClip, concatenate_videoclips
from moviepy.editor import *
def testVid():
    clip = VideoFileClip("Harvard2014.mp4").subclip(1.0,5.0)
    print(clip.duration)
    filename = "subclip_test.mp4"
    clip.write_videofile(filename)
testVid()

Nothing happens for a while and then upon interrupting the program, I keep getting this error:

File "testvid.py", line 1113, in <module>
    run()
  File "testvid.py", line 1102, in run
    testVid()
  File "testvid.py", line 1092, in testVid
    clip = VideoFileClip("Harvard2014.mp4").subclip(1.0,5.0)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/VideoFileClip.py", line 57, in __init__
    reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 32, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 240, in ffmpeg_parse_infos
    proc.stdout.readline()
KeyboardInterrupt

I have reinstalled the newest version ffmpeg and moviepy but havent gotten anywhere. I have seen some people had similar issues when using multiple clips at once, but none of the solutions have helped me. I am running on a MAC OSX.

@tburrows13
Copy link
Collaborator

tburrows13 commented Mar 27, 2017

Can you try using the latest build from the repo? If you're unsure how to do that, let us know either here or on the gitter chat.
The error you are getting upon interrupting is just that; an error because you interrupted it. Why do you say it is a problem with the reader? It appears that it just gets stuck. Have you tried it with a few different videos?

@nataliaperina
Copy link
Author

nataliaperina commented Mar 27, 2017

Hi - do you mean the latest build of moviepy or ffmpeg? Ya - how do I do that?

Sorry - I didn't copy & paste the full error message previously. This is it and why I said there was an error with the reader (see last line):

  File "testvid.py", line 1113, in <module>
    run()
  File "testvid.py", line 1102, in run
    testVid()
  File "testvid.py", line 1092, in testVid
    clip1 = VideoFileClip("Harvard2014.mp4").subclip(1.0,5.0)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/VideoFileClip.py", line 57, in __init__
    reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 32, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
  File "/Library/Python/2.7/site-packages/moviepy/video/io/ffmpeg_reader.py", line 240, in ffmpeg_parse_infos
    proc.stdout.readline()
KeyboardInterrupt
Exception AttributeError: "VideoFileClip instance has no attribute 'reader'" in <bound method VideoFileClip.__del__ of <moviepy.video.io.VideoFileClip.VideoFileClip instance at 0x104d38878>> ignored

Yes, it is getting stuck but I don't know why. I have tried with several different videos, all of which get stuck infinitely until I interrupt.

Thanks!

@tburrows13
Copy link
Collaborator

@nataliaperina ah ok, I meant moviepy not ffmpeg. As for how to do it, go to the main 'code' page on Github, then click on "Clone or download", then "Download ZIP". This will place the entire code for moviepy inside you computer's download folder. From here, you can run your programs inside the initial folder, and it should read from the downloaded folder instead of your computed install. You can put a print("Success") somewhere inside the downloaded folder to make sure it is using the downloaded version.

Alternatively, you can replace the folder where pip installs packages to with the new moviepy folder, or do fancy stuff with git clone etc.

Or, you can wait until we release the next version to PyPI and then simply run pip install moviepy --upgrade. Not sure when this will be though; hopefully soon...!

@nataliaperina
Copy link
Author

Ok I ran it from that folder with the most recent version. Same problem. Any idea why this is??

@tburrows13
Copy link
Collaborator

Can you confirm it was using the right version? (Either by removing moviepy with pip, or printing something unique?)
I'm afraid I have no idea, hopefully someone else can.

@Zulko
Copy link
Owner

Zulko commented Mar 27, 2017

  • does the clip duration print ? (before or after you interrupt)
  • If not, try printing something before the line testVid. Does it print ?
  • Do you observe that hanging with your video in particular, or with other videos too ? (EDIT: oops missed that, several videos, ok, are they all from the same source ?)
  • In the first case, any chance you can provide a video for us to reproduce the bug ?

@nataliaperina
Copy link
Author

nataliaperina commented Mar 27, 2017

I am running now:

print("before testVid")
def testVid():
    print ("Hello!")
    clip = VideoFileClip("big_buck_bunny.mp4").subclip(1.0,5.0)
    print(clip.duration)
    filename = "subclip_test.mp4"
    clip.write_videofile(filename)
    del clip
def run():
    testVid()
run()

I also added a print("success") in the download moviepy version so that I know I am running with that version.

"before test vid", "success", and "hello!" all print before the interrupt, but the clip duration does not print either before or after the interrupt. It occurs with every .mp4 video that I have been trying to run (even test ones downloaded from the internet). This is the output - no longer shows the reader instance error.

File "testvid.py", line 1113, in <module>
    run()
  File "testvid.py", line 1102, in run
    testVid()
  File "testvid.py", line 1093, in testVid
    clip = VideoFileClip("big_buck_bunny.mp4").subclip(1.0,5.0)
  File "/Users/nperina/Downloads/moviepy-master/moviepy/video/io/VideoFileClip.py", line 73, in __init__
    resize_algo=resize_algorithm)
  File "/Users/nperina/Downloads/moviepy-master/moviepy/video/io/ffmpeg_reader.py", line 30, in __init__
    infos = ffmpeg_parse_infos(filename, print_infos, check_duration)
  File "/Users/nperina/Downloads/moviepy-master/moviepy/video/io/ffmpeg_reader.py", line 253, in ffmpeg_parse_infos
    proc.stdout.readline()

@ghost
Copy link

ghost commented Mar 28, 2017

are you running this from the command line?

@nataliaperina
Copy link
Author

nataliaperina commented Mar 28, 2017

No these lines are all in a file testvid.py which i (yes?) do run from the command line with the command python testvid.py

@ghost
Copy link

ghost commented Mar 30, 2017

@nataliaperina .. yes that is what I meant.. I was afraid you were running it from some type of editor, which might be hiding some of the errors..

@ghost
Copy link

ghost commented Mar 30, 2017

@nataliaperina can you try this with:
https://github.com/earney/moviepy_media/raw/master/tests/videos/big_buck_bunny_0_30.webm
This isn't a mp4 but we can see if this works, and then can try a few mp4 files. Can you give us a url of a mp4 that fails for you?

@nataliaperina
Copy link
Author

I have no idea what happened but somehow after running another clean install of numpy, ffmpeg, and moviepy, the code is now working!

thanks!

@ghost
Copy link

ghost commented Mar 30, 2017

I'll close this issue. Please reopen if necessary.

@ghost ghost closed this as completed Mar 30, 2017
@stela
Copy link

stela commented Nov 9, 2017

Same problem appears to happen to me too after I reinstalled ffmpeg on macOS 10.13.1. Temporarily enabled sdl2 to get ffplay built, reinstalled it without sdl2/ffplay and it still fails :(
It hangs while ffmpeg is started but seems idle, no CPU is consumed by it:

$ ps uax | grep ffmp
stela            20296   0.0  0.1  4305324  11140   ??  S    12:41AM   0:00.02 ffmpeg -i test_video.mp4

Get this stack trace in the Pycharm console:

Traceback (most recent call last):
  File "/Users/stela/PycharmProjects/CarND-Vehicle-Detection/vehicle_detection.py", line 376, in <module>
    vehicle_detection_main()
  File "/Users/stela/PycharmProjects/CarND-Vehicle-Detection/vehicle_detection.py", line 369, in vehicle_detection_main
    process_video('test_video.mp4', 'output_images/test_video_out.mp4', part_process_image)
  File "/Users/stela/PycharmProjects/CarND-Vehicle-Detection/vehicle_detection.py", line 351, in process_video
    clip = VideoFileClip(input)
  File "/Users/stela/miniconda3/envs/carnd-term1/lib/python3.5/site-packages/moviepy/video/io/VideoFileClip.py", line 81, in __init__
    fps_source=fps_source)
  File "/Users/stela/miniconda3/envs/carnd-term1/lib/python3.5/site-packages/moviepy/video/io/ffmpeg_reader.py", line 32, in __init__
    fps_source)
  File "/Users/stela/miniconda3/envs/carnd-term1/lib/python3.5/site-packages/moviepy/video/io/ffmpeg_reader.py", line 258, in ffmpeg_parse_infos
    proc.stdout.readline()
KeyboardInterrupt

Using moviepy 0.2.3.2

Update: I just rebooted my mac without any further changes and now it suddenly works again?!

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants