How Long Does It Take to Transcode Video?.Transcoding Example: Live Streaming for Closed Circuit Systems.Transcoding Example: Playback Device Compatibility.If (asyncInfo.Status = AsyncStatus.Completed)Įlse if (asyncInfo.Status = AsyncStatus. Void TranscodeComplete(IAsyncActionWithProgress asyncInfo, AsyncStatus status) void TranscodeProgress(IAsyncActionWithProgress asyncInfo, double percent) These events are part of the async programming framework for Universal Windows Platform (UWP) apps and are not specific to the transcoding API. You can register events to respond when the progress of the asynchronous TranscodeAsync changes. ("Codec not found.") Ĭase TranscodeFailureReason.InvalidProfile: New AsyncActionWithProgressCompletedHandler(TranscodeComplete) Ĭase TranscodeFailureReason.CodecNotFound: New AsyncActionProgressHandler(TranscodeProgress) Var transcodeOp = prepareOp.TranscodeAsync() Transcoder.PrepareFileTranscodeAsync(source, destination, profile) MediaTranscoder transcoder = new MediaTranscoder() Then call the TranscodeAsync method on the PrepareTranscodeResult object that was returned from the async transcode operation. Pass in the source file, the destination file, and the encoding profile. To transcode the file, create a new MediaTranscoder object and call the MediaTranscoder.PrepareFileTranscodeAsync method. Or, if you know the exact encoding settings that you want, you can create a new MediaEncodingProfile object and fill in the profile details. ("720p" stands for 720 progressive scan lines per frame.) The other methods for creating predefined profiles all follow this pattern.Īlternatively, you can create a profile that matches an existing media file by using the MediaEncodingProfile.CreateFromFileAsync method. In this case, VideoEncodingQuality.hd720p means 1280 x 720 pixels at 30 frames per second. The parameter for this method gives the target resolution for the video. The static CreateMp4 method creates an MP4 encoding profile. MediaEncodingProfile.CreateMp4(VideoEncodingQuality.HD720p) The following code creates a profile for MP4 video. High Efficiency Video Coding (HEVC) video, also known as H.265 video Methods for creating audio / video encoding profiles Method The MediaEncodingProfile class provides static methods for creating predefined encoding profiles: Methods for creating Audio-only encoding profiles Method This is where you have the greatest number of options when you transcode a file. The encoding profile contains the settings that determine how the destination file will be encoded. StorageFile destination = await savePicker.PickSaveFileAsync() SavePicker.SuggestedFileName = "New Video" SavePicker.DefaultFileExtension = ".mp4" StorageFile source = await openPicker.PickSingleFileAsync() OpenPicker.SuggestedStartLocation = .VideosLibrary This example uses a FileOpenPicker and a FileSavePicker to allow the user to pick a source and a destination file. The way that your app determines the source and destination files for transcoding depends on your implementation. In addition to the namespaces referenced by the default project template, you will need to reference these namespaces in order to transcode media files using the code in this article. In that case, the re-encoded file might use the same codec as the original file, but it would have a different encoding profile. Or, you might convert a high-definition video file to a lower resolution. For example, you might convert a Windows Media file to MP4 so that it can be played on a portable device that supports MP4 format. This is usually done by decoding and then re-encoding the file. Transcoding is the conversion of a digital media file, such as a video or audio file, from one format to another. You can use the APIs to transcode video files from one format to another.
0 Comments
Leave a Reply. |