Search in sources :

Example 1 with MediaTrack

use of cbit.vcell.export.gloworm.quicktime.MediaTrack in project vcell by virtualcell.

the class PDEDataViewer method makeSurfaceMovie.

private void makeSurfaceMovie(final SurfaceCanvas surfaceCanvas, final int varTotalNumIndices, final String movieDataVarName, final DisplayAdapterService movieDAS, final VCDataIdentifier movieVCDataIdentifier) {
    final SurfaceMovieSettingsPanel smsp = new SurfaceMovieSettingsPanel();
    final double[] timePoints = getPdeDataContext().getTimePoints();
    final int surfaceWidth = surfaceCanvas.getWidth();
    final int surfaceHeight = surfaceCanvas.getHeight();
    smsp.init(surfaceWidth, surfaceHeight, timePoints);
    while (true) {
        if (PopupGenerator.showComponentOKCancelDialog(this, smsp, "Movie Settings for var " + movieDataVarName) != JOptionPane.OK_OPTION) {
            return;
        }
        long movieSize = (smsp.getTotalFrames() * surfaceWidth * surfaceHeight * 3);
        // raw data size;
        long rawDataSize = (smsp.getTotalFrames() * varTotalNumIndices * 8);
        if (movieSize + rawDataSize > 50000000) {
            final String YES_RESULT = "Yes";
            String result = PopupGenerator.showWarningDialog(this, "Movie processing will require at least " + (movieSize + rawDataSize) / 1000000 + " mega-bytes of memory.\nMovie size will be " + (movieSize >= 1000000 ? movieSize / 1000000 + " mega-bytes." : movieSize / 1000.0 + " kilo-bytes.") + " Continue?", new String[] { YES_RESULT, "No" }, YES_RESULT);
            if (result != null && result.equals(YES_RESULT)) {
                break;
            }
        } else {
            break;
        }
    }
    final int beginTimeIndex = smsp.getBeginTimeIndex();
    final int endTimeIndex = smsp.getEndTimeIndex();
    final int step = smsp.getSkipParameter() + 1;
    final String[] varNames = new String[] { movieDataVarName };
    int[] allIndices = new int[varTotalNumIndices];
    for (int i = 0; i < allIndices.length; i++) {
        allIndices[i] = i;
    }
    final TimeSeriesJobSpec timeSeriesJobSpec = new TimeSeriesJobSpec(varNames, new int[][] { allIndices }, null, timePoints[beginTimeIndex], step, timePoints[endTimeIndex], VCDataJobID.createVCDataJobID(getDataViewerManager().getUser(), true));
    Hashtable<String, Object> hash = new Hashtable<String, Object>();
    hash.put(StringKey_timeSeriesJobSpec, timeSeriesJobSpec);
    AsynchClientTask task1 = new TimeSeriesDataRetrievalTask("Retrieving data for variable '" + movieDataVarName + "'", PDEDataViewer.this, getPdeDataContext());
    AsynchClientTask task2 = new AsynchClientTask("select a file", AsynchClientTask.TASKTYPE_SWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            VCFileChooser fileChooser = new VCFileChooser();
            fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
            fileChooser.setMultiSelectionEnabled(false);
            fileChooser.addChoosableFileFilter(FileFilters.FILE_FILTER_MOV);
            // Set the default file filter...
            fileChooser.setFileFilter(FileFilters.FILE_FILTER_MOV);
            // remove all selector
            fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter());
            fileChooser.setDialogTitle("Saving surface movie");
            File selectedFile = null;
            while (true) {
                if (fileChooser.showSaveDialog(PDEDataViewer.this) != JFileChooser.APPROVE_OPTION) {
                    return;
                }
                selectedFile = fileChooser.getSelectedFile();
                if (!selectedFile.getName().endsWith(".mov")) {
                    selectedFile = new File(selectedFile.getAbsolutePath() + ".mov");
                }
                if (selectedFile.exists()) {
                    final String YES_RESULT = "Yes";
                    String result = PopupGenerator.showWarningDialog(PDEDataViewer.this, "Overwrite exisitng file:\n" + selectedFile.getAbsolutePath() + "?", new String[] { YES_RESULT, "No" }, YES_RESULT);
                    if (result != null && result.equals(YES_RESULT)) {
                        break;
                    }
                } else {
                    break;
                }
            }
            hashTable.put("selectedFile", selectedFile);
        }
    };
    AsynchClientTask task3 = new AsynchClientTask("create movie", AsynchClientTask.TASKTYPE_NONSWING_BLOCKING) {

        @Override
        public void run(Hashtable<String, Object> hashTable) throws Exception {
            File selectedFile = (File) hashTable.get("selectedFile");
            if (selectedFile == null) {
                return;
            }
            TSJobResultsNoStats tsJobResultsNoStats = (TSJobResultsNoStats) hashTable.get(StringKey_timeSeriesJobResults);
            double[][] timeSeries = tsJobResultsNoStats.getTimesAndValuesForVariable(movieDataVarName);
            int[] singleFrame = new int[surfaceWidth * surfaceHeight];
            BufferedImage bufferedImage = new BufferedImage(surfaceWidth, surfaceHeight, BufferedImage.TYPE_3BYTE_BGR);
            Graphics2D g2D = bufferedImage.createGraphics();
            VideoMediaChunk[] chunks = new VideoMediaChunk[tsJobResultsNoStats.getTimes().length];
            VideoMediaSample sample;
            int sampleDuration = 0;
            int timeScale = smsp.getFramesPerSecond();
            int bitsPerPixel = 32;
            DisplayAdapterService das = new DisplayAdapterService(movieDAS);
            int[][] origSurfacesColors = surfaceCanvas.getSurfacesColors();
            DataInfoProvider dataInfoProvider = getPDEDataContextPanel1().getDataInfoProvider();
            FileDataContainerManager fileDataContainerManager = new FileDataContainerManager();
            try {
                try {
                    for (int t = 0; t < tsJobResultsNoStats.getTimes().length; t++) {
                        getClientTaskStatusSupport().setMessage("Creating Movie... Progress " + NumberUtils.formatNumber(100.0 * ((double) t / (double) tsJobResultsNoStats.getTimes().length), 3) + "%");
                        double min = Double.POSITIVE_INFINITY;
                        double max = Double.NEGATIVE_INFINITY;
                        for (int index = 1; index < timeSeries.length; index++) {
                            double v = timeSeries[index][t];
                            if ((dataInfoProvider == null || dataInfoProvider.isDefined(index - 1)) && !Double.isNaN(v) && !Double.isInfinite(v)) {
                                min = Math.min(min, v);
                                max = Math.max(max, v);
                            }
                        }
                        das.setValueDomain(new Range(min, max));
                        if (das.getAutoScale()) {
                            das.setActiveScaleRange(new Range(min, max));
                        }
                        int[][] surfacesColors = new int[surfaceCanvas.getSurfaceCollection().getSurfaceCount()][];
                        for (int i = 0; i < surfaceCanvas.getSurfaceCollection().getSurfaceCount(); i += 1) {
                            Surface surface = surfaceCanvas.getSurfaceCollection().getSurfaces(i);
                            surfacesColors[i] = new int[surface.getPolygonCount()];
                            for (int j = 0; j < surface.getPolygonCount(); j += 1) {
                                int membIndex = meshRegionSurfaces.getMembraneIndexForPolygon(i, j);
                                surfacesColors[i][j] = das.getColorFromValue(timeSeries[membIndex + 1][t]);
                            }
                        }
                        surfaceCanvas.setSurfacesColors(surfacesColors);
                        surfaceCanvas.paintImmediately(0, 0, surfaceWidth, surfaceHeight);
                        surfaceCanvas.paint(g2D);
                        bufferedImage.getRGB(0, 0, surfaceWidth, surfaceHeight, singleFrame, 0, surfaceWidth);
                        sampleDuration = 1;
                        sample = FormatSpecificSpecs.getVideoMediaSample(surfaceWidth, surfaceHeight * varNames.length, sampleDuration, false, FormatSpecificSpecs.CODEC_JPEG, 1.0f, singleFrame);
                        chunks[t] = new VideoMediaChunk(sample, fileDataContainerManager);
                    }
                } finally {
                    surfaceCanvas.setSurfacesColors(origSurfacesColors);
                    surfaceCanvas.paintImmediately(0, 0, surfaceWidth, surfaceHeight);
                }
                MediaTrack videoTrack = new MediaTrack(chunks);
                MediaMovie newMovie = new MediaMovie(videoTrack, videoTrack.getDuration(), timeScale);
                newMovie.addUserDataEntry(new UserDataEntry("cpy", "\u00A9" + (new GregorianCalendar()).get(Calendar.YEAR) + ", UCHC"));
                newMovie.addUserDataEntry(new UserDataEntry("des", "Dataset name: " + movieVCDataIdentifier.getID()));
                newMovie.addUserDataEntry(new UserDataEntry("cmt", "Time range: " + timePoints[beginTimeIndex] + " - " + timePoints[endTimeIndex]));
                for (int k = 0; k < varNames.length; k++) {
                    // pad with 0 if k < 10
                    String entryType = "v" + (k < 10 ? "0" : "") + k;
                    UserDataEntry entry = new UserDataEntry(entryType, "Variable name: " + varNames[k] + " min: " + das.getValueDomain().getMin() + " max: " + das.getValueDomain().getMax());
                    newMovie.addUserDataEntry(entry);
                }
                getClientTaskStatusSupport().setMessage("Writing Movie to disk...");
                FileOutputStream fos = new FileOutputStream(selectedFile);
                DataOutputStream movieOutput = new DataOutputStream(new BufferedOutputStream(fos));
                MediaMethods.writeMovie(movieOutput, newMovie);
                movieOutput.close();
                fos.close();
            } finally {
                fileDataContainerManager.closeAllAndDelete();
            }
        }
    };
    ClientTaskDispatcher.dispatch(this, hash, new AsynchClientTask[] { task1, task2, task3 }, true, true, null);
}
Also used : DisplayAdapterService(cbit.image.DisplayAdapterService) AsynchClientTask(cbit.vcell.client.task.AsynchClientTask) TimeSeriesJobSpec(org.vcell.util.document.TimeSeriesJobSpec) DataOutputStream(java.io.DataOutputStream) DataInfoProvider(cbit.vcell.simdata.DataInfoProvider) FileDataContainerManager(cbit.vcell.export.server.FileDataContainerManager) BufferedImage(java.awt.image.BufferedImage) VideoMediaSample(cbit.vcell.export.gloworm.quicktime.VideoMediaSample) Surface(cbit.vcell.geometry.surface.Surface) VCFileChooser(org.vcell.util.gui.VCFileChooser) VideoMediaChunk(cbit.vcell.export.gloworm.quicktime.VideoMediaChunk) BufferedOutputStream(java.io.BufferedOutputStream) Hashtable(java.util.Hashtable) UserDataEntry(cbit.vcell.export.gloworm.atoms.UserDataEntry) GregorianCalendar(java.util.GregorianCalendar) Range(org.vcell.util.Range) Point(java.awt.Point) SinglePoint(cbit.vcell.geometry.SinglePoint) Graphics2D(java.awt.Graphics2D) MediaTrack(cbit.vcell.export.gloworm.quicktime.MediaTrack) FileOutputStream(java.io.FileOutputStream) SurfaceMovieSettingsPanel(cbit.vcell.geometry.gui.SurfaceMovieSettingsPanel) File(java.io.File) TSJobResultsNoStats(org.vcell.util.document.TSJobResultsNoStats) MediaMovie(cbit.vcell.export.gloworm.quicktime.MediaMovie)

Example 2 with MediaTrack

use of cbit.vcell.export.gloworm.quicktime.MediaTrack in project vcell by virtualcell.

the class IMGExporter method createMedia.

private static void createMedia(Vector<ExportOutput> exportOutputV, VCDataIdentifier vcdID, String dataID, ExportSpecs exportSpecs, boolean bEndVars, boolean bEndSlice, boolean bBeginTime, boolean bEndTime, boolean bSingleTimePoint, String[] varNameArr, DisplayPreferences[] displayPreferencesArr, MovieHolder movieHolder, int[] pixels, int mirrorWidth, int mirrorHeight, FileDataContainerManager fileDataContainerManager) throws Exception {
    boolean isGrayScale = true;
    for (int i = 0; i < displayPreferencesArr.length; i++) {
        if (!displayPreferencesArr[i].isGrayScale()) {
            isGrayScale = false;
            break;
        }
    }
    FormatSpecificSpecs formatSpecificSpecs = exportSpecs.getFormatSpecificSpecs();
    if (exportSpecs.getFormat() == ExportFormat.GIF && formatSpecificSpecs instanceof ImageSpecs) /* && ((ImageSpecs)formatSpecificSpecs).getFormat() == ExportConstants.GIF*/
    {
        ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
        GIFOutputStream gifOut = new GIFOutputStream(bytesOut);
        GIFImage gifImage = new GIFUtils.GIFImage(pixels, mirrorWidth);
        gifImage.write(gifOut);
        gifOut.close();
        byte[] data = bytesOut.toByteArray();
        ExportOutput exportOutput = new ExportOutput(true, ".gif", vcdID.getID(), dataID, fileDataContainerManager);
        fileDataContainerManager.append(exportOutput.getFileDataContainerID(), data);
        exportOutputV.add(exportOutput);
    } else if (exportSpecs.getFormat() == ExportFormat.FORMAT_JPEG && formatSpecificSpecs instanceof ImageSpecs) /* && ((ImageSpecs)formatSpecificSpecs).getFormat() == ExportConstants.JPEG*/
    {
        VideoMediaSample jpegEncodedVideoMediaSample = FormatSpecificSpecs.getVideoMediaSample(mirrorWidth, mirrorHeight, 1, isGrayScale, FormatSpecificSpecs.CODEC_JPEG, ((ImageSpecs) formatSpecificSpecs).getcompressionQuality(), pixels);
        ExportOutput exportOutput = new ExportOutput(true, ".jpg", vcdID.getID(), dataID, fileDataContainerManager);
        fileDataContainerManager.append(exportOutput.getFileDataContainerID(), jpegEncodedVideoMediaSample.getDataBytes());
        exportOutputV.add(exportOutput);
    } else if (exportSpecs.getFormat() == ExportFormat.ANIMATED_GIF && formatSpecificSpecs instanceof ImageSpecs) /* && ((ImageSpecs)formatSpecificSpecs).getFormat() == ExportConstants.ANIMATED_GIF*/
    {
        // 1/100's of a second
        int imageDuration = (int) Math.ceil((movieHolder.getSampleDurationSeconds() * 100));
        if (bEndTime && (((ImageSpecs) formatSpecificSpecs).getLoopingMode() != 0 || bSingleTimePoint)) {
            imageDuration = 0;
        }
        if (bBeginTime) {
            movieHolder.setGifImage(new GIFUtils.GIFImage(pixels, mirrorWidth));
            movieHolder.getGifImage().setDelay(imageDuration);
        } else {
            movieHolder.getGifImage().addImage(pixels, mirrorWidth, true);
            movieHolder.getGifImage().setDelay(movieHolder.getGifImage().countImages() - 1, imageDuration);
        }
        if (bEndTime) {
            movieHolder.getGifImage().setIterationCount(((ImageSpecs) formatSpecificSpecs).getLoopingMode());
            ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
            GIFOutputStream gifOut = new GIFOutputStream(bytesOut);
            movieHolder.getGifImage().write(gifOut);
            gifOut.close();
            byte[] data = bytesOut.toByteArray();
            ExportOutput exportOutput = new ExportOutput(true, ".gif", vcdID.getID(), dataID, fileDataContainerManager);
            fileDataContainerManager.append(exportOutput.getFileDataContainerID(), data);
            exportOutputV.add(exportOutput);
        }
    } else if (exportSpecs.getFormat() == ExportFormat.QUICKTIME && formatSpecificSpecs instanceof MovieSpecs) {
        String VIDEOMEDIACHUNKID = (varNameArr.length == 1 ? varNameArr[0] : "OVERLAY");
        // number of units per second in movie
        final int TIMESCALE = 1000;
        boolean bQTVR = ((MovieSpecs) exportSpecs.getFormatSpecificSpecs()).isQTVR();
        int sampleDuration = (bQTVR ? TIMESCALE : (int) (TIMESCALE * movieHolder.getSampleDurationSeconds()));
        VideoMediaSample videoMediaSample = FormatSpecificSpecs.getVideoMediaSample(mirrorWidth, mirrorHeight, sampleDuration, isGrayScale, FormatSpecificSpecs.CODEC_JPEG, ((MovieSpecs) formatSpecificSpecs).getcompressionQuality(), pixels);
        if (bBeginTime && (!bQTVR || movieHolder.getVarNameVideoMediaChunkHash().get(VIDEOMEDIACHUNKID) == null)) {
            movieHolder.getVarNameVideoMediaChunkHash().put(VIDEOMEDIACHUNKID, new Vector<VideoMediaChunk>());
            movieHolder.getVarNameDataIDHash().put(VIDEOMEDIACHUNKID, dataID);
        }
        movieHolder.getVarNameVideoMediaChunkHash().get(VIDEOMEDIACHUNKID).add(new VideoMediaChunk(videoMediaSample, fileDataContainerManager));
        if (bEndTime && !bQTVR) {
            String simID = exportSpecs.getVCDataIdentifier().getID();
            double[] allTimes = exportSpecs.getTimeSpecs().getAllTimes();
            int beginTimeIndex = exportSpecs.getTimeSpecs().getBeginTimeIndex();
            int endTimeIndex = exportSpecs.getTimeSpecs().getEndTimeIndex();
            VideoMediaChunk[] videoMediaChunkArr = movieHolder.getVarNameVideoMediaChunkHash().get(VIDEOMEDIACHUNKID).toArray(new VideoMediaChunk[0]);
            MediaTrack videoTrack = new MediaTrack(videoMediaChunkArr);
            MediaMovie newMovie = new MediaMovie(videoTrack, videoTrack.getDuration(), TIMESCALE);
            newMovie.addUserDataEntry(new UserDataEntry("cpy", "�" + (new GregorianCalendar()).get(Calendar.YEAR) + ", UCHC"));
            newMovie.addUserDataEntry(new UserDataEntry("des", "Dataset name: " + simID));
            newMovie.addUserDataEntry(new UserDataEntry("cmt", "Time range: " + allTimes[beginTimeIndex] + " - " + allTimes[endTimeIndex]));
            for (int i = 0; varNameArr != null && i < varNameArr.length; i++) {
                newMovie.addUserDataEntry(new UserDataEntry("v" + (i < 10 ? "0" : "") + i, "Variable name: " + varNameArr[i] + "\nmin: " + (displayPreferencesArr == null || displayPreferencesArr[i].getScaleSettings() == null ? "default" : displayPreferencesArr[i].getScaleSettings().getMin()) + "\nmax: " + (displayPreferencesArr == null || displayPreferencesArr[i].getScaleSettings() == null ? "default" : displayPreferencesArr[i].getScaleSettings().getMax())));
            }
            FileOutputStream fos = null;
            BufferedOutputStream bos = null;
            DataOutputStream movieos = null;
            try {
                ExportOutput exportOutput = new ExportOutput(true, ".mov", simID, dataID, fileDataContainerManager);
                File tempMovieFile = File.createTempFile("Movie", "temp");
                fileDataContainerManager.manageExistingTempFile(exportOutput.getFileDataContainerID(), tempMovieFile);
                fos = new FileOutputStream(tempMovieFile);
                bos = new BufferedOutputStream(fos);
                movieos = new DataOutputStream(bos);
                MediaMethods.writeMovie(movieos, newMovie);
                movieos.close();
                exportOutputV.add(exportOutput);
                movieHolder.getVarNameVideoMediaChunkHash().clear();
                movieHolder.getVarNameDataIDHash().clear();
            } finally {
                if (movieos != null) {
                    try {
                        movieos.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (bos != null) {
                    try {
                        bos.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
                if (fos != null) {
                    try {
                        fos.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        } else if (bEndVars && bEndTime && bEndSlice && bQTVR) {
            String simID = exportSpecs.getVCDataIdentifier().getID();
            Enumeration<String> allStoredVarNamesEnum = movieHolder.getVarNameVideoMediaChunkHash().keys();
            while (allStoredVarNamesEnum.hasMoreElements()) {
                String varName = allStoredVarNamesEnum.nextElement();
                String storedDataID = movieHolder.getVarNameDataIDHash().get(varName);
                VideoMediaChunk[] videoMediaChunkArr = movieHolder.getVarNameVideoMediaChunkHash().get(varName).toArray(new VideoMediaChunk[0]);
                int beginTimeIndex = exportSpecs.getTimeSpecs().getBeginTimeIndex();
                int endTimeIndex = exportSpecs.getTimeSpecs().getEndTimeIndex();
                int numTimes = endTimeIndex - beginTimeIndex + 1;
                FileOutputStream fos = null;
                BufferedOutputStream bos = null;
                DataOutputStream movieos = null;
                try {
                    ExportOutput exportOutput = new ExportOutput(true, ".mov", simID, storedDataID, fileDataContainerManager);
                    File tempMovieFile = File.createTempFile("Movie", "temp");
                    fileDataContainerManager.manageExistingTempFile(exportOutput.getFileDataContainerID(), tempMovieFile);
                    fos = new FileOutputStream(tempMovieFile);
                    bos = new BufferedOutputStream(fos);
                    movieos = new DataOutputStream(bos);
                    writeQTVRWorker(movieos, videoMediaChunkArr, numTimes, videoMediaChunkArr.length / numTimes, mirrorWidth, mirrorHeight);
                    movieos.close();
                    exportOutputV.add(exportOutput);
                } finally {
                    if (movieos != null) {
                        try {
                            movieos.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (bos != null) {
                        try {
                            bos.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                    if (fos != null) {
                        try {
                            fos.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
                    }
                }
            }
            movieHolder.getVarNameVideoMediaChunkHash().clear();
            movieHolder.getVarNameDataIDHash().clear();
        }
    }
}
Also used : DataOutputStream(java.io.DataOutputStream) VideoMediaSample(cbit.vcell.export.gloworm.quicktime.VideoMediaSample) GIFImage(GIFUtils.GIFImage) GIFOutputStream(GIFUtils.GIFOutputStream) VideoMediaChunk(cbit.vcell.export.gloworm.quicktime.VideoMediaChunk) Vector(java.util.Vector) BufferedOutputStream(java.io.BufferedOutputStream) GIFImage(GIFUtils.GIFImage) UserDataEntry(cbit.vcell.export.gloworm.atoms.UserDataEntry) GregorianCalendar(java.util.GregorianCalendar) ByteArrayOutputStream(java.io.ByteArrayOutputStream) GIFFormatException(GIFUtils.GIFFormatException) RemoteException(java.rmi.RemoteException) DataFormatException(java.util.zip.DataFormatException) IOException(java.io.IOException) DataAccessException(org.vcell.util.DataAccessException) UserCancelException(org.vcell.util.UserCancelException) MediaTrack(cbit.vcell.export.gloworm.quicktime.MediaTrack) FileOutputStream(java.io.FileOutputStream) File(java.io.File) MediaMovie(cbit.vcell.export.gloworm.quicktime.MediaMovie) VRMediaMovie(cbit.vcell.export.gloworm.quicktime.VRMediaMovie)

Example 3 with MediaTrack

use of cbit.vcell.export.gloworm.quicktime.MediaTrack in project vcell by virtualcell.

the class IMGExporter method writeQTVRWorker.

public static void writeQTVRWorker(DataOutputStream dataOutputStream, VideoMediaChunk[] videoMediaChunks, int numTimePoints, int numslices, int width, int height) throws java.io.IOException, java.util.zip.DataFormatException {
    /* make the single node VR World and required chunks */
    if (numTimePoints * numslices != videoMediaChunks.length) {
        throw new DataFormatException("NumTimePoints x Numslices != VideoMediaChunk length.");
    }
    VRWorld singleObjVRWorld = VRWorld.createSingleObjectVRWorld(videoMediaChunks[0].getDuration(), numTimePoints, numslices, (float) (width / 2), (float) (height / 2));
    // reverse pan controls (set bit 3)
    singleObjVRWorld.getVRObjectSampleAtom(0).setControlSettings(singleObjVRWorld.getVRObjectSampleAtom(0).getControlSettings() | (Integer.parseInt("00001000", 2)));
    VRMediaChunk vrChunk = new VRMediaChunk(singleObjVRWorld);
    ObjectMediaChunk objChunk = new ObjectMediaChunk(singleObjVRWorld);
    /* assemble tracks and write the rest of the file */
    MediaTrack qtvrTrack = new MediaTrack(vrChunk);
    MediaTrack objectTrack = new MediaTrack(objChunk);
    MediaTrack imageTrack = new MediaTrack(videoMediaChunks);
    qtvrTrack.setWidth(imageTrack.getWidth());
    qtvrTrack.setHeight(imageTrack.getHeight());
    objectTrack.setWidth(imageTrack.getWidth());
    objectTrack.setHeight(imageTrack.getHeight());
    VRMediaMovie vrMovie = VRMediaMovie.createVRMediaMovie(qtvrTrack, objectTrack, imageTrack, null, imageTrack.getDuration(), videoMediaChunks[0].getDuration());
    MediaMethods.writeMovie(dataOutputStream, vrMovie);
}
Also used : MediaTrack(cbit.vcell.export.gloworm.quicktime.MediaTrack) DataFormatException(java.util.zip.DataFormatException) VRWorld(cbit.vcell.export.gloworm.quicktime.VRWorld) VRMediaChunk(cbit.vcell.export.gloworm.quicktime.VRMediaChunk) ObjectMediaChunk(cbit.vcell.export.gloworm.quicktime.ObjectMediaChunk) VRMediaMovie(cbit.vcell.export.gloworm.quicktime.VRMediaMovie)

Aggregations

MediaTrack (cbit.vcell.export.gloworm.quicktime.MediaTrack)3 UserDataEntry (cbit.vcell.export.gloworm.atoms.UserDataEntry)2 MediaMovie (cbit.vcell.export.gloworm.quicktime.MediaMovie)2 VRMediaMovie (cbit.vcell.export.gloworm.quicktime.VRMediaMovie)2 VideoMediaChunk (cbit.vcell.export.gloworm.quicktime.VideoMediaChunk)2 VideoMediaSample (cbit.vcell.export.gloworm.quicktime.VideoMediaSample)2 BufferedOutputStream (java.io.BufferedOutputStream)2 DataOutputStream (java.io.DataOutputStream)2 File (java.io.File)2 FileOutputStream (java.io.FileOutputStream)2 GregorianCalendar (java.util.GregorianCalendar)2 DataFormatException (java.util.zip.DataFormatException)2 GIFFormatException (GIFUtils.GIFFormatException)1 GIFImage (GIFUtils.GIFImage)1 GIFOutputStream (GIFUtils.GIFOutputStream)1 DisplayAdapterService (cbit.image.DisplayAdapterService)1 AsynchClientTask (cbit.vcell.client.task.AsynchClientTask)1 ObjectMediaChunk (cbit.vcell.export.gloworm.quicktime.ObjectMediaChunk)1 VRMediaChunk (cbit.vcell.export.gloworm.quicktime.VRMediaChunk)1 VRWorld (cbit.vcell.export.gloworm.quicktime.VRWorld)1