Пример #1
0
 public override object ConvertFrom(ITypeDescriptorContext context, System.Globalization.CultureInfo culture, object value)
 {
     if (value is string)
     {
         return(FileSize.Parse((string)value));
     }
     return(base.ConvertFrom(context, culture, value));
 }
Пример #2
0
        /// <summary>
        /// sets the GUI to a minimal mode allowing to configure audio track languages, configure subtitles, and chapters
        /// the rest of the options are deactivated
        /// </summary>
        /// <param name="videoInput">the video input</param>
        /// <param name="framerate">the framerate of the video input</param>
        /// <param name="audioStreams">the audio streams whose languages have to be assigned</param>
        /// <param name="output">the output file</param>
        /// <param name="splitSize">the output split size</param>
        public void setMinimizedMode(string videoInput, VideoEncoderType videoType, double framerate, MuxStream[] audioStreams, AudioEncoderType[] audioTypes, string output,
            FileSize? splitSize, ContainerType cft)
        {
            base.setConfig(videoInput, (decimal)framerate, audioStreams, new MuxStream[0], null, output, splitSize, null, null);

            minimizedMode = true;
            knownVideoType = videoType;
            knownAudioTypes = audioTypes;

            // disable everything
            videoGroupbox.Enabled = false;

            for (int i = 0; i < audioStreams.Length; ++i)
                audioTracks[i].Enabled = false;

            this.output.Filename = output;
            this.splitting.Value = splitSize;
            this.muxButton.Text = "Go";
            updatePossibleContainers();
            if (this.cbContainer.Items.Contains(cft))
                cbContainer.SelectedItem = cft;
            checkIO();
        }
Пример #3
0
        private void CalcVideoOverhead()
        {
            VideoOverheadRatio = 1;

            if (ContainerType == ContainerType.MP4)
            {
                VideoOverhead = new FileSize(Unit.B,
                    (HasBFrames ? mp4OverheadWithBframes : mp4OverheadWithoutBframes) * Frames);
            }
            else if (ContainerType == ContainerType.MKV)
            {
                long nbIframes = Frames / 10;
                long nbBframes = HasBFrames ? (Frames - nbIframes) / 2 : 0;
                long nbPframes = Frames - nbIframes - nbBframes;
                VideoOverhead = new FileSize(Unit.B,
                    (4300M + 1400M + nbIframes * mkvIframeOverhead + nbPframes * mkvPframeOverhead +
                    nbBframes * mkvBframeOverhead +
                    TotalSeconds * 12 / 2 // this line for 12 bytes per cluster overhoad
                    ));
            }
            else if (ContainerType == ContainerType.AVI)
            {
                VideoOverhead = new FileSize(Unit.B, Frames * aviVideoOverhead);
            }
            else if (ContainerType == ContainerType.M2TS)
            {
                // for m2ts, video overhead is a ratio (rather than constant)
                VideoOverheadRatio = 106F / 100F;
            }
        }
Пример #4
0
        private void CalcAudioOverheadAndSize()
        {
            AudioOverheadRatio = 1;
            AudioSize = FileSize.Empty;
            AudioOverhead = FileSize.Empty;

            if (ContainerType == ContainerType.M2TS)
                AudioOverheadRatio = 106F / 100F;

            foreach (var audio in AudioStreams)
            {
                AudioSize += (audio.Size ?? FileSize.Empty);

                if (ContainerType == ContainerType.MKV)
                    AudioOverhead += new FileSize(Unit.B, GetMkvAudioOverhead(audio.AType, 48000, (double)TotalSeconds));
                else if (ContainerType == ContainerType.M2TS)
                    AudioOverhead +=  new FileSize(Unit.B, GetM2tsAudioOverhead(audio.AType, 48000, (double)TotalSeconds));
                else if (ContainerType == ContainerType.AVI)
                    AudioOverhead +=  new FileSize(Unit.B, GetAviAudioOverhead(audio.AType) * Frames);
            }
        }
Пример #5
0
 public void CalcByTotalSize()
 {
     CalcVideoOverhead();
     CalcAudioOverheadAndSize();
     CalcExtraOverhead();
     CalcQualityCodecModifier();
     VideoSize = new FileSize((ulong)((float)TotalSize.Bytes / VideoOverheadRatio)) - AudioMuxSize - ExtraMuxSize - VideoOverhead;
     CalcBitsPerPixel();
     CalcQualityEstimate();
 }
Пример #6
0
 public void CalcByBitsPerPixel()
 {
     CalcVideoOverhead();
     CalcAudioOverheadAndSize();
     CalcExtraOverhead();
     CalcQualityCodecModifier();
     VideoSize = new FileSize((ulong)((
         BitsPerPixel / 8F * (float)(FrameSize.Width * FrameSize.Height) * Frames / VideoOverheadRatio)) - VideoOverhead.Bytes);
     TotalSize = VideoMuxSize + AudioMuxSize + ExtraMuxSize;
     CalcQualityEstimate();
 }
Пример #7
0
 private void setConfig(string videoInput, string muxedInput, decimal? framerate, MuxStream[] audioStreams,
     MuxStream[] subtitleStreams, string chapterFile, string output, FileSize? splitSize, Dar? dar, string deviceType)
 {
     base.setConfig(videoInput, framerate, audioStreams, subtitleStreams, chapterFile, output, splitSize, dar, deviceType);
     this.muxedInput.Filename = muxedInput;
     this.checkIO();
 }
Пример #8
0
        /// <summary>
        /// sets the configuration of the GUI
        /// used when a job is loaded (jobs have everything already filled out)
        /// </summary>
        /// <param name="videoInput">the video input (raw or mp4)</param>
        /// <param name="framerate">framerate of the input</param>
        /// <param name="audioStreams">the audiostreams</param>
        /// <param name="subtitleStreams">the subtitle streams</param>
        /// <param name="output">name of the output</param>
        /// <param name="splitSize">split size of the output</param>
        public void setConfig(string videoInput, decimal? framerate, MuxStream[] audioStreams, MuxStream[] subtitleStreams, string chapterFile, string output, FileSize? splitSize, Dar? dar, string deviceType)
        {
            this.dar = dar;
            vInput.Filename = videoInput;
            fps.Value = framerate;

            int index = 0;
            foreach (MuxStream stream in audioStreams)
            {
                if (audioTracks.Count == index)
                    AudioAddTrack();
                audioTracks[index].Stream = stream;
                index++;
            }

            index = 0;
            foreach (MuxStream stream in subtitleStreams)
            {
                if (subtitleTracks.Count == index)
                    SubtitleAddTrack();
                subtitleTracks[index].Stream = stream;
                index++;
            }

            chapters.Filename = chapterFile;
            this.output.Filename = output;
            this.splitting.Value = splitSize;
            this.muxButton.Text = "Update";
            this.cbType.Text = deviceType;
            checkIO();
        }
Пример #9
0
 private void selectExtraFile(string file)
 {
     FileSize = FileSize.Of2(file) ?? FileSize.Empty;
     size.Text = FileSize.ToString();
     name.Text = System.IO.Path.GetFileName(file);
     raiseEvent();
 }
Пример #10
0
        private void audio1Bitrate_ValueChanged(object sender, EventArgs e)
        {
            if (length <= 0)
                return;

            if (updating)
                return;

            updating = true;

            int bitrate = (int)audio1Bitrate.Value;
            if (bitrate > 0 && audio1Type.SelectedIndex == -1)
                audio1Type.SelectedItem = AudioType.VBRMP3;
            double bytesPerSecond = (double)bitrate * 1000.0 / 8.0;
            FileSize f = new FileSize((ulong)(length * bytesPerSecond));
            //size.CertainValue = f;
            size.Text = f.ToString();
            raiseEvent();
            updating = false;
        }
Пример #11
0
        public JobChain GenerateMuxJobs(VideoStream video, decimal? framerate, MuxStream[] audioStreamsArray, MuxableType[] audioTypes,
            MuxStream[] subtitleStreamsArray, MuxableType[] subTypes,
            string chapterFile, MuxableType chapterInputType, ContainerType container, string output, FileSize? splitSize, List<string> inputsToDelete, string deviceType, MuxableType deviceOutputType)
        {
            Debug.Assert(splitSize == null || splitSize.Value != FileSize.Empty);

            MuxProvider prov = mainForm.MuxProvider;
            List<MuxableType> allTypes = new List<MuxableType>();
            allTypes.Add(video.VideoType);
            allTypes.AddRange(audioTypes);
            allTypes.AddRange(subTypes);
            if (chapterInputType != null)
                allTypes.Add(chapterInputType);
            if (deviceOutputType != null)
                allTypes.Add(deviceOutputType);
            MuxPath muxPath = prov.GetMuxPath(container, splitSize.HasValue, allTypes.ToArray());
            List<MuxJob> jobs = new List<MuxJob>();
            List<MuxStream> subtitleStreams = new List<MuxStream>(subtitleStreamsArray);
            List<MuxStream> audioStreams = new List<MuxStream>(audioStreamsArray);
            int index = 0;
            int tempNumber = 1;
            string previousOutput = null;
            foreach (MuxPathLeg mpl in muxPath)
            {
                List<string> filesToDeleteThisJob = new List<string>();

                MuxJob mjob = new MuxJob();

                if (previousOutput != null)
                {
                    mjob.Settings.MuxedInput = previousOutput;
                    filesToDeleteThisJob.Add(previousOutput);
                }

                mjob.NbOfFrames = video.NumberOfFrames;
                mjob.NbOfBFrames = video.Settings.NbBframes;
                mjob.Codec = video.Settings.Codec.ToString();
                string fpsFormated = String.Format("{0:##.###}", framerate); // this formating is required for mkvmerge at least to avoid fps rounding error
                mjob.Settings.Framerate = Convert.ToDecimal(fpsFormated);
                mjob.Settings.VideoName = video.Settings.VideoName;

                string tempOutputName = Path.Combine(Path.GetDirectoryName(output),
                    Path.GetFileNameWithoutExtension(output) + tempNumber + ".");
                tempNumber++;
                foreach (MuxableType o in mpl.handledInputTypes)
                {
                    if (o.outputType is VideoType)
                    {
                        mjob.Settings.VideoInput = video.Output;
                        if (inputsToDelete.Contains(video.Output))
                            filesToDeleteThisJob.Add(video.Output);
                        mjob.Settings.DAR = video.DAR;
                    }
                    else if (o.outputType is AudioType)
                    {
                        MuxStream stream = audioStreams.Find(delegate(MuxStream m)
                        {
                            return (VideoUtil.guessAudioType(m.path) == o.outputType);
                        });

                        if (stream != null)
                        {
                            mjob.Settings.AudioStreams.Add(stream);
                            audioStreams.Remove(stream);

                            if (inputsToDelete.Contains(stream.path))
                                filesToDeleteThisJob.Add(stream.path);
                        }
                    }
                    else if (o.outputType is SubtitleType)
                    {
                        MuxStream stream = subtitleStreams.Find(delegate(MuxStream m)
                        {
                            return (VideoUtil.guessSubtitleType(m.path) == o.outputType);
                        });

                        if (stream != null)
                        {
                            mjob.Settings.SubtitleStreams.Add(stream);
                            subtitleStreams.Remove(stream);

                            if (inputsToDelete.Contains(stream.path))
                                filesToDeleteThisJob.Add(stream.path);
                        }
                    }
                    else if (o.outputType is ChapterType)
                    {
                        if ((VideoUtil.guessChapterType(chapterFile) == o.outputType))
                            mjob.Settings.ChapterFile = chapterFile;
                        if (inputsToDelete.Contains(chapterFile))
                            filesToDeleteThisJob.Add(chapterFile);
                    }
                    else if (o.outputType is DeviceType)
                    {
                        if ((VideoUtil.guessDeviceType(deviceType) == o.outputType))
                            mjob.Settings.DeviceType = deviceType;
                    }
                }
                foreach (MuxStream s in mjob.Settings.AudioStreams)
                {
                    audioStreams.Remove(s);
                }
                foreach (MuxStream s in mjob.Settings.SubtitleStreams)
                {
                    subtitleStreams.Remove(s);
                }
                mjob.FilesToDelete.AddRange(filesToDeleteThisJob);
                if (index == muxPath.Length - 1)
                {
                    mjob.Settings.MuxedOutput = output;
                    mjob.Settings.SplitSize = splitSize;
                    mjob.Settings.DAR = video.DAR;
                    mjob.ContainerType = container;
                }
                else
                {
                    ContainerType cot = mpl.muxerInterface.GetContainersInCommon(muxPath[index + 1].muxerInterface)[0];
                    mjob.Settings.MuxedOutput = tempOutputName + cot.Extension;
                    mjob.ContainerType = cot;
                }
                previousOutput = mjob.Settings.MuxedOutput;
                index++;
                jobs.Add(mjob);
                if (string.IsNullOrEmpty(mjob.Settings.VideoInput))
                    mjob.Input = mjob.Settings.MuxedInput;
                else
                    mjob.Input = mjob.Settings.VideoInput;
                mjob.Output = mjob.Settings.MuxedOutput;
                mjob.MuxType = mpl.muxerInterface.MuxerType;
            }

            return new SequentialChain(jobs.ToArray());
        }
Пример #12
0
 public FileSizeEventArgs(FileSize value)
     : base()
 {
     Value = value;
 }