Eng:Importing Movies

You used to be able to import a movie (.mov/.avi/other) file into Scratch as a sequence of costumes to be used in an animation. Sound, however, will not be imported, and needs to be added separately.

Mac
Open your movie in iMovie and export it as an Image Sequence using Share > Export with Quicktime.

You may change the frame rate using the Options button. A lower frame rate is recommended for longer videos.

Open the frames with Gimp using the 'Open as layers' function and export as a .gif file. Use shift+click to select multiple files.

To add sounds, go back to iMovie, and export the sounds as mp3 using Share > Export with Quicktime and choosing mp3 as the export format.

Windows
Select a video file from the Media Pool and double-click on it. A more advanced way is to drag and drop the video file into the arranger.

Go to File > Export Movie... > Animated GIF.

Set your options and choose the directory of where you want the GIF to be saved, then click OK. Depending on the movie/video you are exporting, it may take some time due to the file size.

The Audio can be exported as well by going to File > Export Movie... > Audio as wave or Audio as MP3.

Alternative using Photoshop
Open Photoshop and then choose File > Import > Video frames to layers... and then choose your video files. You can change frame rate settings and choose which part of your video is converted into layers.

You may now export it as an animated .gif file.

Linux
You can use the following command:

ffmpeg -i video.mpg image%d.jpg

This will generate a sequence of JPEG images from a video file, which you can then import into Scratch as costumes.

It may be easier to use an external program such as Gimp to convert the images into a single animated gif.

Importing the Image
Drag the .gif file to the costumes area of a sprite and wait for them to be added.

Scripts
Finally, add the following script to iterate through the costumes: when gf clicked forever next costume

You may need to add a

wait (0.05) secs

or similar block to get the timing correct, especially if you are importing sounds as well.

A more accurate script for exact timing using the timer is as follows. Replace 'fps' with your chosen frames per second.

when gf clicked reset timer forever switch costume to ((timer) / ((1) / (fps) ) end

Sounds can be played using this script.

when gf clicked forever play sound [movie sounds v] until done