Esempio n. 1
0
        private async Task DoSubClipAsync()
        {
            var subclipConfig = this.GetSubclippingInternalConfiguration();

            if (subclipConfig.Reencode) // reencode the clip
            {
                ProcessFromTransform form = new ProcessFromTransform(_amsClientV3, _mainform, _selectedAssets, null, subclipConfig.StartTime, subclipConfig.EndTime, true);

                if (form.ShowDialog() == DialogResult.OK)
                {
                    await _mainform.CreateAndSubmitJobsAsync(new List <Transform>() { form.SelectedTransform }, _selectedAssets, form.StartClipTime, form.EndClipTime);
                }

                /*
                 * var processor = Mainform.GetLatestMediaProcessorByName(Constants.AzureMediaEncoderStandard);
                 * EncodingMES form2 = new EncodingMES(_context, new List<IAsset>(), processor.Version, _mainform, subclipConfig, disableOverlay: true)
                 * {
                 *  EncodingLabel = (_selectedAssets.Count > 1) ?
                 *                  string.Format("{0} asset{1} selected. You are going to submit {0} job{1} with 1 task.", _selectedAssets.Count, Program.ReturnS(_selectedAssets.Count), _selectedAssets.Count)
                 *                  :
                 *                  "Asset '" + _selectedAssets.FirstOrDefault().Name + "' will be encoded (1 job with 1 task).",
                 *
                 *  EncodingJobName = "Subclipping with reencoding of " + Constants.NameconvInputasset,
                 *  EncodingOutputAssetName = Constants.NameconvInputasset + "- Subclipped with reencoding",
                 *  EncodingAMEStdPresetJSONFilesUserFolder = Properties.Settings.Default.MESPresetFilesCurrentFolder,
                 *  EncodingAMEStdPresetJSONFilesFolder = Application.StartupPath + Constants.PathMESFiles,
                 *  SelectedAssets = _selectedAssets
                 * };
                 *
                 * if (form2.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                 * {
                 *  string taskname = "Subclipping with reencoding of " + Constants.NameconvInputasset + " with " + Constants.NameconvEncodername;
                 *  _mainform.LaunchJobs_OneJobPerInputAsset_OneTaskPerfConfig(
                 *     processor,
                 *     _selectedAssets,
                 *     form2.EncodingJobName,
                 *     form2.JobOptions.Priority,
                 *     taskname,
                 *     form2.EncodingOutputAssetName,
                 *     new List<string>() { form2.EncodingConfiguration },
                 *     form2.JobOptions.OutputAssetsCreationOptions,
                 *     form2.JobOptions.OutputAssetsFormatOption,
                 *     form2.JobOptions.TasksOptionsSetting,
                 *     form2.JobOptions.StorageSelected);
                 * }
                 */
            }
            else if (subclipConfig.CreateAssetFilter) // create a asset filter
            {
                Asset             selasset = _selectedAssets.FirstOrDefault();
                DynManifestFilter formAF   = new DynManifestFilter(_amsClientV3, null, selasset, subclipConfig);
                if (formAF.ShowDialog() == DialogResult.OK)
                {
                    FilterCreationInfo filterinfo = null;
                    try
                    {
                        filterinfo = formAF.GetFilterInfo;
                        AssetFilter assetFilter = new AssetFilter()
                        {
                            PresentationTimeRange = filterinfo.Presentationtimerange
                        };

                        await _amsClientV3.AMSclient.AssetFilters.CreateOrUpdateAsync(_amsClientV3.credentialsEntry.ResourceGroup, _amsClientV3.credentialsEntry.AccountName, selasset.Name, filterinfo.Name, assetFilter);

                        _mainform.TextBoxLogWriteLine("Asset filter '{0}' created.", filterinfo.Name);
                    }
                    catch (Exception ex)
                    {
                        _mainform.TextBoxLogWriteLine("Error when creating filter '{0}'.", (filterinfo != null && filterinfo.Name != null) ? filterinfo.Name : "unknown name", true);
                        _mainform.TextBoxLogWriteLine(ex);
                    }

                    await _mainform.DoRefreshGridFiltersVAsync(false);
                }
            }
            else // no reencode or asset filter but stream copy
            {
                ClipTime startTime = null;
                ClipTime endTime   = null;

                if (checkBoxTrimming.Checked)
                {
                    startTime = new AbsoluteClipTime()
                    {
                        Time = subclipConfig.StartTime
                    };

                    endTime = new AbsoluteClipTime()
                    {
                        Time = subclipConfig.EndTime
                    };
                }

                var transform = await _mainform.CreateAndGetCopyCodecTransformIfNeededAsync();

                await _mainform.CreateAndSubmitJobsAsync(new List <Transform>() { transform }, _selectedAssets, startTime, endTime, EncodingJobName, EncodingOutputAssetName);

                MessageBox.Show("Subclipping job(s) submitted", "Sublipping", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }

            GenerateUniqueNamesForJobAndOutput();
        }