public void TestPostConvertVideo()
        {
            var            localName  = "sample.avi";
            var            remoteName = "toconvert.avi";
            var            fullName   = Path.Combine(this.dataFolder, remoteName);
            var            resultPath = Path.Combine(this.dataFolder, "converted.mp4");
            ConvertOptions options    = new ConvertOptions();

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName));

            var request = new PostConvertVideoRequest(remoteName, "mp4", resultPath, options, this.dataFolder);
            var actual  = this.VideoApi.PostConvertVideo(request);

            Assert.AreEqual(200, System.Convert.ToInt32(actual.Code.ToString()));
        }
        public void TestAspectRatioVideo()
        {
            var localName = "sample.avi";

            var            fullName   = Path.Combine(this.dataFolder, localName);
            var            resultPath = Path.Combine(this.dataFolder, "aspectratio.avi");
            ConvertOptions options    = new ConvertOptions();

            options.AspectRatio = ConvertOptions.AspectRatioEnum.R32;

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName));

            var request = new PostConvertVideoRequest(localName, "avi", resultPath, options, this.dataFolder);
            var actual  = this.VideoApi.PostConvertVideo(request);

            Assert.AreEqual(200, System.Convert.ToInt32(actual.Code.ToString()));
        }
        public void TestPostAddWatermarkText()
        {
            var            localName  = "sample.avi";
            var            fullName   = Path.Combine(this.dataFolder, localName);
            var            resultPath = Path.Combine(this.dataFolder, "convertedWatermarkText.mp4");
            ConvertOptions options    = new ConvertOptions();

            options.WatermarkText          = new WatermarkTextOptions();
            options.WatermarkText.Text     = "Test watermark text";
            options.WatermarkText.FontFile = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Fonts), "Arial.ttf");

            this.StorageApi.PutCreate(fullName, null, null, File.ReadAllBytes(BaseTestContext.GetDataDir() + localName));

            var request = new PostConvertVideoRequest(localName, "mp4", resultPath, options, this.dataFolder);
            var actual  = this.VideoApi.PostConvertVideo(request);

            Assert.AreEqual(200, System.Convert.ToInt32(actual.Code.ToString()));
        }
Exemple #4
0
        /// <summary>
        /// Convert document from request content to format specified.
        /// </summary>
        /// <param name="request">Request. <see cref="PostConvertVideoRequest" /></param>
        /// <returns><see cref="SaveResponse"/></returns>
        public SaveResponse PostConvertVideo(PostConvertVideoRequest request)
        {
            // verify the required parameter 'name' is set
            if (request.Name == null)
            {
                throw new ApiException(400, "Missing required parameter 'name' when calling PostConvertVideo");
            }

            // verify the required parameter 'format' is set
            if (request.Format == null)
            {
                throw new ApiException(400, "Missing required parameter 'format' when calling PostConvertVideo");
            }

            // verify the required parameter 'resultPath' is set
            if (request.ResultPath == null)
            {
                throw new ApiException(400, "Missing required parameter 'resultPath' when calling PostConvertVideo");
            }

            // verify the required parameter 'options' is set
            if (request.Options == null)
            {
                throw new ApiException(400, "Missing required parameter 'options' when calling PostConvertVideo");
            }

            // create path and map variables
            var resourcePath = "/video/{name}/convert?appSid={appSid}&amp;format=[format]&amp;resultPath=[resultPath]&amp;folder=[folder]&amp;storage=[storage]&amp;destFileName=[destFileName]";

            resourcePath = Regex
                           .Replace(resourcePath, "\\*", string.Empty)
                           .Replace("&amp;", "&")
                           .Replace("/?", "?");
            resourcePath = this.AddPathParameter(resourcePath, "name", request.Name);
            resourcePath = this.AddQueryParameter(resourcePath, "format", request.Format);
            resourcePath = this.AddQueryParameter(resourcePath, "resultPath", request.ResultPath);
            resourcePath = this.AddQueryParameter(resourcePath, "folder", request.Folder);
            resourcePath = this.AddQueryParameter(resourcePath, "storage", request.Storage);
            resourcePath = this.AddQueryParameter(resourcePath, "destFileName", request.DestFileName);
            var postBody = request.Options; // http body (model) parameter

            try
            {
                var response = this.apiInvoker.InvokeApi(
                    resourcePath,
                    "POST",
                    postBody,
                    null,
                    null);
                if (response != null)
                {
                    return((SaveResponse)SerializationHelper.Deserialize(response, typeof(SaveResponse)));
                }

                return(null);
            }
            catch (ApiException ex)
            {
                if (ex.ErrorCode == 404)
                {
                    return(null);
                }

                throw;
            }
        }