Error with PlayMovieAction open
pmazzoni
I am trying to open a video file with the command:
playmovieaction open = "fullpath"
but I get the error "No movie". I tried including the file name with the path and I tried including only the path, without the filename, but I get the same error.
- Does fullpath need to be an Igor path instead?
- Can it be an Igor path?
Pietro
...sorry, I forgot to include version info: MacOS 10.14.6 (Mojave), Igor 8.0.4
January 13, 2021 at 08:20 am - Permalink
Hi Pietro,I just tried this on my system IP9 (Beta) Mac 10.15.7 (Catalina)
•PlayMovieAction gotoEnd, getTime
•Variable tEnd = V_Value
•PlayMovieAction step=-1, getTime
•Print "frames = ", tEnd/(tEnd-V_value)
frames = 3900.02
So I used the full path. I used option-right click "Copy -... as PathName" to get the full path and then copy pasted with added quotes.
Andy
January 13, 2021 at 08:32 am - Permalink
Thank you Andy, I got it to work using your code as a starting point. My mistake may have been that the path included escape codes for spaces but was also in quotes. Your example included spaces and that reminded me of the proper handling of spaces in macOS.
The playMovieAction command will be useful for extracting video frames, but it looks like Igor for Mac can no longer play video files. Is this correct? Or can I get Igor to control an external video player?
January 13, 2021 at 10:33 am - Permalink
Hi,
On my system when a play movie command is issued, Quicktime launches and plays the movie.
Andy
January 13, 2021 at 05:36 pm - Permalink
In reply to Thank you Andy, I got it to… by pmazzoni
For the PlayMovie operation, Igor Pro 8.04 and Igor Pro 9 will open a movie file using the application on the machine that is associated with the file type of the movie.
For the PlayMovieAction operation, the documentation of Igor Pro 9 explicitly states that the stop and start keywords are obsolete. I suspect that these keywords are also obsolete in versions of Igor Pro 8 released after macOS 10.15 because Apple removed the functionality Igor relied upon.
January 14, 2021 at 09:34 am - Permalink
Thank you both for clarifying this. Just opening and starting the movie will not be enough for my purposes. I wrote functions that allowed the user to review a video by starting, stopping and jumping to various frames, all within Igor. This will no longer be possible. Time to learn a little more Python.
January 14, 2021 at 09:48 am - Permalink
In reply to Thank you both for… by pmazzoni
Potentially you could use PlayMovieAction extract to extract the frames from the movie into Igor and then display the frames in a graph. You would need to add controls to allow the user to move forward and backward. Actually playing the video (at least at typical video speed) might be possible but isn't necessarily straightforward.
I'm curious to know which Python module you'd use to play the movie. My guess is that the module is using something open source under the hood that isn't practical for a commercial application like Igor to use. You could install ffmpeg on the machine and then call that using ExecuteScriptText. I don't know if ffmpeg provides a way to control playback of the movie.
January 14, 2021 at 10:21 am - Permalink
Can you post the video somwhere?
January 14, 2021 at 01:27 pm - Permalink
Adam: I explored using the OpenCV library in Python and got it to half-work (my Python code opens and plays video, but hangs when trying to close it). However, I followed your suggestion for what to try with the playMovieAction in Igor and it works! I open the video with playMovieAction, extract the first frame, plot is as an ImagePlot, and then extract subsequent frames and update the graph each time.
By some coincidence, the computer I am using plays through the frames at a a very similar rate to the actual frame rate. I could later add code to make the loop progress at the same rate as the video's frame rate, regardless of CPU speed. But for my current needs the frame rate does not matter--I just need the user to see the next n frames in the video, at whatever speed. I include the code below.
Thank you Adam!
Thomas: the video was not the problem. It is a simple MP4 clip that was opened with no problem by Igor in earlier macOS versions. And I've been able to open it using playMovieAction.
Here is the code:
January 15, 2021 at 08:27 am - Permalink
...sorry about the horrible formatting of the code in my last post. I just learned about "Insert Code Snippet". Here is the code again in the proper format:
//Open video file
playMovieAction open="/Users/pietro/Desktop/IMG_0003.mp4"
variable refNum = V_value
print "refNum", refNum
//Just curious to see how this number behaves. I think it
//is incremented at each call and is reset after Igor quits
playMovieAction gotoBeginning
//Redundant for now but I will need it later when I want
//to find out the number of frames in the video clip
playMovieAction extract
wave M_MovieFrame
display
AppendImage M_MovieFrame
SetAxis left 719.5,-0.5 //Flips the vertical axis so the video is not upside down
//The numbers are determined by the clip's height in pixels (800), which I happen to know
doUpdate
variable counter
for (counter = 0; counter < 500; counter += 1)
//At present I want to show the first
//500 frames of the clip. Later I will add code to determine the number of frames
//in the clip
playMovieAction step = 1
playMovieAction extract
doUpdate
endFor
playMovieAction kill
End //PlayVideo
January 15, 2021 at 08:29 am - Permalink
...continuing in my efforts to restore a set of routines for annotating videos.
I had created in Igor 6 when Apple still made it possible for Igor to open a video and move around in it quickly. I'd like to get those routines to work in Igor 8.
I tried two approaches:
1) PlayMovieAction open with loop = 0 allows me to play a movie at realistic speed (I extract one frame at a time and update an image graph with the most recently loaded frame). However, I cannot back up (rewind) in loop mode = 0
2) PlayMovieAction open with loop = 1 allows me to skip around, forward and backward, but the extraction of each frame is too slow, and the movie plays in slow motion
3) I also tried a combination of 1 and 2: open the video file with loop = 0 and play at normal speed. When the user clicks the "Back" button (e.g., requests to skip back by n frames), my function makes a note of the frame requested, closes the video file, and reopens it with loop = 0 at the new requested frame. This method is too slow, as it takes several seconds for the file to be closed and reopened, and the time increases for longer videos. I need to edit videos as long as 3 hours.
4) I considered pre-loading a large number of frames and updating what is in memory as the user moves around in the video. Memory requirements grow rapidly for this approach. I may convert the video to greyscale first, so that each frame is a 2D image rather than 3 (for RGB). This could work but I doubt I could load the entire video (all 3 hours of it) into memory.
5) I would like the explore the option of controlling an ouside player, like VLC, through Unix (Mac Terminal) commands. The commands I need are basically: open movie file, skip to an arbitrary frame number, play a video at normal speed, advance one frame, skip backwards or forward to load one frame at a time for display on an image graph; and then let the user skip forward or backward an arbitrary number of frames.
Does anyone know of a Mac-compatible or Unix/Linux video player that can be controlled (start playing, stop, skip to an arbitrary frame ahead or behind the current frame) through Mac terminal commands (i.e., through ExecuteScript)? ffmpeg? VLC? Others
Pietro
March 27, 2021 at 04:44 pm - Permalink
Update:
I am giving up for now. VLC can be extensively controlled from the command line. I created shell scripts that Igor executed flawlessly using ExecuteUnixScript. However, I need the user to be able to pause and resume, and VLC does not release control back to the user while pausing. I was able to get around this problem only within Unix, by sending the process to the background, and then killing it before restarting playback. Unfortunately, I was unable to use the ExecuteUnixScript command to send the process to the background.
There may well be a way to accomplish the remaining steps in Igor using options I don't know, but this is getting more complicated than is worth pursuing for my current project. I explored Datavyu, an open-source package for doing exactly what I want to do (annotate video clips), and I like it. Our team will use Datavyu to annotate our videos and then export the annotations and their time stamps into Igor, to integrate with other data.
Thanks everyone for your suggestions.
Pietro
April 1, 2021 at 10:48 pm - Permalink