Ejemplo n.º 1
0
        public void exportTo(DicomElement dicomElement, BackgroundWorker worker)
        {
            string tmpAviFilePath = Path.Combine(Settings.Default.ExportPath, dicomElement + "-tmp.avi");
            if (File.Exists(tmpAviFilePath))
            {
                tmpAviFilePath = renameToNonExistentFileName(tmpAviFilePath);
            }
            doExporting(tmpAviFilePath, dicomElement, worker);

            List<VideoFormat> videoFormats = getCheckedFormats();
            foreach (VideoFormat videoFormat in videoFormats)
            {
                log.Debug("Exporting to ." + videoFormat.ToString().ToLower());
                doCompression(videoFormat, tmpAviFilePath, dicomElement);
            }

            File.Delete(tmpAviFilePath);
        }
Ejemplo n.º 2
0
        private string createDefaultArguments(VideoFormat videoFormat, string inputFilePath, string outputFilePath, DicomElement dicomElement)
        {
            // for ffmpeg testing
            //ffmpeg -i test-video.avi -r 2 -qscale 31 -f m4v m5.mpg
            // mpeg1 supports only specific fps values, see mpeg12data.c from ffmpeg source
            string format = videoFormat.ToString().ToLower();

            int originalFps;
            string strOriginalFps = dicomElement.DicomFile.DataSet[DicomTags.CineRate].GetString(0, "");
            if (int.TryParse(strOriginalFps, out originalFps) == false)
            {
                originalFps = Settings.Default.Fps;
            }

            int fps = (videoFormat == VideoFormat.MPEG) ? 24 : originalFps;

            return @"-i " + inputFilePath
                + " -r " + fps
                + " -qscale " + Settings.Default.Quality
                + " -f " + format
                + " \"" + outputFilePath + "\"";
        }
Ejemplo n.º 3
0
        private void doCompression(VideoFormat videoFormat,string tmpAviFilePath, DicomElement dicomElement)
        {
            string format = videoFormat.ToString().ToLower();
            string outputFileName = Path.GetFileNameWithoutExtension(dicomElement.FilePath) + "." + format;
            string outputFolderPath = Settings.Default.ExportPath + dicomElement.GetSubFolderPath(format);
            Directory.CreateDirectory(outputFolderPath);
            string outputFilePath = Path.Combine(outputFolderPath, outputFileName);
            if (File.Exists(outputFilePath))
            {
                outputFilePath = renameToNonExistentFileName(outputFilePath);
            }

            if (videoFormat == VideoFormat.M4V)
            {
                executeMultiPassesCommandsForM4v(tmpAviFilePath, outputFilePath);

            }
            else
            {
                executeFFmpegCommand(createDefaultArguments(videoFormat, tmpAviFilePath, outputFilePath, dicomElement));
            }
        }
Ejemplo n.º 4
0
        private void doExporting(string tmpFilePath, DicomElement dicomElement, BackgroundWorker worker)
        {
            //create a new AVI file
            AviManager aviManager = new AviManager(tmpFilePath, false);
            //add a new video stream and one frame to the new file
            // todo mozda ce moci drugaciji konstruktor...
            Bitmap bitmap = dicomElement.GetBitmap(1);
            VideoStream aviStream = aviManager.AddVideoStream(createCompressedOptions(), Settings.Default.Fps, bitmap);
            bitmap.Dispose();
            worker.ReportProgress(1);

            for (int n = 2; n <= dicomElement.FrameCount; n++)
            {
                bitmap = dicomElement.GetBitmap(n);
                aviStream.AddFrame(bitmap);
                bitmap.Dispose();
                worker.ReportProgress(1);
            }

            aviManager.Close();
        }
Ejemplo n.º 5
0
 internal void TreeNodeSelectionChanged(TreeNode currentNode)
 {
     this.currentDicomElement = new DicomElement(currentNode);
     this.currentFrame = 1;
     this.selection.Size = new Size();
     this.endPoint = this.startPoint;
 }