public static string ToString(this Texture2D _img, EncodeTo _encodeTo = EncodeTo.PNG) { // Converting texture data to string byte[] _bytes = (_encodeTo == EncodeTo.JPG) ? _img.EncodeToJPG() : _img.EncodeToPNG(); string _strTexData = System.Convert.ToBase64String(_bytes); return(_strTexData); }
public static string ToString (this Texture2D _img, EncodeTo _encodeTo = EncodeTo.PNG) { // Converting texture data to string byte[] _bytes = (_encodeTo == EncodeTo.JPG) ? _img.EncodeToJPG() : _img.EncodeToPNG(); string _strTexData = System.Convert.ToBase64String(_bytes); return _strTexData; }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileToUpload">The full path to the file to be uploaded.</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <param name="createMultipleRenditions">If the file is a supported transcodeable type, this optional flag can be /// used to control the number of transcoded renditions. If true (default), multiple renditions at varying encoding /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6 rendition to be created /// at the standard encoding rate and dimensions.</param> /// <param name="preserveSourceRendition">If the video file is H.264 encoded and if createMultipleRenditions is true, /// then multiple VP6 renditions are created and in addition the H.264 source is retained as an additional rendition.</param> /// <param name="h264NoProcessing">Use this option to prevent H.264 source files from being transcoded. This parameter cannot /// be used in combination with create_multiple_renditions. It is optional and defaults to false.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, string fileToUpload, EncodeTo encodeTo, bool createMultipleRenditions, bool preserveSourceRendition, bool h264NoProcessing) { using (FileStream fs = File.OpenRead(fileToUpload)) { string fileName = new FileInfo(fileToUpload).Name; return CreateVideo(video, new FileUploadInfo(fs, fileName), encodeTo, createMultipleRenditions, preserveSourceRendition, h264NoProcessing); } }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileToUpload">The full path to the file to be uploaded.</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <param name="createMultipleRenditions">If the file is a supported transcodeable type, this optional flag can be /// used to control the number of transcoded renditions. If true (default), multiple renditions at varying encoding /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6 rendition to be created /// at the standard encoding rate and dimensions.</param> /// <param name="preserveSourceRendition">If the video file is H.264 encoded and if createMultipleRenditions is true, /// then multiple VP6 renditions are created and in addition the H.264 source is retained as an additional rendition.</param> /// <param name="h264NoProcessing">Use this option to prevent H.264 source files from being transcoded. This parameter cannot /// be used in combination with create_multiple_renditions. It is optional and defaults to false.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, string fileToUpload, EncodeTo encodeTo, bool createMultipleRenditions, bool preserveSourceRendition, bool h264NoProcessing) { using (FileStream fs = File.OpenRead(fileToUpload)) { string fileName = new FileInfo(fileToUpload).Name; return(CreateVideo(video, new FileUploadInfo(fs, fileName), encodeTo, createMultipleRenditions, preserveSourceRendition, h264NoProcessing)); } }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileToUpload">The full path to the file to be uploaded.</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <param name="createMultipleRenditions">If the file is a supported transcodeable type, this optional flag can be /// used to control the number of transcoded renditions. If true (default), multiple renditions at varying encoding /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6 rendition to be created /// at the standard encoding rate and dimensions.</param> /// <param name="preserveSourceRendition">If the video file is H.264 encoded and if createMultipleRenditions is true, /// then multiple VP6 renditions are created and in addition the H.264 source is retained as an additional rendition.</param> /// <param name="h264NoProcessing">Use this option to prevent H.264 source files from being transcoded. This parameter cannot /// be used in combination with create_multiple_renditions. It is optional and defaults to false.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, string fileToUpload, EncodeTo encodeTo, bool createMultipleRenditions, bool preserveSourceRendition, bool h264NoProcessing) { string fileName; byte[] fileBytes; GetFileUploadInfo(fileToUpload, out fileName, out fileBytes); return CreateVideo(video, fileName, fileBytes, encodeTo, createMultipleRenditions, preserveSourceRendition, h264NoProcessing); }
public static string Serialise (this Texture2D _img, EncodeTo _encodeTo = EncodeTo.PNG) { // Need to append width and height information IDictionary _dict = new Dictionary<string, object>(); _dict["width"] = _img.width; _dict["height"] = _img.height; _dict["texture"] = _img.ToString(_encodeTo); // Json format string string _strJson = JSONUtility.ToJSON(_dict); return _strJson; }
public static string Serialise(this Texture2D _img, EncodeTo _encodeTo = EncodeTo.PNG) { // Need to append width and height information IDictionary _dict = new Dictionary <string, object>(); _dict["width"] = _img.width; _dict["height"] = _img.height; _dict["texture"] = _img.ToString(_encodeTo); // Json format string string _strJson = JSONUtility.ToJSON(_dict); return(_strJson); }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileName">The full path to the file to be uploaded.</param> /// <param name="fileBytes">The contents of the file</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <param name="createMultipleRenditions">If the file is a supported transcodeable type, this optional flag can be /// used to control the number of transcoded renditions. If true (default), multiple renditions at varying encoding /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6 rendition to be created /// at the standard encoding rate and dimensions.</param> /// <param name="preserveSourceRendition">If the video file is H.264 encoded and if createMultipleRenditions is true, /// then multiple VP6 renditions are created and in addition the H.264 source is retained as an additional rendition.</param> /// <param name="h264NoProcessing">Use this option to prevent H.264 source files from being transcoded. This parameter cannot /// be used in combination with create_multiple_renditions. It is optional and defaults to false.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, string fileName, byte[] fileBytes, EncodeTo encodeTo, bool createMultipleRenditions, bool preserveSourceRendition, bool h264NoProcessing) { BrightcoveParamCollection parms = CreateWriteParamCollection("create_video", methodParams => { methodParams.Add("video", video); if (encodeTo != EncodeTo.None) { methodParams.Add("encode_to", encodeTo.ToString().ToUpper()); } methodParams.Add("create_multiple_renditions", createMultipleRenditions.ToString().ToLower()); methodParams.Add("preserve_source_rendition", preserveSourceRendition.ToString().ToLower()); methodParams.Add("H264NoProcessing ", h264NoProcessing.ToString().ToLower()); }); return RunFilePost<BrightcoveResultContainer<long>>(parms, fileName, fileBytes).Result; }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileToUpload">The full path to the file to be uploaded.</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, string fileToUpload, EncodeTo encodeTo) { return CreateVideo(video, fileToUpload, encodeTo, true); }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileToUpload">The full path to the file to be uploaded.</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <param name="createMultipleRenditions">If the file is a supported transcodeable type, this optional flag can be /// used to control the number of transcoded renditions. If true (default), multiple renditions at varying encoding /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6 rendition to be created /// at the standard encoding rate and dimensions.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, string fileToUpload, EncodeTo encodeTo, bool createMultipleRenditions) { return CreateVideo(video, fileToUpload, encodeTo, createMultipleRenditions, false); }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileUploadInfo">Information for the file to be uploaded.</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <param name="createMultipleRenditions">If the file is a supported transcodeable type, this optional flag can be /// used to control the number of transcoded renditions. If true (default), multiple renditions at varying encoding /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6 rendition to be created /// at the standard encoding rate and dimensions.</param> /// <param name="preserveSourceRendition">If the video file is H.264 encoded and if createMultipleRenditions is true, /// then multiple VP6 renditions are created and in addition the H.264 source is retained as an additional rendition.</param> /// <param name="h264NoProcessing">Use this option to prevent H.264 source files from being transcoded. This parameter cannot /// be used in combination with create_multiple_renditions. It is optional and defaults to false.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, FileUploadInfo fileUploadInfo, EncodeTo encodeTo, bool createMultipleRenditions, bool preserveSourceRendition, bool h264NoProcessing) { BrightcoveParamCollection parms = CreateWriteParamCollection("create_video", methodParams => { methodParams.Add("video", video); if (encodeTo != EncodeTo.None) { methodParams.Add("encode_to", encodeTo.ToString().ToUpper()); } methodParams.Add("create_multiple_renditions", createMultipleRenditions.ToString().ToLower()); methodParams.Add("preserve_source_rendition", preserveSourceRendition.ToString().ToLower()); methodParams.Add("H264NoProcessing ", h264NoProcessing.ToString().ToLower()); }); if (fileUploadInfo != null) { return(RunFilePost <BrightcoveResultContainer <long> >(parms, fileUploadInfo).Result); } return(RunPost <BrightcoveResultContainer <long> >(parms).Result); }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileToUpload">The full path to the file to be uploaded.</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, string fileToUpload, EncodeTo encodeTo) { return(CreateVideo(video, fileToUpload, encodeTo, true)); }
/// <summary> /// Creates a new video by uploading a file. /// </summary> /// <param name="video">The metadata for the video you want to create.</param> /// <param name="fileToUpload">The full path to the file to be uploaded.</param> /// <param name="encodeTo">If the file requires transcoding, use this parameter to specify the target encoding. /// Valid values are MP4 or FLV, representing the H264 and VP6 codecs respectively. Note that transcoding of /// FLV files to another codec is not currently supported. This parameter is optional and defaults to FLV.</param> /// <param name="createMultipleRenditions">If the file is a supported transcodeable type, this optional flag can be /// used to control the number of transcoded renditions. If true (default), multiple renditions at varying encoding /// rates and dimensions are created. Setting this to false will cause a single transcoded VP6 rendition to be created /// at the standard encoding rate and dimensions.</param> /// <returns>The numeric ID of the newly created video.</returns> public long CreateVideo(BrightcoveVideo video, string fileToUpload, EncodeTo encodeTo, bool createMultipleRenditions) { return(CreateVideo(video, fileToUpload, encodeTo, createMultipleRenditions, false)); }
private static async Task decryptAndSaveFile(string activation_bytes, string inputPath, string outputPath, TextBoxBase debugWindow, EncodeTo encodeTo, int encodeQuality = 80) { Extract("ffmpeg.exe"); var fileBase = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(inputPath)); string arguments; // only decrypt. no re-encoding if (encodeTo == EncodeTo.DecryptOnly) { var fileout = fileBase + ".m4b"; arguments = $"-activation_bytes {activation_bytes} -i {inputPath.SurroundWithQuotes()} -vn -c:a copy {fileout.SurroundWithQuotes()}"; } // re-encode. encoding will be determined by file extension else // if (convertRb.Checked) { var fileout = fileBase + "." + encodeTo.ToString().ToLower(); arguments = $"-y -activation_bytes {activation_bytes} -i {inputPath.SurroundWithQuotes()} -ab {encodeQuality} -map_metadata 0 -id3v2_version 3 -vn {fileout.SurroundWithQuotes()}"; } // nothing in stdout. progress/debug info is in stderr var startInfo = new ProcessStartInfo { FileName = Path.Combine(resdir, "ffmpeg.exe"), Arguments = arguments, CreateNoWindow = true, RedirectStandardError = true, UseShellExecute = false, WorkingDirectory = Directory.GetCurrentDirectory() }; using var ffm = new Process { StartInfo = startInfo, EnableRaisingEvents = true }; ffm.ErrorDataReceived += (s, ea) => debugWindow.UIThread(() => debugWindow.AppendText($"DEBUG: {ea.Data}\r\n")); ffm.Start(); ffm.BeginErrorReadLine(); await Task.Run(() => ffm.WaitForExit()); ffm.Close(); }