Login  Register

Saving a stack as a Quicktime Movie

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options Options
Embed post
Permalink
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Saving a stack as a Quicktime Movie

Philip Ershler
92 posts
Hello,
        I have modified the Batch Image processing plugin so that I can batch Quicktime movies as

1. Open the Quicktime Movie
2. Set an ROI
3. Crop the stack to the ROI
4. Save the stack back out as a compressed Quicktime movie (hopefully)

        Here is a snipette of code that "almost" works.

        public void convert(String dir1, String dir2, String format) {
                IJ.log("\\Clear");
                IJ.log("dir1: "+dir1);
                IJ.log("dir2: "+dir2);
                String[] list = new File(dir1).list();
                if (list==null) return;
                for (int i=0; i<list.length; i++) {
                        IJ.showProgress(i, list.length);
                        IJ.showStatus(i+"/"+list.length);
                        boolean isDir = (new File(dir1+list[i])).isDirectory();
                        if (!isDir && !list[i].startsWith(".")) {
                                theOpener = new My_QT_Movie_Opener(); // QT_Movie_Opener modified so it does not display a dialog "Convert to 8 bit"
                                theOpener.run(dir1+list[i]);
                                theIp = IJ.getImage();
                                theIp.setRoi(197, 74, 405, 354);
                                IJ.run(theIp, "Crop", "");
                                theIp.setTitle("temp.mov");
                                //IJ.log(" \"QuickTime Movie...\", \"compression=Sorenson quality=Normal frame=30 save=" + dir2 + list[i] + "\" ");
                                IJ.run(" \"QuickTime Movie...\", \"compression=Sorenson quality=Normal frame=30 save=" + dir2 + list[i] + "\" ");
                                IJ.run("Close");
                        }
                }
                IJ.showProgress(1.0);
                IJ.showStatus("Done converting " + list.length + " files");
        }

        Everything down to this line, which is what comes from recording a plugin for one pass through the 4 steps above, which works properly.

IJ.run(" \"QuickTime Movie...\", \"compression=Sorenson quality=Normal frame=30 save=" + dir2 + list[i] + "\" ");

        When it hits this line the machine complains "unknown command". At this point I have a cropped stack ready to be written out. What is the correct way to write a stack out as a Quicktime movie from a plugin?

Thanks, Phil



Philip R. Ershler Ph.D.
University of Utah
Cardiovascular Research and Training Institute
95 South 2000 East
Salt Lake City, UT 84112-5000
Reply | Threaded
Open this post in threaded view
| More
Print post
Permalink

Re: Saving a stack as a Quicktime Movie

ctrueden
1670 posts
Hi Phil,

IJ.run(" \"QuickTime Movie...\", \"compression=Sorenson quality=Normal
> frame=30 save=" + dir2 + list[i] + "\" ");
>

Your command is enclosed in an extraneous outer set of quotes. Try this
instead:

IJ.run("QuickTime Movie...", "compression=Sorenson quality=Normal frame=30
save=" + dir2 + list[i]);

Regards,
Curtis


On Mon, Oct 31, 2011 at 11:25 PM, Philip Ershler <[hidden email]>wrote:

> Hello,
>        I have modified the Batch Image processing plugin so that I can
> batch Quicktime movies as
>
> 1. Open the Quicktime Movie
> 2. Set an ROI
> 3. Crop the stack to the ROI
> 4. Save the stack back out as a compressed Quicktime movie (hopefully)
>
>        Here is a snipette of code that "almost" works.
>
>        public void convert(String dir1, String dir2, String format) {
>                IJ.log("\\Clear");
>                IJ.log("dir1: "+dir1);
>                IJ.log("dir2: "+dir2);
>                String[] list = new File(dir1).list();
>                if (list==null) return;
>                for (int i=0; i<list.length; i++) {
>                        IJ.showProgress(i, list.length);
>                        IJ.showStatus(i+"/"+list.length);
>                        boolean isDir = (new
> File(dir1+list[i])).isDirectory();
>                        if (!isDir && !list[i].startsWith(".")) {
>                                theOpener = new My_QT_Movie_Opener(); //
> QT_Movie_Opener modified so it does not display a dialog "Convert to 8 bit"
>                                theOpener.run(dir1+list[i]);
>                                theIp = IJ.getImage();
>                                theIp.setRoi(197, 74, 405, 354);
>                                IJ.run(theIp, "Crop", "");
>                                theIp.setTitle("temp.mov");
>                                //IJ.log(" \"QuickTime Movie...\",
> \"compression=Sorenson quality=Normal frame=30 save=" + dir2 + list[i] +
> "\" ");
>                                IJ.run(" \"QuickTime Movie...\",
> \"compression=Sorenson quality=Normal frame=30 save=" + dir2 + list[i] +
> "\" ");
>                                IJ.run("Close");
>                        }
>                }
>                IJ.showProgress(1.0);
>                IJ.showStatus("Done converting " + list.length + " files");
>        }
>
>        Everything down to this line, which is what comes from recording a
> plugin for one pass through the 4 steps above, which works properly.
>
> IJ.run(" \"QuickTime Movie...\", \"compression=Sorenson quality=Normal
> frame=30 save=" + dir2 + list[i] + "\" ");
>
>        When it hits this line the machine complains "unknown command". At
> this point I have a cropped stack ready to be written out. What is the
> correct way to write a stack out as a Quicktime movie from a plugin?
>
> Thanks, Phil
>
>
>
> Philip R. Ershler Ph.D.
> University of Utah
> Cardiovascular Research and Training Institute
> 95 South 2000 East
> Salt Lake City, UT 84112-5000
>