Exemplo n.º 1
0
        public void CreateEncodingProfile()
        {
            var profile = new EncodingProfile
            {
                Name = "TestProfile",
                VideoStreamConfigs = new List <VideoStreamConfig>
                {
                    new VideoStreamConfig
                    {
                        Bitrate = 1200000,
                        Codec   = VideoCodec.H264,
                        Width   = 1280,
                        Height  = 720,
                        Rate    = 24,
                        Profile = Profile.Main,
                        Preset  = Preset.Premium
                    }
                },
                AudioStreamConfigs = new List <AudioStreamConfig>
                {
                    new AudioStreamConfig
                    {
                        DefaultStreamId = 0,
                        Bitrate         = 192000
                    }
                }
            };

            var result = _api.CreateEncodingProfile(profile);

            Assert.IsNotNull(result);
        }
Exemplo n.º 2
0
 public ConfigState()
 {
     /* Set default values */
     fastTagging             = false;
     currentDatabase         = Constants.DEFAULT_DB_NAME;
     lang                    = null;
     autoSave                = false;
     captureVideoStandard    = VideoStandards.P480_16_9.Clone();
     captureEncodingProfile  = EncodingProfiles.MP4.Clone();
     captureEncodingQuality  = EncodingQualities.Medium.Clone();
     renderVideoStandard     = VideoStandards.P720_16_9.Clone();
     renderEncodingProfile   = EncodingProfiles.MP4.Clone();
     renderEncodingQuality   = EncodingQualities.High.Clone();
     overlayTitle            = true;
     enableAudio             = false;
     fps_n                   = 25;
     fps_d                   = 1;
     autorender              = false;
     autorenderDir           = null;
     lastRenderDir           = null;
     lastDir                 = null;
     reviewPlaysInSameWindow = true;
     defaultTemplate         = null;
     hotkeys                 = new Hotkeys();
     projectSortMethod       = ProjectSortMethod.Date;
     ignoreUpdaterVersion    = null;
 }
        public CommandResult SetEncoding(EncodingProfile enc)
        {
            ConnectionTag ct = GEnv.Connections.FindTag(_connection);

            _connection.Param.EncodingProfile = enc;
            ct.Terminal.Reset();
            GApp.Frame.AdjustTerminalUI(true, ct);
            return(CommandResult.Success);
        }
 public string GetEncoderProfile(VideoCodec codec, EncodingProfile profile)
 {
     if (Profiles.ContainsKey(codec))
     {
         string profileArg;
         Profiles[codec].TryGetValue(profile, out profileArg);
         return(profileArg);
     }
     return(null);
 }
Exemplo n.º 5
0
        private void ChangeEncoding(object sender, System.EventArgs e)
        {
            if (_blockEventHandler)
            {
                return;
            }
            EncodingProfile enc = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex);
            ContainerConnectionCommandTarget t = GApp.GetConnectionCommandTarget();

            t.SetEncoding(enc);
            t.Focus();
        }
Exemplo n.º 6
0
        private static void Instance_ScanCompleted(object sender, EventArgs e)
        {
            var source = sender as HandBrakeInstance;

            if (source.Titles.Count == 0)
            {
                Console.WriteLine("找無標題,ISO 無效");
                return;
            }

            foreach (var bitrate in bitrates)
            {
                var src          = new FileInfo(srcPath);
                var destfileName = $"{Path.GetFileNameWithoutExtension(srcPath)}_{bitrate}.mp4";
                var destPath     = Path.Combine(destDir, destfileName);

                EncodingProfile profile = GetProfile(bitrate);
                var             job     = new EncodeJob
                {
                    SourcePath      = srcPath,
                    OutputPath      = destPath,
                    EncodingProfile = profile,
                    Title           = instance.FeatureTitle,
                    SecondsStart    = TimeSpan.FromMinutes(10).TotalSeconds,
                    SecondsEnd      = TimeSpan.FromMinutes(11).TotalSeconds,
                    RangeType       = VideoRangeType.Seconds,
                    //RangeType = VideoRangeType.All,
                    ChosenAudioTracks = new List <int> {
                        1
                    },
                    Subtitles = new Subtitles
                    {
                        SourceSubtitles = new List <SourceSubtitle>(),
                        SrtSubtitles    = new List <SrtSubtitle>()
                    },
                };

                instance.EncodeProgress += (o, args) =>
                {
                    Console.WriteLine($"{destPath}\t{args.FractionComplete}");
                };
                instance.EncodeCompleted += (o, args) =>
                {
                    Console.WriteLine("Encode completed.");
                };
                instance.StartEncode(job);
            }

            Console.ReadLine();
            Console.WriteLine("Done");
        }
Exemplo n.º 7
0
        public EncodingSettings(VideoStandard videoStandard, EncodingProfile encodingProfile,
		                         EncodingQuality encodingQuality, uint fr_n, uint fr_d,
		                         string outputFile, bool enableAudio, bool enableTitle,
		                         uint titleSize)
        {
            VideoStandard = videoStandard;
            EncodingProfile = encodingProfile;
            EncodingQuality = encodingQuality;
            Framerate_n = fr_n;
            Framerate_d = fr_d;
            OutputFile = outputFile;
            TitleSize = titleSize;
            EnableAudio = enableAudio;
            EnableTitle = enableTitle;
        }
Exemplo n.º 8
0
        public static ListStore FillEncodingFormat(ComboBox encodingBox, EncodingProfile def)
        {
            ListStore encodingStore;
            int       index = 0, active = 0;

            encodingStore = new ListStore(typeof(string), typeof(EncodingProfile));
            foreach (EncodingProfile prof in EncodingProfiles.Render)
            {
                encodingStore.AppendValues(prof.Name, prof);
                if (prof.Equals(def))
                {
                    active = index;
                }
                index++;
            }
            encodingBox.Model  = encodingStore;
            encodingBox.Active = active;
            return(encodingStore);
        }
Exemplo n.º 9
0
        private SerialTerminalParam ValidateParam()
        {
            SerialTerminalParam p = new SerialTerminalParam();

            try {
                p.LogType = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None);
                if (p.LogType != LogType.None)
                {
                    p.LogPath = _logFileBox.Text;
                    if (p.LogPath == GUtil.CreateLogFileName(null))
                    {
                        p.LogPath = GUtil.CreateLogFileName(String.Format("com{0}", _portBox.SelectedIndex + 1));
                    }
                    LogFileCheckResult r = GCUtil.CheckLogFileName(p.LogPath, this);
                    if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error)
                    {
                        return(null);
                    }
                    p.LogAppend = (r == LogFileCheckResult.Append);
                }

                p.Port        = _portBox.SelectedIndex + 1;
                p.BaudRate    = Int32.Parse(_baudRateBox.Text);
                p.ByteSize    = (byte)(_dataBitsBox.SelectedIndex == 0? 7 : 8);
                p.StopBits    = (StopBits)_stopBitsBox.SelectedIndex;
                p.Parity      = (Parity)_parityBox.SelectedIndex;
                p.FlowControl = (FlowControl)_flowControlBox.SelectedIndex;

                p.EncodingProfile = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex);

                p.LocalEcho  = _localEchoBox.SelectedIndex == 1;
                p.TransmitNL = (NewLine)EnumDescAttributeT.For(typeof(NewLine)).FromDescription(_newLineBox.Text, LogType.None);

                p.TransmitDelayPerChar = Int32.Parse(_transmitDelayPerCharBox.Text);
                p.TransmitDelayPerLine = Int32.Parse(_transmitDelayPerLineBox.Text);
                return(p);
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(null);
            }
        }
Exemplo n.º 10
0
 public ConfigState()
 {
     /* Set default values */
     fastTagging             = false;
     currentDatabase         = Constants.DEFAULT_DB_NAME;
     lang                    = null;
     autoSave                = false;
     captureVideoStandard    = VideoStandards.P480_16_9;
     captureEncodingProfile  = EncodingProfiles.MP4;
     captureEncodingQuality  = EncodingQualities.Medium;
     renderVideoStandard     = VideoStandards.P720_16_9;
     renderEncodingProfile   = EncodingProfiles.MP4;
     renderEncodingQuality   = EncodingQualities.High;
     overlayTitle            = true;
     enableAudio             = false;
     fps_n                   = 25;
     fps_d                   = 1;
     autorender              = false;
     autorenderDir           = null;
     reviewPlaysInSameWindow = true;
 }
Exemplo n.º 11
0
        public JapaneseCharDecoder(TerminalConnection con)
        {
            _jisbuf = new MemoryStream(0x1000);
            _state = State.Normal;
            _connection = con;
            _encoding = con.Param.EncodingProfile;

            _iso2022jpByteProcessor   = new ByteProcessor(this.ProcessByteAsISO2022JP);
            _DECLineByteProcessor     = new ByteProcessor(this.ProcessByteAsDECLine);
            _currentByteProcessor = null;
            _G0ByteProcessor = null;
            _G1ByteProcessor = null;
        }
Exemplo n.º 12
0
        /// <summary>
        /// Get an EncodeJob model for a LibHB Encode.
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <returns>
        /// An Interop.EncodeJob model.
        /// </returns>
        public static EncodeJob GetEncodeJob(EncodeTask task)
        {
            // The current Job Configuration
            EncodeTask work = task;

            // Which will be converted to this EncodeJob Model.
            EncodeJob       job     = new EncodeJob();
            EncodingProfile profile = new EncodingProfile();

            job.EncodingProfile = profile;

            // Audio Settings
            profile.AudioEncodings = new List <AudioEncoding>();
            job.ChosenAudioTracks  = new List <int>();
            foreach (AudioTrack track in work.AudioTracks)
            {
                AudioEncoding newTrack = new AudioEncoding
                {
                    Bitrate       = track.Bitrate,
                    Drc           = track.DRC,
                    Gain          = track.Gain,
                    Encoder       = Converters.GetCliAudioEncoder(track.Encoder),
                    InputNumber   = track.Track.HasValue ? track.Track.Value : 0,
                    Mixdown       = Converters.GetCliMixDown(track.MixDown),
                    SampleRateRaw = GetSampleRateRaw(track.SampleRate),
                };

                profile.AudioEncodings.Add(newTrack);
                if (track.Track != null)
                {
                    job.ChosenAudioTracks.Add(track.Track.Value);
                }
            }

            // Title Settings
            job.OutputPath = work.Destination;
            job.SourcePath = work.Source;
            job.Title      = work.Title;
            // job.SourceType = work.Type;
            switch (work.PointToPointMode)
            {
            case PointToPointMode.Chapters:
                job.RangeType = VideoRangeType.Chapters;
                break;

            case PointToPointMode.Seconds:
                job.RangeType = VideoRangeType.Seconds;
                break;

            case PointToPointMode.Frames:
                job.RangeType = VideoRangeType.Frames;
                break;
            }

            if (work.PointToPointMode == PointToPointMode.Seconds)
            {
                job.SecondsEnd   = work.EndPoint;
                job.SecondsStart = work.StartPoint;
            }
            if (work.PointToPointMode == PointToPointMode.Chapters)
            {
                job.ChapterStart = work.StartPoint;
                job.ChapterEnd   = work.EndPoint;
            }
            if (work.PointToPointMode == PointToPointMode.Frames)
            {
                job.FramesEnd   = work.EndPoint;
                job.FramesStart = work.StartPoint;
            }

            job.Angle           = work.Angle;
            job.EncodingProfile = profile;

            // Output Settings
            profile.IPod5GSupport = work.IPod5GSupport;
            profile.Optimize      = work.OptimizeMP4;
            switch (work.OutputFormat)
            {
            case OutputFormat.Mp4:
            case OutputFormat.M4V:
                profile.ContainerName = "av_mp4";     // TODO make part of enum.
                break;

            case OutputFormat.Mkv:
                profile.ContainerName = "av_mkv";     // TODO make part of enum.
                break;
            }

            // Picture Settings
            profile.Anamorphic = work.Anamorphic;
            profile.Cropping   = new Cropping
            {
                Top    = work.Cropping.Top,
                Bottom = work.Cropping.Bottom,
                Left   = work.Cropping.Left,
                Right  = work.Cropping.Right
            };
            profile.CroppingType = CroppingType.Custom; // TODO deal with this better
            profile.DisplayWidth = work.DisplayWidth.HasValue
                           ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString())
                           : 0;
            profile.PixelAspectX      = work.PixelAspectX;
            profile.PixelAspectY      = work.PixelAspectY;
            profile.Height            = work.Height.HasValue ? work.Height.Value : 0;
            profile.KeepDisplayAspect = work.KeepDisplayAspect;
            profile.MaxHeight         = work.MaxHeight.HasValue ? work.MaxHeight.Value : 0;
            profile.MaxWidth          = work.MaxWidth.HasValue ? work.MaxWidth.Value : 0;
            profile.Modulus           = work.Modulus.HasValue ? work.Modulus.Value : 16;
            profile.UseDisplayWidth   = true;
            profile.Width             = work.Width.HasValue ? work.Width.Value : 0;

            // Filter Settings
            profile.CustomDecomb      = work.CustomDecomb;
            profile.CustomDeinterlace = work.CustomDeinterlace;
            profile.CustomDenoise     = work.CustomDenoise;
            profile.CustomDetelecine  = work.CustomDetelecine;
            if (work.Deblock > 4)
            {
                profile.Deblock = work.Deblock;
            }
            profile.Decomb      = work.Decomb;
            profile.Deinterlace = work.Deinterlace;
            profile.Denoise     = work.Denoise;
            profile.Detelecine  = work.Detelecine;
            profile.Grayscale   = work.Grayscale;

            // Video Settings
            profile.Framerate           = work.Framerate.HasValue ? work.Framerate.Value : 0;
            profile.ConstantFramerate   = work.FramerateMode == FramerateMode.CFR;
            profile.Quality             = work.Quality.HasValue ? work.Quality.Value : 0;
            profile.VideoBitrate        = work.VideoBitrate.HasValue ? work.VideoBitrate.Value : 0;
            profile.VideoEncodeRateType = work.VideoEncodeRateType;
            profile.VideoEncoder        = Converters.GetVideoEncoder(work.VideoEncoder);

            if (work.VideoEncoder == VideoEncoder.X264)
            {
                profile.VideoPreset = work.X264Preset.ToString().ToLower().Replace(" ", string.Empty);
                profile.VideoTunes  = new List <string>();

                if (work.X264Tune != x264Tune.None)
                {
                    profile.VideoTunes.Add(work.X264Tune.ToString().ToLower().Replace(" ", string.Empty));
                }

                if (work.FastDecode)
                {
                    profile.VideoTunes.Add("fastdecode");
                }
            }
            else if (work.VideoEncoder == VideoEncoder.X265)
            {
                profile.VideoPreset  = work.X265Preset.ToString().ToLower().Replace(" ", string.Empty);
                profile.VideoProfile = work.H265Profile.ToString().ToLower().Replace(" ", string.Empty);
                profile.VideoTunes   = new List <string>();
            }

            profile.VideoLevel   = work.H264Level;
            profile.VideoProfile = work.H264Profile.ToString().ToLower().Replace(" ", string.Empty); // TODO change these away from strings.

            // Chapter Markers
            profile.IncludeChapterMarkers = work.IncludeChapterMarkers;
            job.CustomChapterNames        = work.ChapterNames.Select(item => item.ChapterName).ToList();
            job.UseDefaultChapterNames    = work.IncludeChapterMarkers;

            // Advanced Settings
            profile.VideoOptions = work.AdvancedEncoderOptions;

            // Subtitles
            job.Subtitles = new Subtitles {
                SourceSubtitles = new List <SourceSubtitle>(), SrtSubtitles = new List <SrtSubtitle>()
            };
            foreach (SubtitleTrack track in work.SubtitleTracks)
            {
                if (track.IsSrtSubtitle)
                {
                    job.Subtitles.SrtSubtitles.Add(
                        new SrtSubtitle
                    {
                        CharacterCode = track.SrtCharCode,
                        Default       = track.Default,
                        FileName      = track.SrtFileName,
                        LanguageCode  = track.SrtLang,
                        Offset        = track.SrtOffset
                    });
                }
                else
                {
                    if (track.SourceTrack != null)
                    {
                        job.Subtitles.SourceSubtitles.Add(
                            new SourceSubtitle
                        {
                            BurnedIn    = track.Burned,
                            Default     = track.Default,
                            Forced      = track.Forced,
                            TrackNumber = track.SourceTrack.TrackNumber
                        });
                    }
                }
            }

            return(job);
        }
Exemplo n.º 13
0
        /*
         * TODO: This conversion class needs to be finished off before libencode will work.
         */

        /// <summary>
        /// Get an EncodeJob model for a LibHB Encode.
        /// </summary>
        /// <param name="task">
        /// The task.
        /// </param>
        /// <returns>
        /// An Interop.EncodeJob model.
        /// </returns>
        public static EncodeJob GetEncodeJob(QueueTask task)
        {
            // Sanity Checking
            if (task == null || task.Task == null)
            {
                return(null);
            }

            // The current Job Configuration
            EncodeTask work = task.Task;

            // Which will be converted to this EncodeJob Model.
            EncodeJob job = new EncodeJob();



            EncodingProfile profile = new EncodingProfile();

            job.EncodingProfile = profile;

            profile.Anamorphic = work.Anamorphic;

            profile.AudioEncodings = new List <AudioEncoding>();
            job.ChosenAudioTracks  = new List <int>();
            foreach (AudioTrack track in work.AudioTracks)
            {
                AudioEncoding newTrack = new AudioEncoding
                {
                    Bitrate       = track.Bitrate,
                    Drc           = track.DRC,
                    Gain          = track.Gain,
                    Encoder       = track.Encoder,
                    InputNumber   = track.Track.HasValue ? track.Track.Value : 0,
                    Mixdown       = track.MixDown,
                    SampleRateRaw = GetSampleRateRaw(track.SampleRate),
                };

                profile.AudioEncodings.Add(newTrack);
                if (track.Track != null)
                {
                    job.ChosenAudioTracks.Add(track.Track.Value);
                }
            }
            profile.Cropping = new Cropping
            {
                Top    = work.Cropping.Top,
                Bottom = work.Cropping.Bottom,
                Left   = work.Cropping.Left,
                Right  = work.Cropping.Right
            };

            profile.CustomCropping    = true; // TODO deal with this better
            profile.CustomDecomb      = work.CustomDecomb;
            profile.CustomDeinterlace = work.CustomDeinterlace;
            profile.CustomDenoise     = work.CustomDenoise;
            profile.CustomDetelecine  = work.CustomDetelecine;
            profile.Deblock           = work.Deblock;
            profile.Decomb            = work.Decomb;
            profile.Deinterlace       = work.Deinterlace;
            profile.Denoise           = work.Denoise;
            profile.Detelecine        = work.Detelecine;
            profile.DisplayWidth      = work.DisplayWidth.HasValue
                                       ? int.Parse(Math.Round(work.DisplayWidth.Value, 0).ToString())
                                       : 0;
            profile.Framerate             = work.Framerate.HasValue ? work.Framerate.Value : 0;
            profile.Grayscale             = work.Grayscale;
            profile.Height                = work.Height.HasValue ? work.Height.Value : 0;
            profile.IPod5GSupport         = work.IPod5GSupport;
            profile.IncludeChapterMarkers = work.IncludeChapterMarkers;
            profile.KeepDisplayAspect     = work.KeepDisplayAspect;
            profile.LargeFile             = work.LargeFile;
            profile.MaxHeight             = work.MaxHeight.HasValue ? work.MaxHeight.Value : 0;
            profile.MaxWidth              = work.MaxWidth.HasValue ? work.MaxWidth.Value : 0;
            profile.Modulus               = work.Modulus.HasValue ? work.Modulus.Value : 16;
            profile.Optimize              = work.OptimizeMP4;
            switch (work.OutputFormat)
            {
            case OutputFormat.Mp4:
            case OutputFormat.M4V:
                profile.OutputFormat = Interop.Model.Encoding.OutputFormat.Mp4;
                break;

            case OutputFormat.Mkv:
                profile.OutputFormat = Interop.Model.Encoding.OutputFormat.Mkv;
                break;
            }
            profile.PeakFramerate = work.FramerateMode == FramerateMode.PFR;
            profile.PixelAspectX  = work.PixelAspectX;
            profile.PixelAspectY  = work.PixelAspectY;

            switch (work.OutputFormat)
            {
            case OutputFormat.Mp4:
                profile.PreferredExtension = OutputExtension.Mp4;
                break;

            case OutputFormat.M4V:
                profile.PreferredExtension = OutputExtension.M4v;
                break;
            }
            profile.Quality             = work.Quality.HasValue ? work.Quality.Value : 0;
            profile.UseDisplayWidth     = true;
            profile.VideoBitrate        = work.VideoBitrate.HasValue ? work.VideoBitrate.Value : 0;
            profile.VideoEncodeRateType = work.VideoEncodeRateType;
            profile.VideoEncoder        = work.VideoEncoder;
            profile.Width       = work.Width.HasValue ? work.Width.Value : 0;
            profile.X264Options = work.AdvancedEncoderOptions;

            if (work.PointToPointMode == PointToPointMode.Chapters)
            {
                job.ChapterStart = work.StartPoint;
                job.ChapterEnd   = work.EndPoint;
            }

            job.Angle           = work.Angle;
            job.EncodingProfile = profile;
            if (work.PointToPointMode == PointToPointMode.Frames)
            {
                job.FramesEnd   = work.EndPoint;
                job.FramesStart = work.StartPoint;
            }

            job.CustomChapterNames     = work.ChapterNames;
            job.UseDefaultChapterNames = work.IncludeChapterMarkers;

            job.OutputPath = work.Destination;
            switch (work.PointToPointMode)
            {
            case PointToPointMode.Chapters:
                job.RangeType = VideoRangeType.Chapters;
                break;

            case PointToPointMode.Seconds:
                job.RangeType = VideoRangeType.Seconds;
                break;

            case PointToPointMode.Frames:
                job.RangeType = VideoRangeType.Frames;
                break;
            }


            if (work.PointToPointMode == PointToPointMode.Seconds)
            {
                job.SecondsEnd   = work.EndPoint;
                job.SecondsStart = work.StartPoint;
            }

            job.SourcePath = work.Source;
            // job.SourceType = work.Type;
            job.Title = work.Title;

            // TODO Setup subtitles
            job.Subtitles = new Subtitles {
                SourceSubtitles = new List <SourceSubtitle>(), SrtSubtitles = new List <SrtSubtitle>()
            };
            //foreach (SubtitleTrack track in work.SubtitleTracks)
            //{
            //    // TODO
            //}


            return(job);
        }
 public CommandResult SetEncoding(EncodingProfile enc)
 {
     ConnectionTag ct = GEnv.Connections.FindTag(_connection);
     _connection.Param.EncodingProfile = enc;
     ct.Terminal.Reset();
     GApp.Frame.AdjustTerminalUI(true, ct);
     return CommandResult.Success;
 }
Exemplo n.º 15
0
        public static List <string> ResolveVideoProfile(VideoContainer container, VideoCodec videoCodec, AudioCodec audioCodec, EncodingProfile h264Profile, float h264Level, float fps, int width, int height, long videoBitrate, long audioBitrate, Timestamp timestampType)
        {
            List <string> valuesProfiles = new List <string>();

            if (container == VideoContainer.Asf)
            {
                if ((videoCodec == VideoCodec.Wmv && audioCodec == AudioCodec.Unknown) ||
                    (videoCodec == VideoCodec.Wmv && audioCodec == AudioCodec.Mp3) ||
                    (audioCodec == AudioCodec.Wma || audioCodec == AudioCodec.WmaPro))
                {
                    if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma)
                    {
                        valuesProfiles.Add("WMV");
                    }
                }
                else if (videoCodec == VideoCodec.Vc1)
                {
                    valuesProfiles.Add("VC1_ASF");
                }
                else if (videoCodec == VideoCodec.Mpeg1 || videoCodec == VideoCodec.Mpeg2)
                {
                    valuesProfiles.Add("DVR_MS");
                }
                else
                {
                    throw new Exception("ASF video file does not match any supported web profile");
                }
            }
            else if (container == VideoContainer.Avi)
            {
                valuesProfiles.Add("AVI");
            }
            else if (container == VideoContainer.Matroska)
            {
                valuesProfiles.Add("MATROSKA");
            }
            else if (container == VideoContainer.Mp4)
            {
                if (videoCodec == VideoCodec.H264)
                {
                    valuesProfiles.Add("AVC_MP4");
                }
                else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4)
                {
                    valuesProfiles.Add("MPEG4_P2_MP4");
                }
                else if (videoCodec == VideoCodec.H263 && audioCodec == AudioCodec.Aac)
                {
                    valuesProfiles.Add("MPEG4_H263_MP4");
                }
                else
                {
                    throw new Exception("MP4 video file does not match any supported web profile");
                }
            }
            else if (container == VideoContainer.Mpeg2Ps)
            {
                valuesProfiles.Add("MPEG_PS");
            }
            else if (container == VideoContainer.Mpeg1)
            {
                valuesProfiles.Add("MPEG1");
            }
            else if (container == VideoContainer.Mpeg2Ts || container == VideoContainer.M2Ts)
            {
                if (videoCodec == VideoCodec.Mpeg2)
                {
                    valuesProfiles.Add("MPEG_TS");
                }
                else if (videoCodec == VideoCodec.H264)
                {
                    valuesProfiles.Add("AVC_TS");
                }
                else if (videoCodec == VideoCodec.Vc1)
                {
                    valuesProfiles.Add("VC1_TS");
                }
                else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4)
                {
                    valuesProfiles.Add("MPEG4_P2_TS");
                }
                else
                {
                    throw new Exception("MPEG2TS video file does not match any supported web profile");
                }
            }
            else if (container == VideoContainer.Flv)
            {
                valuesProfiles.Add("FLV");
            }
            else if (container == VideoContainer.Wtv)
            {
                valuesProfiles.Add("WTV");
            }
            else if (container == VideoContainer.Gp3)
            {
                if (videoCodec == VideoCodec.H264)
                {
                    valuesProfiles.Add("AVC_3GPP");
                }
                else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4)
                {
                    valuesProfiles.Add("MPEG4_P2_3GPP");
                }
                else if (videoCodec == VideoCodec.H263)
                {
                    valuesProfiles.Add("MPEG4_H263_3GPP");
                }
                else
                {
                    throw new Exception("3GP video file does not match any supported web profile");
                }
            }
            else if (container == VideoContainer.RealMedia)
            {
                valuesProfiles.Add("REAL_VIDEO");
            }
            else if (container == VideoContainer.Ogg)
            {
                valuesProfiles.Add("OGV");
            }
            else if (container == VideoContainer.Hls)
            {
                if (videoCodec == VideoCodec.H264 && (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac || audioCodec == AudioCodec.Mp3))
                {
                    valuesProfiles.Add("HLS");
                }
                else
                {
                    throw new Exception("HLS video file does not match any supported web profile");
                }
            }
            else
            {
                throw new Exception("Video does not match any supported web profile");
            }
            return(valuesProfiles);
        }
Exemplo n.º 16
0
 public void Reset(EncodingProfile enc)
 {
     _encoding.Reset();
     _encoding = enc;
     _encoding.Reset();
 }
Exemplo n.º 17
0
        public static ListStore FillEncodingFormat(ComboBox encodingBox, EncodingProfile def)
        {
            ListStore encodingStore;
            int index = 0, active = 0;

            encodingStore = new ListStore (typeof(string), typeof(EncodingProfile));
            foreach (EncodingProfile prof in EncodingProfiles.Render) {
                encodingStore.AppendValues (prof.Name, prof);
                if (prof.Equals (def))
                    active = index;
                index++;
            }
            encodingBox.Model = encodingStore;
            encodingBox.Active = active;
            return encodingStore;
        }
Exemplo n.º 18
0
        public static List <string> ResolveVideoProfile(VideoContainer container, VideoCodec videoCodec, AudioCodec audioCodec, EncodingProfile h264Profile, float?h264Level, float?fps, int?width, int?height, long?videoBitrate, long?audioBitrate, Timestamp timestampType)
        {
            List <string> valuesProfiles = new List <string>();

            if (container == VideoContainer.Asf)
            {
                if ((videoCodec == VideoCodec.Wmv && audioCodec == AudioCodec.Unknown) ||
                    (videoCodec == VideoCodec.Wmv && audioCodec == AudioCodec.Mp3) ||
                    (audioCodec == AudioCodec.Wma || audioCodec == AudioCodec.WmaPro))
                {
                    if (width <= 176 && height <= 144)
                    {
                        if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma)
                        {
                            if (audioBitrate != 0 && audioBitrate < 193)
                            {
                                valuesProfiles.Add("WMVSPLL_BASE");

                                //Fallback
                                valuesProfiles.Add("WMVMED_BASE");
                            }
                            else
                            {
                                valuesProfiles.Add("WMVMED_FULL");
                            }
                        }
                        else if (audioCodec == AudioCodec.Mp3)
                        {
                            valuesProfiles.Add("WMVSPLL_MP3");
                        }
                        else
                        {
                            valuesProfiles.Add("WMVMED_PRO");
                        }
                    }
                    else if (width <= 352 && height <= 288)
                    {
                        if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma)
                        {
                            if (audioBitrate > 0 && audioBitrate < 193)
                            {
                                valuesProfiles.Add("WMVSPML_BASE");

                                //Fallback
                                valuesProfiles.Add("WMVMED_BASE");
                            }
                            else
                            {
                                valuesProfiles.Add("WMVMED_FULL");
                            }
                        }
                        else if (audioCodec == AudioCodec.Mp3)
                        {
                            valuesProfiles.Add("WMVSPML_MP3");
                        }
                        else
                        {
                            valuesProfiles.Add("WMVMED_PRO");
                        }
                    }
                    else if (width <= 720 && height <= 576)
                    {
                        if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma)
                        {
                            if (audioBitrate > 0 && audioBitrate < 193)
                            {
                                valuesProfiles.Add("WMVMED_BASE");
                            }
                            else
                            {
                                valuesProfiles.Add("WMVMED_FULL");
                            }
                        }
                        else
                        {
                            valuesProfiles.Add("WMVMED_PRO");
                        }
                    }
                    else if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Wma)
                    {
                        if (audioBitrate > 0 && audioBitrate < 193)
                        {
                            valuesProfiles.Add("WMVHIGH_BASE");
                        }
                        else
                        {
                            valuesProfiles.Add("WMVHIGH_FULL");
                        }
                    }
                    else
                    {
                        valuesProfiles.Add("WMVHIGH_PRO");
                    }
                }
                else if (videoCodec == VideoCodec.Vc1)
                {
                    if (width <= 720 && height <= 576)
                    {
                        valuesProfiles.Add("VC1_ASF_AP_L1_WMA");
                    }
                    else if (width <= 1280 && height <= 720)
                    {
                        valuesProfiles.Add("VC1_ASF_AP_L2_WMA");
                    }
                    else if (width <= 1920 && height <= 1080)
                    {
                        valuesProfiles.Add("VC1_ASF_AP_L3_WMA");
                    }
                }
                else if (videoCodec == VideoCodec.Mpeg1 || videoCodec == VideoCodec.Mpeg2)
                {
                    valuesProfiles.Add("DVR_MS");
                }
                else
                {
                    throw new Exception("ASF video file does not match any supported DLNA profile");
                }
            }
            else if (container == VideoContainer.Avi)
            {
                valuesProfiles.Add("AVI");
            }
            else if (container == VideoContainer.Matroska)
            {
                valuesProfiles.Add("MATROSKA");
            }
            else if (container == VideoContainer.Mp4)
            {
                bool isHD = false;
                if (Convert.ToInt32(width) > 720 || Convert.ToInt32(height) > 576)
                {
                    isHD = true;
                }
                long bitrate = 0;
                if (videoBitrate > 0 && audioBitrate > 0)
                {
                    bitrate = videoBitrate.Value + audioBitrate.Value;
                }

                if (videoCodec == VideoCodec.H264)
                {
                    if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Ac3 || audioCodec == AudioCodec.EAc3)
                    {
                        if (h264Profile == EncodingProfile.Baseline)
                        {
                            if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                            {
                                valuesProfiles.Add("AVC_MP4_BL_CIF30_AC3");
                            }
                        }

                        if (isHD)
                        {
                            valuesProfiles.Add("AVC_MP4_MP_HD_AC3");
                        }

                        //Main profile and fallback
                        valuesProfiles.Add("AVC_MP4_MP_SD_AC3");
                    }
                    else if (audioCodec == AudioCodec.Mp3)
                    {
                        if (isHD)
                        {
                            valuesProfiles.Add("AVC_MP4_MP_HD_MPEG1_L3");
                        }

                        valuesProfiles.Add("AVC_MP4_MP_SD_MPEG1_L3");
                    }
                    else if (audioCodec == AudioCodec.Lpcm)
                    {
                        valuesProfiles.Add("AVC_MP4_LPCM");
                    }
                    if (isHD == false)
                    {
                        if (audioCodec == AudioCodec.Aac)
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    if (bitrate > 0 && bitrate <= 520)
                                    {
                                        valuesProfiles.Add("AVC_MP4_BL_CIF30_AAC_520");
                                    }
                                    else if (bitrate > 0 && bitrate <= 940)
                                    {
                                        valuesProfiles.Add("AVC_MP4_BL_CIF30_AAC_940");
                                    }

                                    //Fallback
                                    valuesProfiles.Add("AVC_MP4_BL_CIF30_AAC_MULT5");
                                }
                                else
                                {
                                    if (h264Level == 3.0 && bitrate > 0 && bitrate <= 5000)
                                    {
                                        valuesProfiles.Add("AVC_MP4_BL_L3L_SD_AAC");
                                    }
                                    else if (h264Level <= 3.1 && bitrate > 0 && bitrate <= 15000)
                                    {
                                        valuesProfiles.Add("AVC_MP4_BL_L31_HD_AAC");
                                    }
                                }
                            }

                            //Main profile and fallback
                            valuesProfiles.Add("AVC_MP4_MP_SD_AAC_MULT5");
                        }
                        else if (audioCodec == AudioCodec.Dts)
                        {
                            valuesProfiles.Add("AVC_MP4_MP_SD_DTS");
                        }
                        else if (audioCodec == AudioCodec.DtsHd)
                        {
                            valuesProfiles.Add("AVC_MP4_MP_SD_DTSHD");
                        }
                    }
                    else if (Convert.ToInt32(width) <= 1280 && Convert.ToInt32(height) <= 720)
                    {
                        if (audioCodec == AudioCodec.Aac)
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (h264Level <= 3.1 && bitrate > 0 && bitrate <= 15000)
                                {
                                    valuesProfiles.Add("AVC_MP4_BL_L31_HD_AAC");
                                }
                                else if (h264Level <= 3.2 && bitrate > 0 && bitrate <= 21000)
                                {
                                    valuesProfiles.Add("AVC_MP4_BL_L32_HD_AAC");
                                }
                            }

                            //Main profile and fallback
                            valuesProfiles.Add("AVC_MP4_MP_HD_720p_AAC");
                        }
                        else if (audioCodec == AudioCodec.Dts)
                        {
                            valuesProfiles.Add("AVC_MP4_HP_HD_DTS");
                        }
                        else if (audioCodec == AudioCodec.DtsHd)
                        {
                            valuesProfiles.Add("AVC_MP4_HP_HD_DTSHD");
                        }
                    }
                    else if (Convert.ToInt32(width) <= 1920 && Convert.ToInt32(height) <= 1080)
                    {
                        if (audioCodec == AudioCodec.Aac)
                        {
                            if (h264Profile == EncodingProfile.High || h264Profile == EncodingProfile.High10 || h264Profile == EncodingProfile.High422 || h264Profile == EncodingProfile.High444)
                            {
                                valuesProfiles.Add("AVC_MP4_HP_HD_AAC");
                            }

                            //Main profile and fallback
                            valuesProfiles.Add("AVC_MP4_MP_HD_1080i_AAC");
                        }
                        else if (audioCodec == AudioCodec.Dts)
                        {
                            valuesProfiles.Add("AVC_MP4_HP_HD_DTS");
                        }
                        else if (audioCodec == AudioCodec.DtsHd)
                        {
                            valuesProfiles.Add("AVC_MP4_HP_HD_DTSHD");
                        }
                    }
                }
                else if (videoCodec == VideoCodec.H265)
                {
                    valuesProfiles.Add("HEVC_MP4");
                }
                else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4)
                {
                    if (Convert.ToInt32(width) <= 720 && Convert.ToInt32(height) <= 576)
                    {
                        if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac)
                        {
                            valuesProfiles.Add("MPEG4_P2_MP4_ASP_AAC");
                        }
                        else if (audioCodec == AudioCodec.Ac3 || audioCodec == AudioCodec.Mp3)
                        {
                            valuesProfiles.Add("MPEG4_P2_MP4_NDSD");
                        }
                    }
                    else if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac)
                    {
                        valuesProfiles.Add("MPEG4_P2_MP4_SP_L6_AAC");
                    }
                }
                else if (videoCodec == VideoCodec.H263 && audioCodec == AudioCodec.Aac)
                {
                    valuesProfiles.Add("MPEG4_H263_MP4_P0_L10_AAC");
                }
                else
                {
                    throw new Exception("MP4 video file does not match any supported DLNA profile");
                }
            }
            else if (container == VideoContainer.Mpeg2Ps)
            {
                valuesProfiles.Add("MPEG_PS_PAL");
                valuesProfiles.Add("MPEG_PS_NTSC");
            }
            else if (container == VideoContainer.Mpeg1)
            {
                valuesProfiles.Add("MPEG1");
            }
            else if (container == VideoContainer.Mpeg2Ts || container == VideoContainer.M2Ts)
            {
                bool isHD = false;
                if (Convert.ToInt32(width) > 720 || Convert.ToInt32(height) > 576)
                {
                    isHD = true;
                }

                if (videoCodec == VideoCodec.Mpeg2)
                {
                    if (isHD)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("MPEG_TS_HD_EU_ISO");
                            valuesProfiles.Add("MPEG_TS_HD_NA_ISO");
                            valuesProfiles.Add("MPEG_TS_HD_KO_ISO");
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            valuesProfiles.Add("MPEG_TS_HD_EU_T");
                            valuesProfiles.Add("MPEG_TS_HD_NA_T");
                            valuesProfiles.Add("MPEG_TS_HD_KO_T");
                            if (audioCodec == AudioCodec.Aac)
                            {
                                valuesProfiles.Add("MPEG_TS_JP_T");
                            }
                        }
                        else
                        {
                            valuesProfiles.Add("MPEG_TS_HD_EU");
                            valuesProfiles.Add("MPEG_TS_HD_NA");
                            valuesProfiles.Add("MPEG_TS_HD_KO");
                        }
                    }
                    else
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("MPEG_TS_SD_EU_ISO");
                            valuesProfiles.Add("MPEG_TS_SD_NA_ISO");
                            valuesProfiles.Add("MPEG_TS_SD_KO_ISO");
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            valuesProfiles.Add("MPEG_TS_SD_EU_T");
                            valuesProfiles.Add("MPEG_TS_SD_NA_T");
                            valuesProfiles.Add("MPEG_TS_SD_KO_T");
                            if (audioCodec == AudioCodec.Aac)
                            {
                                valuesProfiles.Add("MPEG_TS_JP_T");
                            }
                        }
                        else
                        {
                            valuesProfiles.Add("MPEG_TS_SD_EU");
                            valuesProfiles.Add("MPEG_TS_SD_NA");
                            valuesProfiles.Add("MPEG_TS_SD_KO");
                        }
                    }
                }
                else if (videoCodec == VideoCodec.H264)
                {
                    if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Ac3 || audioCodec == AudioCodec.EAc3)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF15_AC3_ISO");
                                }
                                else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_AC3_ISO");
                                }
                            }
                            else if (h264Profile == EncodingProfile.High || h264Profile == EncodingProfile.High10 || h264Profile == EncodingProfile.High422 || h264Profile == EncodingProfile.High444)
                            {
                                if (isHD)
                                {
                                    valuesProfiles.Add("AVC_TS_HP_HD_AC3_ISO");
                                }
                                else
                                {
                                    valuesProfiles.Add("AVC_TS_HP_SD_AC3_ISO");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_AC3_ISO");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_AC3_ISO");
                            }
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF15_AC3_T");
                                }
                                else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_AC3_T");
                                }
                            }
                            else if (h264Profile == EncodingProfile.High || h264Profile == EncodingProfile.High10 || h264Profile == EncodingProfile.High422 || h264Profile == EncodingProfile.High444)
                            {
                                if (isHD)
                                {
                                    valuesProfiles.Add("AVC_TS_HP_HD_AC3_T");
                                }
                                else
                                {
                                    valuesProfiles.Add("AVC_TS_HP_SD_AC3_T");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_AC3_T");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_AC3_T");
                            }
                        }
                        else
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF15_AC3");
                                }
                                else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_AC3");
                                }
                            }
                            else if (h264Profile == EncodingProfile.High || h264Profile == EncodingProfile.High10 || h264Profile == EncodingProfile.High422 || h264Profile == EncodingProfile.High444)
                            {
                                if (isHD)
                                {
                                    valuesProfiles.Add("AVC_TS_HP_HD_AC3");
                                }
                                else
                                {
                                    valuesProfiles.Add("AVC_TS_HP_SD_AC3");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_AC3");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_AC3");
                            }
                        }
                    }
                    else if (audioCodec == AudioCodec.Lpcm)
                    {
                        if (fps >= 59)
                        {
                            valuesProfiles.Add("AVC_TS_HD_60_LPCM_T");
                        }

                        //Fallback
                        valuesProfiles.Add("AVC_TS_HD_50_LPCM_T");
                    }
                    else if (audioCodec == AudioCodec.Dts)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("AVC_TS_HD_DTS_ISO");
                        }
                        else
                        {
                            valuesProfiles.Add("AVC_TS_HD_DTS_T");
                        }
                    }
                    else if (audioCodec == AudioCodec.DtsHd)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("AVC_TS_DTSHD_MA_ISO");
                        }
                        else
                        {
                            valuesProfiles.Add("AVC_TS_DTSHD_MA_T");
                        }
                    }
                    else if (audioCodec == AudioCodec.Mp2)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_HP_HD_MPEG1_L2_ISO");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_HP_SD_MPEG1_L2_ISO");
                            }
                        }
                        else
                        {
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_HP_HD_MPEG1_L2_T");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_HP_SD_MPEG1_L2_T");
                            }
                        }
                    }
                    else if (audioCodec == AudioCodec.Aac)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF15_AAC_MULT5_ISO");
                                }
                                else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_AAC_MULT5_ISO");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_AAC_MULT5_ISO");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_AAC_MULT5_ISO");
                            }
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF15_AAC_MULT5_T");
                                }
                                else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_AAC_MULT5_T");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_AAC_MULT5_T");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_AAC_MULT5_T");
                            }
                        }
                        else
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 384)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF15_AAC_MULT5");
                                }
                                else if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_AAC_MULT5");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_AAC_MULT5");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_AAC_MULT5");
                            }
                        }
                    }
                    else if (audioCodec == AudioCodec.Mp3)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_MPEG1_L3_ISO");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_MPEG1_L3_ISO");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_MPEG1_L3_ISO");
                            }
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_MPEG1_L3_T");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_MPEG1_L3_T");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_MPEG1_L3_T");
                            }
                        }
                        else
                        {
                            if (h264Profile == EncodingProfile.Baseline)
                            {
                                if (width <= 352 && height <= 288 && videoBitrate > 0 && videoBitrate <= 3000)
                                {
                                    valuesProfiles.Add("AVC_TS_BL_CIF30_MPEG1_L3");
                                }
                            }

                            //Main profile and fallbacks
                            if (isHD)
                            {
                                valuesProfiles.Add("AVC_TS_MP_HD_MPEG1_L3");
                            }
                            else
                            {
                                valuesProfiles.Add("AVC_TS_MP_SD_MPEG1_L3");
                            }
                        }
                    }
                }
                else if (videoCodec == VideoCodec.Vc1)
                {
                    if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Ac3)
                    {
                        if (isHD)
                        {
                            valuesProfiles.Add("VC1_TS_AP_L2_AC3_ISO");
                        }
                        else
                        {
                            valuesProfiles.Add("VC1_TS_AP_L1_AC3_ISO");
                        }
                    }
                    else if (audioCodec == AudioCodec.Dts)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("VC1_TS_HD_DTS_ISO");
                        }
                        else
                        {
                            valuesProfiles.Add("VC1_TS_HD_DTS_T");
                        }
                    }
                    else if (audioCodec == AudioCodec.DtsHd)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("VC1_TS_HD_DTSHD_MA_ISO");
                        }
                        else
                        {
                            valuesProfiles.Add("VC1_TS_HD_DTSHD_MA_T");
                        }
                    }
                    else
                    {
                        if (isHD)
                        {
                            valuesProfiles.Add("VC1_TS_AP_L2_AC3_ISO");
                        }
                        else
                        {
                            valuesProfiles.Add("VC1_TS_AP_L1_AC3_ISO");
                        }
                    }
                }
                else if (videoCodec == VideoCodec.H265)
                {
                    valuesProfiles.Add("HEVC_TS");
                }
                else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4)
                {
                    if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Ac3 || audioCodec == AudioCodec.EAc3)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_AC3_ISO");
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_AC3_T");
                        }
                        else
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_AC3");
                        }
                    }
                    else if (audioCodec == AudioCodec.Aac)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_AAC_ISO");
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_AAC_T");
                        }
                        else
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_AAC");
                        }
                    }
                    else if (audioCodec == AudioCodec.Mp3)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG1_L3_ISO");
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG1_L3_T");
                        }
                        else
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG1_L3");
                        }
                    }
                    else if (audioCodec == AudioCodec.Mp2)
                    {
                        if (timestampType == Timestamp.None)
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG2_L2_ISO");
                        }
                        else if (timestampType == Timestamp.Valid)
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG2_L2_T");
                        }
                        else
                        {
                            valuesProfiles.Add("MPEG4_P2_TS_ASP_MPEG2_L2");
                        }
                    }
                }
                else
                {
                    throw new Exception("MPEG2TS video file does not match any supported DLNA profile");
                }
            }
            else if (container == VideoContainer.Flv)
            {
                valuesProfiles.Add("FLV");
            }
            else if (container == VideoContainer.Wtv)
            {
                valuesProfiles.Add("WTV");
            }
            else if (container == VideoContainer.Gp3)
            {
                if (videoCodec == VideoCodec.H264)
                {
                    if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac)
                    {
                        valuesProfiles.Add("AVC_3GPP_BL_QCIF15_AAC");
                    }
                }
                else if (videoCodec == VideoCodec.MsMpeg4 || videoCodec == VideoCodec.Mpeg4)
                {
                    if (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac)
                    {
                        valuesProfiles.Add("MPEG4_P2_3GPP_SP_L0B_AAC");
                    }
                    else if (audioCodec == AudioCodec.Amr)
                    {
                        valuesProfiles.Add("MPEG4_P2_3GPP_SP_L0B_AMR");
                    }
                }
                else if (videoCodec == VideoCodec.H263 && audioCodec == AudioCodec.Amr)
                {
                    valuesProfiles.Add("MPEG4_H263_3GPP_P0_L10_AMR");
                }
                else
                {
                    throw new Exception("3GP video file does not match any supported DLNA profile");
                }
            }
            else if (container == VideoContainer.RealMedia)
            {
                valuesProfiles.Add("REAL_VIDEO");
            }
            else if (container == VideoContainer.Ogg)
            {
                valuesProfiles.Add("OGV");
            }
            else if (container == VideoContainer.Hls)
            {
                if (videoCodec == VideoCodec.H264 && (audioCodec == AudioCodec.Unknown || audioCodec == AudioCodec.Aac))
                {
                    valuesProfiles.Add("HLS");
                }
            }
            //else if (container == VideoContainer.Rtsp)
            //{
            //  valuesProfiles.Add("RTSP");
            //}
            //else if (container == VideoContainer.Rtp)
            //{
            //  valuesProfiles.Add("RTP");
            //}
            else
            {
                throw new Exception("Video does not match any supported DLNA profile");
            }
            return(valuesProfiles);
        }
Exemplo n.º 19
0
        //入力内容に誤りがあればそれを警告してnullを返す。なければ必要なところを埋めたTCPTerminalParamを返す
        private TCPTerminalParam ValidateContent()
        {
            string           msg = null;
            TCPTerminalParam p   = null;
            SSHTerminalParam sp  = null;

            try {
                ConnectionMethod m = ParseMethod(_methodBox.Text);
                if (m == ConnectionMethod.Telnet)
                {
                    p = new TelnetTerminalParam("");
                }
                else
                {
                    p          = sp = new SSHTerminalParam(ConnectionMethod.SSH2, "", "", "");
                    sp.Method  = m;
                    sp.Account = _userNameBox.Text;
                }

                p.Host = _hostBox.Text;
                try {
                    p.Port = ParsePort(_portBox.Text);
                }
                catch (FormatException ex) {
                    msg = ex.Message;
                }

                if (_hostBox.Text.Length == 0)
                {
                    msg = GApp.Strings.GetString("Message.LoginDialog.HostIsEmpty");
                }

                p.LogType = (LogType)EnumDescAttributeT.For(typeof(LogType)).FromDescription(_logTypeBox.Text, LogType.None);

                if (p.LogType != LogType.None)
                {
                    p.LogPath = _logFileBox.Text;
                    if (p.LogPath == GUtil.CreateLogFileName(null))
                    {
                        p.LogPath = GUtil.CreateLogFileName(_hostBox.Text);
                    }
                    LogFileCheckResult r = GCUtil.CheckLogFileName(p.LogPath, this);
                    if (r == LogFileCheckResult.Cancel || r == LogFileCheckResult.Error)
                    {
                        return(null);
                    }
                    p.LogAppend = (r == LogFileCheckResult.Append);
                }

                if (p.IsSSH)
                {
                    Debug.Assert(sp != null);
                    sp.AuthType = (AuthType)_authOptions.SelectedIndex;
                    if (sp.AuthType == AuthType.PublicKey)
                    {
                        if (!File.Exists(_privateKeyFile.Text))
                        {
                            msg = GApp.Strings.GetString("Message.LoginDialog.KeyFileNotExist");
                        }
                        else
                        {
                            sp.IdentityFile = _privateKeyFile.Text;
                        }
                    }
                }
                p.EncodingProfile = EncodingProfile.Get((EncodingType)_encodingBox.SelectedIndex);

                p.LocalEcho    = _localEchoBox.SelectedIndex == 1;
                p.TransmitNL   = (NewLine)EnumDescAttributeT.For(typeof(NewLine)).FromDescription(_newLineBox.Text, NewLine.CR);
                p.TerminalType = (TerminalType)_terminalTypeBox.SelectedIndex;

                if (msg != null)
                {
                    ShowError(msg);
                    return(null);
                }
                else
                {
                    return(p);
                }
            }
            catch (Exception ex) {
                GUtil.Warning(this, ex.Message);
                return(null);
            }
        }