public static Massive EncodeLine(Massive m) { //Определяем дефолты (с учетом --preset и --tune) x262_arguments defaults = new x262_arguments(m.x262options.preset, m.x262options.tune, m.x262options.profile); //обнуляем старые строки m.vpasses.Clear(); string line = "--mpeg2 "; if (m.encodingmode == Settings.EncodingModes.OnePass || m.encodingmode == Settings.EncodingModes.TwoPass || m.encodingmode == Settings.EncodingModes.ThreePass) line += "--bitrate " + m.outvbitrate; else if (m.encodingmode == Settings.EncodingModes.TwoPassSize || m.encodingmode == Settings.EncodingModes.ThreePassSize) line += "--size " + m.outvbitrate; else if (m.encodingmode == Settings.EncodingModes.Quality || m.encodingmode == Settings.EncodingModes.TwoPassQuality || m.encodingmode == Settings.EncodingModes.ThreePassQuality) line += "--crf " + Calculate.ConvertDoubleToPointString((double)m.outvbitrate, 1); else if (m.encodingmode == Settings.EncodingModes.Quantizer) line += "--qp " + m.outvbitrate; //Пресет line += " --preset " + m.x262options.preset.ToString().ToLower(); if (m.x262options.tune != defaults.tune && !m.x262options.extra_cli.Contains("--tune ")) line += " --tune " + m.x262options.tune.ToString().ToLower(); if (m.x262options.profile != defaults.profile && !m.x262options.extra_cli.Contains("--profile ")) line += " --profile " + m.x262options.profile.ToString().ToLower(); if (m.x262options.level != defaults.level && !m.x262options.extra_cli.Contains("--level ")) line += " --level " + m.x262options.level; if (m.x262options.aqmode != defaults.aqmode && !m.x262options.extra_cli.Contains("--aq-mode ")) line += " --aq-mode " + m.x262options.aqmode; if (m.x262options.aqstrength != defaults.aqstrength && m.x262options.aqmode != 0 && !m.x262options.extra_cli.Contains("--aq-strength ")) line += " --aq-strength " + m.x262options.aqstrength; if (m.x262options.merange != defaults.merange && !m.x262options.extra_cli.Contains("--merange ")) line += " --merange " + m.x262options.merange; if (m.x262options.no_chroma && !defaults.no_chroma && !m.x262options.extra_cli.Contains("--no-chroma-me")) line += " --no-chroma-me"; if (m.x262options.bframes != defaults.bframes && !m.x262options.extra_cli.Contains("--bframes ")) line += " --bframes " + m.x262options.bframes; if (m.x262options.dc != defaults.dc && !m.x262options.extra_cli.Contains("--dc ")) line += " --dc " + m.x262options.dc; if (m.x262options.b_adapt != defaults.b_adapt && !m.x262options.extra_cli.Contains("--b-adapt ")) line += " --b-adapt " + m.x262options.b_adapt; if (m.x262options.altscan && !defaults.altscan && !m.x262options.extra_cli.Contains("--altscan")) line += " --altscan"; if (m.x262options.no_fastpskip && !defaults.no_fastpskip && !m.x262options.extra_cli.Contains("--no-fast-pskip")) line += " --no-fast-pskip"; if (m.x262options.linear_q && !defaults.linear_q && !m.x262options.extra_cli.Contains("--linear-quant")) line += " --linear-quant"; if (m.x262options.custommatrix != defaults.custommatrix && !m.x262options.extra_cli.Contains("--cqm ")) line += " --cqm " + m.x262options.custommatrix; if (m.x262options.min_quant != defaults.min_quant && !m.x262options.extra_cli.Contains("--qpmin ")) line += " --qpmin " + m.x262options.min_quant; if (m.x262options.max_quant != defaults.max_quant && !m.x262options.extra_cli.Contains("--qpmax ")) line += " --qpmax " + m.x262options.max_quant; if (m.x262options.step_quant != defaults.step_quant && !m.x262options.extra_cli.Contains("--qpstep ")) line += " --qpstep " + m.x262options.step_quant; if (m.x262options.no_psy && !defaults.no_psy && !m.x262options.extra_cli.Contains("--no-psy")) line += " --no-psy"; if (!m.x262options.no_psy && m.x262options.psyrdo != defaults.psyrdo && !m.x262options.extra_cli.Contains("--psy-rd ")) line += " --psy-rd " + Calculate.ConvertDoubleToPointString((double)m.x262options.psyrdo, 2) + ":0.00"; if (m.x262options.threads != defaults.threads && !m.x262options.extra_cli.Contains("--threads ")) { if (m.x262options.threads == "1" && m.x262options.thread_input) line += " --threads 1 --thread-input"; else line += " --threads " + m.x262options.threads; } if (m.x262options.qcomp != defaults.qcomp && !m.x262options.extra_cli.Contains("--qcomp ")) line += " --qcomp " + Calculate.ConvertDoubleToPointString((double)m.x262options.qcomp, 2); if (m.x262options.vbv_maxrate != defaults.vbv_maxrate && !m.x262options.extra_cli.Contains("--vbv-maxrate ")) line += " --vbv-maxrate " + m.x262options.vbv_maxrate; if (m.x262options.vbv_bufsize != defaults.vbv_bufsize && !m.x262options.extra_cli.Contains("--vbv-bufsize ")) line += " --vbv-bufsize " + m.x262options.vbv_bufsize; if (m.x262options.vbv_init != defaults.vbv_init && !m.x262options.extra_cli.Contains("--vbv-init ")) line += " --vbv-init " + Calculate.ConvertDoubleToPointString((double)m.x262options.vbv_init, 2); if (m.x262options.qp_offset != defaults.qp_offset && !m.x262options.extra_cli.Contains("--chroma-qp-offset ")) line += " --chroma-qp-offset " + m.x262options.qp_offset; if (m.x262options.subme != defaults.subme && !m.x262options.extra_cli.Contains("--subme ")) line += " --subme " + m.x262options.subme; if (m.x262options.me != defaults.me && !m.x262options.extra_cli.Contains("--me ")) line += " --me " + m.x262options.me; if (m.x262options.slow_frstpass && !defaults.slow_frstpass && !m.x262options.extra_cli.Contains("--slow-firstpass")) line += " --slow-firstpass"; if (m.x262options.no_mbtree && !defaults.no_mbtree && !m.x262options.extra_cli.Contains("--no-mbtree")) line += " --no-mbtree"; if (!m.x262options.no_mbtree && m.x262options.lookahead != defaults.lookahead && !m.x262options.extra_cli.Contains("--rc-lookahead ")) line += " --rc-lookahead " + m.x262options.lookahead; if (m.x262options.lookahead_threads != defaults.lookahead_threads && !m.x262options.extra_cli.Contains("--lookahead-threads ")) line += " --lookahead-threads " + m.x262options.lookahead_threads; if (m.x262options.gop_min > 0 && m.x262options.gop_min != defaults.gop_min && !m.x262options.extra_cli.Contains("--min-keyint ")) line += " --min-keyint " + m.x262options.gop_min; if (m.x262options.gop_max != defaults.gop_max && !m.x262options.extra_cli.Contains("--keyint ")) line += " --keyint " + (m.x262options.gop_max > 0 ? m.x262options.gop_max.ToString() : "infinite"); if (m.x262options.ratio_ip != defaults.ratio_ip && !m.x262options.extra_cli.Contains("--ipratio ")) line += " --ipratio " + Calculate.ConvertDoubleToPointString((double)m.x262options.ratio_ip, 2); if (m.x262options.ratio_pb != defaults.ratio_pb && !m.x262options.extra_cli.Contains("--pbratio ")) line += " --pbratio " + Calculate.ConvertDoubleToPointString((double)m.x262options.ratio_pb, 2); if (m.x262options.open_gop && !defaults.open_gop && !m.x262options.extra_cli.Contains("--open-gop")) line += " --open-gop"; if (m.x262options.slices != defaults.slices && !m.x262options.extra_cli.Contains("--slices ")) line += " --slices " + m.x262options.slices; if (m.x262options.fake_int && !defaults.fake_int && !m.x262options.extra_cli.Contains("--fake-interlaced")) line += " --fake-interlaced"; if (m.x262options.range_in != defaults.range_in && !m.x262options.extra_cli.Contains("--input-range ")) line += " --input-range " + m.x262options.range_in; if (m.x262options.range_out != defaults.range_out && !m.x262options.extra_cli.Contains("--range ")) line += " --range " + m.x262options.range_out; if (m.x262options.colorprim != defaults.colorprim && !m.x262options.extra_cli.Contains("--colorprim ")) line += " --colorprim " + ((m.x262options.colorprim == "Undefined") ? "undef" : m.x262options.colorprim); if (m.x262options.transfer != defaults.transfer && !m.x262options.extra_cli.Contains("--transfer ")) line += " --transfer " + ((m.x262options.transfer == "Undefined") ? "undef" : m.x262options.transfer); if (m.x262options.colormatrix != defaults.colormatrix && !m.x262options.extra_cli.Contains("--colormatrix ")) line += " --colormatrix " + ((m.x262options.colormatrix == "Undefined") ? "undef" : m.x262options.colormatrix); if (m.x262options.colorspace != defaults.colorspace && !m.x262options.extra_cli.Contains("--output-csp ")) line += " --output-csp " + m.x262options.colorspace.ToLower(); if (m.x262options.non_deterministic && !defaults.non_deterministic && !m.x262options.extra_cli.Contains("--non-deterministic")) line += " --non-deterministic"; if (m.x262options.bluray && !defaults.bluray && !m.x262options.extra_cli.Contains("--bluray-compat")) line += " --bluray-compat"; line += " --extra:"; if (m.x262options.extra_cli != defaults.extra_cli) line += " " + m.x262options.extra_cli; //удаляем пустоту в начале line = line.TrimStart(new char[] { ' ' }); //забиваем данные в массив if (m.encodingmode == Settings.EncodingModes.OnePass || m.encodingmode == Settings.EncodingModes.Quality || m.encodingmode == Settings.EncodingModes.Quantizer) m.vpasses.Add(line); else if (m.encodingmode == Settings.EncodingModes.TwoPassQuality) { m.vpasses.Add("--pass 1 " + line); m.vpasses.Add("--pass 2 " + line); } else if (m.encodingmode == Settings.EncodingModes.ThreePassQuality) { m.vpasses.Add("--pass 1 " + line); m.vpasses.Add("--pass 3 " + line); m.vpasses.Add("--pass 2 " + line); } else if (m.encodingmode == Settings.EncodingModes.TwoPass || m.encodingmode == Settings.EncodingModes.TwoPassSize) { m.vpasses.Add("--pass 1 " + line); m.vpasses.Add("--pass 2 " + line); } else if (m.encodingmode == Settings.EncodingModes.ThreePass || m.encodingmode == Settings.EncodingModes.ThreePassSize) { m.vpasses.Add("--pass 1 " + line); m.vpasses.Add("--pass 3 " + line); m.vpasses.Add("--pass 2 " + line); } return m; }
private void SetToolTips() { image_warning.ToolTip = Languages.Translate("This encoder is highly experimental!") + "\r\n" + Languages.Translate("Use it at your own risk!"); //Определяем дефолты (с учетом --preset и --tune) //x262_arguments def = new x262_arguments(m.x262options.preset, m.x262options.tune, m.x262options.profile); //Определяем дефолты без учета --preset и --tune, т.к. это именно дефолты самого энкодера x262_arguments def = new x262_arguments(Presets.Medium, Tunes.None, m.x262options.profile); CultureInfo cult_info = new CultureInfo("en-US"); if (m.encodingmode == Settings.EncodingModes.OnePass || m.encodingmode == Settings.EncodingModes.TwoPass || m.encodingmode == Settings.EncodingModes.ThreePass) num_bitrate.ToolTip = "Set bitrate (Default: Auto)"; else if (m.encodingmode == Settings.EncodingModes.TwoPassSize || m.encodingmode == Settings.EncodingModes.ThreePassSize) num_bitrate.ToolTip = "Set file size (Default: InFileSize)"; else if (m.encodingmode == Settings.EncodingModes.Quantizer) num_bitrate.ToolTip = "Set target quantizer (1 - 69). Lower - better quality but bigger filesize.\r\n(Default: 23)"; else num_bitrate.ToolTip = "Set target quality (0 - 51). Lower - better quality but bigger filesize.\r\n(Default: 23)"; combo_mode.ToolTip = "Encoding mode"; combo_mpg_profile.ToolTip = "Specify profile (--profile, default: " + def.profile.ToString() + ")"; combo_level.ToolTip = "Specify level (--level, default: Unrestricted)"; combo_tune.ToolTip = "Tune the settings for a particular type of source or situation (--tune, default: " + def.tune.ToString() + ")"; combo_subme.ToolTip = "Subpixel motion estimation and mode decision (--subme, default: " + def.subme + ")\r\n" + "1 - fast\r\n7 - medium\r\n9 - slow"; combo_me.ToolTip = "Integer pixel motion estimation method (--me, default: --me " + def.me + ")\r\n" + "Diamond Search, fast (--me dia)\r\nHexagonal Search (--me hex)\r\nUneven Multi-Hexagon Search (--me umh)\r\n" + "Exhaustive Search (--me esa)\r\nSATD Exhaustive Search, slow (--me tesa)"; combo_merange.ToolTip = "Maximum motion vector search range (--merange, default: " + def.merange + ")"; check_chroma.ToolTip = "Ignore chroma in motion estimation (--no-chroma-me, default: unchecked)"; combo_bframes.ToolTip = "Number of B-frames between I and P (--bframes, default: " + def.bframes + ")"; combo_dc_precision.ToolTip = "Specify intra DC precision to use (--dc, default: " + def.dc + ")"; check_altscan.ToolTip = "Use alternate MPEG-2 VLC scan order, not zigzag (--altscan, default: unchecked)"; check_fast_pskip.ToolTip = "Disables early SKIP detection on P-frames (--no-fast-pskip, default: unchecked)"; check_linear_q.ToolTip = "Use MPEG-2 linear quantization table (--linear-quant, default: unchecked)"; num_min_quant.ToolTip = "Set min QP (--qpmin, default: " + def.min_quant + ")"; num_max_quant.ToolTip = "Set max QP (--qpmax, default: " + def.max_quant + ")"; num_step_quant.ToolTip = "Set max QP step (--qpstep, default: " + def.step_quant + ")"; if (m.encodingmode == Settings.EncodingModes.Quality || m.encodingmode == Settings.EncodingModes.Quantizer || m.encodingmode == Settings.EncodingModes.TwoPassQuality || m.encodingmode == Settings.EncodingModes.ThreePassQuality) { slider_preset.ToolTip = "Set encoding preset (--preset, default: Medium):" + Environment.NewLine + "Ultrafast - fastest encoding, but biggest output file size" + Environment.NewLine + "Medium - default, good speed and medium file size" + Environment.NewLine + "Veryslow - high quality encoding, small file size" + Environment.NewLine + "Placebo - super high quality encoding, smallest file size"; } else { slider_preset.ToolTip = "Set encoding preset (--preset, default: Medium):" + Environment.NewLine + "Ultrafast - fastest encoding, bad quality" + Environment.NewLine + "Medium - default, optimal speed-quality solution" + Environment.NewLine + "Veryslow - high quality encoding" + Environment.NewLine + "Placebo - super high quality encoding"; } combo_badapt_mode.ToolTip = "Adaptive B-frame decision method (--b-adapt, default: " + (def.b_adapt == 0 ? "Disabled)" : def.b_adapt == 1 ? "Fast)" : "Optimal"); combo_adapt_quant_mode.ToolTip = "AQ mode (--aq-mode, default: " + (def.aqmode == 0 ? "None" : def.aqmode == 1 ? "VAQ" : "A-VAQ") + ")\r\n" + "None - disabled, 0\r\nVAQ - variance AQ (complexity mask), 1\r\nA-VAQ - auto-variance AQ (experimental), 2"; combo_adapt_quant.ToolTip = "AQ Strength (--ag-strength, default: " + def.aqstrength + ")\r\n" + "Reduces blocking and blurring in flat and textured areas: 0.5 - weak AQ, 1.5 - strong AQ"; num_psyrdo.ToolTip = "Strength of psychovisual RD optimization, requires Subpixel ME >= 6 (--psy-rd, default: " + def.psyrdo.ToString(cult_info) + ")"; num_vbv_max.ToolTip = "Max local bitrate, kbit/s (--vbv-maxrate, default: " + def.vbv_maxrate + ")"; num_vbv_buf.ToolTip = "Set size of the VBV buffer, kbit (--vbv-bufsize, default: " + def.vbv_bufsize + ")"; num_vbv_init.ToolTip = "Initial VBV buffer occupancy (--vbv-init, default: " + def.vbv_init.ToString(cult_info) + ")"; num_qcomp.ToolTip = "QP curve compression (--qcomp, default: " + def.qcomp.ToString(cult_info) + ")\r\n0.00 => CBR, 1.00 => CQP"; num_chroma_qp.ToolTip = "QP difference between chroma and luma (--chroma-qp-offset, default: " + def.qp_offset + ")"; combo_threads_count.ToolTip = "Set number of threads for encoding (--threads, default: Auto)\r\n" + "Auto = 1.5 * logical_processors\r\n1+1 = --threads 1 --thread-input"; check_slow_first.ToolTip = "Enable slow 1-st pass for multipassing encoding (off by default)" + Environment.NewLine + "(--slow-firstpass if checked)"; check_nombtree.ToolTip = "Disable mb-tree ratecontrol (off by default, --no-mbtree if checked)"; num_lookahead.ToolTip = "Number of frames for mb-tree ratecontrol and VBV-lookahead (--rc-lookahead, default: " + def.lookahead + ")"; combo_lookahead_threads.ToolTip = "Force a specific number of lookahead threads (--lookahead-threads, default: Auto)\r\nAuto = 1/6 of regular threads."; check_enable_psy.ToolTip = "If unchecked disable all visual optimizations that worsen both PSNR and SSIM" + Environment.NewLine + "(--no-psy if not checked)"; num_min_gop.ToolTip = "Minimum GOP size (--min-keyint, default: " + def.gop_min + ")\r\n0 - Auto"; num_max_gop.ToolTip = "Maximum GOP size (--keyint, default: " + def.gop_max + ")\r\n0 - \"infinite\""; num_ratio_ip.ToolTip = "QP factor between I and P (--ipratio, default: " + def.ratio_ip.ToString(cult_info) + ")"; num_ratio_pb.ToolTip = "QP factor between P and B (--pbratio, default: " + def.ratio_pb.ToString(cult_info) + ")"; combo_open_gop.ToolTip = "Use recovery points to close GOPs, requires B-frames (--open-gop, default: " + (!def.open_gop ? "No" : "Yes") + ")"; num_slices.ToolTip = "Number of slices per frame (--slices, default: " + def.slices + ")"; check_fake_int.ToolTip = "Flag stream as interlaced but encode progressive (--fake-interlaced, default: unchecked)"; combo_range_in.ToolTip = "Forces the range of the input (--input-range, default: Auto)\r\nIf input and output ranges aren't the same, x262 will perform range conversion!"; combo_range_out.ToolTip = "Sets the range of the output (--range, default: Auto)\r\nIf input and output ranges aren't the same, x262 will perform range conversion!"; combo_colorprim.ToolTip = "Specify color primaries (--colorprim, default: " + def.colorprim + ")"; combo_transfer.ToolTip = "Specify transfer characteristics (--transfer, default: " + def.transfer + ")"; combo_colormatrix.ToolTip = "Specify color matrix setting (--colormatrix, default: " + def.colormatrix + ")"; combo_colorspace.ToolTip = "Specify output colorspace (--output-csp, default: " + def.colorspace + ")\r\nDo not change it if you don't know what you`re doing!"; check_non_deterministic.ToolTip = "Slightly improve quality when encoding with --threads > 1, at the cost of non-deterministic output encodes\r\n(--non-deterministic, default: unchecked)"; check_bluray.ToolTip = "Enable compatibility hacks for Blu-ray support (--bluray-compat, default: unchecked)"; }
private void slider_preset_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e) { if (slider_preset.IsFocused || slider_preset.IsMouseOver) { //Создаем новые параметры с учетом --preset, и берем от них только те, от которых зависит пресет m.x262options.preset = (Presets)Enum.ToObject(typeof(Presets), (int)slider_preset.Value); x262_arguments defaults = new x262_arguments(m.x262options.preset, m.x262options.tune, m.x262options.profile); m.x262options.aqmode = defaults.aqmode; m.x262options.b_adapt = defaults.b_adapt; m.x262options.bframes = defaults.bframes; m.x262options.lookahead = defaults.lookahead; m.x262options.me = defaults.me; m.x262options.merange = defaults.merange; m.x262options.no_fastpskip = defaults.no_fastpskip; m.x262options.no_mbtree = defaults.no_mbtree; m.x262options.psyrdo = defaults.psyrdo;// m.x262options.slow_frstpass = defaults.slow_frstpass; m.x262options.subme = defaults.subme; root_window.UpdateOutSize(); root_window.UpdateManualProfile(); m = DecodeLine(m); //Пересчитываем параметры из CLI в m.x262options (это нужно для "--extra:") LoadFromProfile(); //Выставляем значения из m.x262options в элементы управления } }
private void combo_tune_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (combo_tune.IsDropDownOpen || combo_tune.IsSelectionBoxHighlighted) { //Создаем новые параметры с учетом --tune, и берем от них только те, от которых зависит tune m.x262options.tune = (Tunes)Enum.ToObject(typeof(Tunes), combo_tune.SelectedIndex); x262_arguments defaults = new x262_arguments(m.x262options.preset, m.x262options.tune, m.x262options.profile); m.x262options.aqmode = defaults.aqmode; m.x262options.aqstrength = defaults.aqstrength; m.x262options.bframes = defaults.bframes; m.x262options.no_psy = defaults.no_psy; m.x262options.psyrdo = defaults.psyrdo; m.x262options.qcomp = defaults.qcomp; m.x262options.ratio_ip = defaults.ratio_ip; m.x262options.ratio_pb = defaults.ratio_pb; root_window.UpdateOutSize(); root_window.UpdateManualProfile(); m = DecodeLine(m); //Пересчитываем параметры из CLI в m.x262options (это нужно для "--extra:") LoadFromProfile(); //Выставляем значения из m.x262options в элементы управления } }