Troubles with 'media_player_mpy' - Unable to download 'ffmpeg.osx'
Hello everyone,
I just started using OS and basically I just want to run a finished experiment on my Mac. Already upon opening the experiment I get the following Bug:
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/item_store.py", line 161, in new
self.experiment, script, self.experiment.item_prefix())
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/plugins.py", line 361, in load_plugin
item_module = import_plugin(plugin, _type=_type)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/libopensesame/plugins.py", line 332, in import_plugin
return imp.load_source(plugin, path)
File "/Applications/OpenSesame.app/Contents/Resources/share/opensesame_plugins/media_player_mpy/media_player_mpy.py", line 42, in
import mediadecoder
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/mediadecoder/init.py", line 6, in
from mediadecoder.decoder import Decoder
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/mediadecoder/decoder.py", line 9, in
from moviepy.video.io.VideoFileClip import VideoFileClip
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/moviepy/video/io/VideoFileClip.py", line 3, in
from moviepy.video.VideoClip import VideoClip
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/moviepy/video/VideoClip.py", line 20, in
from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/moviepy/video/io/ffmpeg_writer.py", line 15, in
from moviepy.config import get_setting
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/moviepy/config.py", line 38, in
FFMPEG_BINARY = get_exe()
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/imageio/plugins/ffmpeg.py", line 52, in get_exe
exe = get_remote_file('ffmpeg/' + FNAME_PER_PLATFORM[plat])
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/imageio/core/fetching.py", line 98, in get_remote_file
_fetch_file(url, filename)
File "/Applications/OpenSesame.app/Contents/Resources/lib/python2.7/site-packages/imageio/core/fetching.py", line 154, in _fetch_file
os.path.basename(file_name))
IOError: Unable to download 'ffmpeg.osx'. Perhaps there is a no internet connection? If there is, please report this problem.
Although I can start the experiment, it crashes every time I want to continue.
I tried to initiate the ffmpeg-download dragging a visual stimulus into the experiment, but that didn't help either. I ve been trying this at different times and there is definitely nothing wrong with the internet connection.
Probably this is peanuts, but I am very thankful for any help indeed.
Comments
High aseesa,
That is weird. On the first run of media_player_mpy, OpenSesame needs to download a small package (ffmpeg.osx) that enables it to decode a wide array of video formats. This usually doesn't cause any trouble, but in your case it appears to not be able to download this file.
Could it be that the computer on which OpenSesame is running on has a firewall which blocks the connection? Or the University network does so? I would try again from a different network/wifi connection before we dive into this deeper. The file only needs to be downloaded once, so when you succeed, you're set to use media_player_mpy from wherever you want.
Hello Daniel, thank you for your quick response. I just tried it from another network and checked my firewall settings (although firewall is turned off it doesn't work) - and still get the same error messages.
Is there anything I could do manually to incorporate the ffmpeg.osx package?
Yes there is. You could try the following first. Start python and type:
but this is what OpenSesame does, so it probably doesn't work.
The alternative step is that you download ffmpeg yourself and place it in the right folder.
You should be able to get ffmpeg.osx at https://github.com/imageio/imageio-binaries/raw/master/ffmpeg
You copy the ffmpeg.osx to
/Users/<your_username>/Library/Application Support/imageio/ffmpeg
So to be clear, the last ffmpeg in this path is a folder, and in this folder you place the file ffmpeg.osx.If you fire up your experiment after doing this, it should now work and you should be able to play videos.
Thank you so much, I can finally open the experiment.
But I seem unable to reproduce audio stimuli in my experiment. (although I get no bugs...)
Do you have a hint for me what might be wrong?
No I would really need more information for that. Do you mean the video plays but there is no sound? Have you checked if
play audio
in the configuration panel is set tono
by accident?If you a trying to play separate sound files: there is indeed some trouble with audio rendering on OSX, because the pygame mixer (which is used for audio) is very flakey to say at best. We are trying to find a more durable solution than pygame mixer, but until we have there is no easy way to fix audio playback on the mac. Sorry for the inconvenience.
I got a similar problem when my computer was not connected to the internet. However, I did have ffmpeg.win.exe in some other location on my computer (in Psychopy libraries) . I did connect my computer to the internet and then OpenSesame would let me open and run my experiment. But when I checked whether ffmpeg.win.exe was downloaded again or copied - it didn't . It stayed the exact same place. Is it reasonable?
I just hesitate whether I should download ffmpeg.osx from the above link? but I don't find the path you wrote @Daniel . Where else can it be put?
(My problem is that the quality of the movies inside OS is worse than when I use Windows Media Player etc. The audio is OK but the visual stops and moves slowly. I am not sure whether it has anything to do with thee ffmeg or the media_player_mpy or it is related to anything else (avbin? what else could it be?)
Hi Daniel,
I have the same problem as Aseesa and Noa described and I get a very similar error message (posted below). I have manually downloaded the ffmpeg.osx file but like Noa, I cannot seem to find the correct path to put it (I only have an Appdata folder, no "application support" and when I search for imageo I find nothing).
The media_player_mpy plugin appears as an icon in the sidebar but it does not appear in my experiment and I get the error message I pasted below when I try to run the experiment.
I am currently logged in with our institutional admin account and wanted to install the latest OS version to the computer's local environment so we could use OS outside the instutional network. Could this have something do to with the problems I have?
On my other work computer (when I'm connected to the institution network and in my user environment) the plugin works beautifully and I have no issues with it all.
Thank you in advance for any advice!
Johanna
File "C:\Program Files\OpenSesame\lib\site-packages\libopensesame\item_store.py", line 161, in new
self.experiment, script, self.experiment.item_prefix())
File "C:\Program Files\OpenSesame\lib\site-packages\libopensesame\plugins.py", line 360, in load_plugin
item_module = import_plugin(plugin, _type=_type)
File "C:\Program Files\OpenSesame\lib\site-packages\libopensesame\plugins.py", line 331, in import_plugin
return imp.load_source(plugin, path)
File "C:\Program Files\OpenSesame\share\opensesame_plugins\media_player_mpy\media_player_mpy.py", line 42, in
import mediadecoder
File "C:\Program Files\OpenSesame\lib\site-packages\mediadecoder__init__.py", line 6, in
from mediadecoder.decoder import Decoder
File "C:\Program Files\OpenSesame\lib\site-packages\mediadecoder\decoder.py", line 9, in
from moviepy.video.io.VideoFileClip import VideoFileClip
File "C:\Program Files\OpenSesame\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 3, in
from moviepy.video.VideoClip import VideoClip
File "C:\Program Files\OpenSesame\lib\site-packages\moviepy\video\VideoClip.py", line 20, in
from .io.ffmpeg_writer import ffmpeg_write_image, ffmpeg_write_video
File "C:\Program Files\OpenSesame\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 15, in
from moviepy.config import get_setting
File "C:\Program Files\OpenSesame\lib\site-packages\moviepy\config.py", line 38, in
FFMPEG_BINARY = get_exe()
File "C:\Program Files\OpenSesame\lib\site-packages\imageio\plugins\ffmpeg.py", line 52, in get_exe
exe = get_remote_file('ffmpeg/' + FNAME_PER_PLATFORM[plat])
File "C:\Program Files\OpenSesame\lib\site-packages\imageio\core\fetching.py", line 98, in get_remote_file
_fetch_file(url, filename)
File "C:\Program Files\OpenSesame\lib\site-packages\imageio\core\fetching.py", line 154, in _fetch_file
os.path.basename(file_name))
IOError: Unable to download 'ffmpeg.win32.exe'. Perhaps there is a no internet connection? If there is, please report this problem
UPDATE: It appears to have been an issue with the firewall of our institution (we just had to re-install OS outside the institution network). All good now
Johanna
Evening Daniel,
The proposed solution to copy paste the ffmpeg.exe file to the designated folder manually does not seems to work. After it did not work when I copy pasted it at the imageio area (which in my copy was under Lib not Library) as suggested, then I went ahead and copy pasted the ffmpeg.exe file to every folder within OpenSesame! It took me more than half an hour to paste the file manually to what should be at least a hundred subfolders of OS. Why are so many folders necessary anyway!!
Anyway, I made sure that the file is there should OS need it. Then I also shut the firewall completely just in case it was blocking it. The problem persisted.
I tried shutting down the firewall with other computers of the institution also, the result is the same.
I opened a file named ffmpeg.py or so, and after reading some Python language I specifically directed OS to locate and execute the ffmpeg.exe file since it was ignoring it even when it was there, it still did not work.
Are there any other solutions to this problem? My videos are MPG's, would converting them to other formats help perhaps?
Please help as soon as you can because I need a working OS by the beginning of next week! A bit tight on time here!
Regards
DCube
Just tested it with the .mov extension video format. The problem persists...
If ffmpeg.exe is this critical to OS functioning regarding experiments with videos, and considering that the file is both light in MB's and easy to get (i.e., free access), then maybe in future versions OS should come with its own ffmpeg.exe file that it would innately and independently from the internet install itself to the right location, wherever it may be (and I have tried all the folders).
I have reproduced the problem on an old llaptop back home. I disabled all access to the internet thus OS now cannot open the experiment with videos without errors because ffmpeg.exe could not be downloaded from the internet. So now I do not have to travel to the institution to test various proposed solutions and waste a day. I can test the proposed solutions to this old llaptop of mine right here.
So, I am waiting for some help in this regard. Will test all proposed solutions here until one works. This way others would know how to solve this problem also.
Regards
DCube
Thought I report this odd event, just in case it sparkles some solution ideas to the problem.
Before I tried to reproduce the problem in that old llaptop, I initially tried it first on the brand new game station desktop that my kids use. I disabled the internet so as to block OS from getting access to the ffmpeg.exe file online. But the problem failed to be reproduced for some reason.
Maybe somehow these new computers already have ffmpeg.exe installed somewhere else other than the internet that OS seems to be able to find by alternative/non-internet means. Basically, my OS experiment with videos opened and worked in that new gamestation computer regardless if there was an internet connection or not.
Quite singular, is it not?
Regards
DCube
Hi DCube,
In a post above someone reports the error message includes "ffmpeg.win32.exe" instead of "ffmpeg.exe". Maybe that helps?
Best,
Jarik
Hi Jarik,
Thank you for your reply.
It is the same problem. The exact name of what I called "ffmpeg.exe" is ffmpeg.win32.exe. That file ffmpeg.win32.exe is what is missing and the computers in the institution cannot reach through the internet despite being online and the firewall being off. Copy pasting ffmpeg.win32.exe on all OS folders does not helps solve the problem and I still receive the message with errors when trying to run my OS that has commands to play video files.
Thank you for your reply, Jarik. But unless someone provides a better solution I mind as well play the videos separately.
DCube.
It's a guess but you might want to try putting ffmpeg in the c:\windows\system32 folder.
You could also see if the old VLC plugin still works.
Best,
Jarik
I just copied ffmpeg to the windows' System32 folder. The problem persists.
What was the trick to use OS' old VLC plugin again?
Thanks
DCube
Hi DCube.
I admit that the way this currently works is less than ideal. I haven't had a lot of time lately to dive into this problem, but it's high on my list of priorities to get fixed.
The ffmpeg download functionality is actually provided by the underlying imageio library. It offers to set an environmental variable called
imageio_ffmpeg_exe
that points to the location where the ffmpeg binary can be found. We plan on integrating the ffmpeg binary this way in future versions of OpenSesame. More info can be found here:http://imageio.readthedocs.io/en/latest/envvariables.html
So basically, you can place the ffmpeg library in any folder you like, as long as you start your OS experiment with a script containing:
Please let me know if this helps!
Morning Daniel.
Glad to hear from you!
If that command will fix it, then we are getting close to the solution because now it seems there is a script error. What I get now is that OS will not open for the following reasons:
Failed to parse line "os.environ["imageio_ffmpeg_exe"] = "C:\Program Files\OpenSesame\Library\ffmpeg.win32.exe"". Is there a closing quotation missing?
Below I get:
raise ValueError, "No closing quotation"
ValueError: No closing quotation.
Upon reading some at the forum I noticed that this seems to be a type of syntax error. What I tried to do thus far is change from \ to / and vice versa, use the name of the disc C: which is OS(C:), remove it completely so the path starts from Program Files, and I decapitalised IMAGEIO_FFMPEG_EXE.
Another detail that I noticed is that you seem to be speaking of an "ffmpeg library" rather than the ffmpeg.win32.exe file. So I copied the ffmpeg.win32.exe file to an area that I know that there are other ffmpeg's with extensions like py and pyc, which may together seems like a "library" or a folder to OS. But the latest path to the proposed command mentioned above "C:\Program Files\OpenSesame\Lib\site-packages\imageio\plugins\ffmpeg" and "C:\Program Files\OpenSesame\Lib\site-packages\imageio\plugins\ffmpeg.win32.exe" did not work neither.
This now is a typing error. I am typing something wrong. My OpenSesame folder is under C:\Program Files\Open Sesame . Can you tell me please what path sounds right to OS in order for it to alas open the darn ffmpeg.win32.exe file and enable videos to play in my experiments?
To think, a whole experiment is stopped because of a path problem!
Regards
DCube
Latest update,
Daniel, on your post you use double quotation marks (i.e., " ) while in your link it is with single quotation marks (i.e., ' ). Since this is a typing problem then I changed it to single quotation marks.
The result is that now OS ignores the command to open ffmpeg.win32.exe manually entirely and the previous error of failing to load the plugin 'media_player_mpy' due to lack of internet connection shows up. So, it seems it is no longer a typing error with single quotation marks and the path is okay and yet ignored, while the same path is incorrect with double quotation marks.
Perhaps a combination between double and single quotation marks is the matter then?
DCube
Tweaking around the quotation marks only made it worse. Now I am back to square one where OS ignores the command to open ffmpeg.win32.exe and searches it from the internet regardless what type of quotation marks or what path is used.
Quite frustrating!
What a stubborn problem!
OS seeks ffmpeg.win32.exe from the internet even when commanded specifically not to use the internet with the os.environ['IMAGEIO_NO_INTERNET'] = 'true'' command! This with single and double quotations!
Well, I am out of ideas! Unless the problem is fixed today I will have to remove the videos from OS tomorrow.
DCube
Hi DCube,
Sorry, but I have no time to look at it at such short notice.
The fact that you get a message about mismatching quotations is probably due to a copy-paste mistake, or other kind of syntax error. I see that your Python statements contain quite some mistakes, so maybe you should brush up your Python knowledge first. For now, here are some tips:
"C:\\path\\to\\your\\ffmpeg"
That should be the only change you need to make. If you leave away theC:\\
, python will not look from the Program Files directory, but from the current working directory (os.getcwd()
). You are also allowed to use forward slashes, so why that didn't work is a mystery to me.True
orFalse
, so starting with a capital letter, and not encapsulated in quotes.os.environ['IMAGEIO_NO_INTERNET'] = 'true'
is therefore wrong, because you are storing the string "true" in this variable, and not the boolean valueTrue
.os.environ['IMAGEIO_NO_INTERNET'] = True
is thus the correct way to write this.Hello Daniel.
Here is what I just tried:
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = True
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "C:\Program Files\OpenSesame\ffmpeg.win32.exe"
These are put on page 20 as can be seen in Word file. The sticky problem persists. OS keeps on trying to download ffmpeg.win32.exe from the internet.
Seems like solving this problem without the internet is hopeless. When will this bug be fixed in the upcoming version of OS?
DCube
Hi DCube,
I cannot tell when the problem will be fixed yet as I am busy with other work and currently don't have any time to look at this. I will give it a try as soon as I can.
There are some mistakes in your code again. If you look at my previous post, I mentioned you have to escape all backslashes in a string by using a double backslash. You also have the wrong variable that specifies there is no Internet. You are using
IMAGEIO_FFMPEG_EXE
instead ofIMAGEIO_NO_INTERNET
The correct code should be something like:
Be sure to place this code before any media_player_mpy instances occur in your experiment.
Evening Daniel,
I copied the content manually to my experiment before even "Video" is even mentioned, on the 1st page. The problem persists.
DCube
Running OpenSesame on Mac OS X, I had the same error message as the original poster ("OError: Unable to download 'ffmpeg.osx'. Perhaps there is a no internet connection? If there is, please report this problem.") whenever I tried to add a
media_player_mpy
item to my experiment. I followed the link prvided by Daniel above and copied theffmpeg.osx
file into the/Users/<your_username>/Library/Application Support/imageio/ffmpeg
folder.Now I could add the
media_player_mpy
item to the experiment without it crashing. But when I try to run the experiment with the video in it now, it crashes in the prepare phase of the video with the following error message (traceback):Seems like the
ffmpeg.osx
file has got the wrong format?! I actually tried all Mac versions of the file on the Github page (always renaming them to ffmpeg.osx), but nothing helped.Google also tells me that this error occurs when running shell scripts if the shebang line (starting
#!
) isn't correct. Can that be translated to the situation within OpenSesame somehow?I had the same type of error when i tried to drag the visual stimuli button to my experiment. The first error was that it could not load open-sesame-plugin-media_player_py and the second dealt with ffmpeg.osx
If it can help others, I used these commands in bash :
pip install open-sesame-plugin-media_player_py
, thenbrew upgrade ffmpeg
(there, I had some issues with xcode and could not brew upgrade so I had to change the date of my laptop to the 1st of october 2019 to be able to dosudo xcodebuild -runFirstLaunch
, thensudo xcode-select -s /Applications/Xcode.app/Contents/Developer
and then reset my clockwork to normal)After that, as explained above, I copied the file ffmpeg.osx/ffmpeg.osx.snowleopardandabove in
/Users/<your_username>/Library/ApplicationSupport/imageio/ffmpeg
and set the path within OpenSesame debugging window :
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/Users/<your_username>/Library/ApplicationSupport/imageio"
And now it is working !!!!!! ? I hope it will help some of you
PS: I am on MacOS Sierra
But I have to do it everytime I open OpenSesame :
import os
os.environ["IMAGEIO_FFMPEG_EXE"] = "/Users/<your_username>/Library/ApplicationSupport/imageio"
Is it normal?
Hi,
I am using OpenSesame for the first time. I'm builting an experiment with images and videos. The first part with images running succesfully but the part with videos crash. To read video I'm using open-sesame-media_player_mpy and I've load the plugin following the instruction of this discussion. I have the same problem that dec_labmanager, I have to introduce this script everytime I open OpenSesame. The item run good but when I run my experiment, it crash and I receive this message :
Details
experiment[prepare].new_media_player_mpy[prepare]
OSError
[Errno 2] No such file or directory
Wed May 6 17:27:07 2020
Traceback (also in debug window)
Somebody can help me, pleas ? I'm looking for in the forum and I have not see a solution...
Thank you very much