Esempio n. 1
0
        public IVideoFormat[] GetAvailableVideoFormats(ICamera target)
        {
            if (target is not WindowsCamera camera)
            {
                throw new ArgumentException("Provided ICamera object is not for this platform.",
                                            target.ToString());
            }

            var camera_list = WindowsCapture.FindDevices();

            if (camera.CameraIndex >= 0 && camera.CameraIndex < camera_list.Length)
            {
                var videoFormats = WindowsCapture.GetVideoFormat(camera.CameraIndex);

                var genericVF = new IVideoFormat[videoFormats.Length];

                for (var i = 0; i < genericVF.Length; i++)
                {
                    var vf = videoFormats[i];
                    genericVF[i] = new WindowsVideoFormats(vf.SubType,
                                                           new PixelSize((int)vf.Size.Width, (int)vf.Size.Height), vf);
                }

                return(genericVF);
            }

            throw new ArgumentException("Specified camera is not available.", target.CameraName);
        }
Esempio n. 2
0
 public async Task <bool> TryStartAsync(
     ICamera targetCamera,
     IVideoFormat targetVideoFormat,
     Action <ICamera, IVideoFormat, ILockedFramebuffer> frameCallback)
 {
     return(false);
 }
Esempio n. 3
0
        private void SetTranscodeParameters()
        {
            IVideoFormat videoFormat = Preview.VideoFormat;
            IAudioFormat audioFormat = Preview.AudioFormat;

            mediaComposer.addSourceFile(new File(Preview.File));

            IMediaFile mediaFile = mediaComposer.getSourceFiles()[0];

            var sourceFiles = mediaComposer.getSourceFiles();

            if (sourceFiles.Count != 0)
            {
                double mul = Preview.Duration / 100;

                long trimStartTime = (long)(Preview.SegmentStart * mul);
                long trimStopTime  = (long)(Preview.SegmentEnd * mul);

                var sourceFile = sourceFiles[0];

                sourceFile.addSegment(Segment.fromMicroSeconds(trimStartTime, trimStopTime));
            }

            ComboBoxItem framerateItem = (ComboBoxItem)FramerateSelect.SelectedItem;
            String       videoProfile  = ((ComboBoxItem)ProfileSelect.SelectedItem).Content.ToString();

            var match = Regex.Match(videoProfile, @"\(([0-9]+)x([0-9]+)\)");

            uint width     = uint.Parse(match.Groups[1].Value);
            uint height    = uint.Parse(match.Groups[2].Value);
            uint framerate = uint.Parse(framerateItem.Content.ToString());
            uint bitrate   = (uint)(BitrateSelect.Value * 1000);

            if (videoFormat != null)
            {
                var vFormat = new WinRtVideoFormat(videoMimeType, width, height)
                {
                    bitrate = bitrate
                };

                vFormat.frameRate.Numerator   = framerate;
                vFormat.frameRate.Denominator = 1;

                mediaComposer.setTargetVideoFormat(vFormat);
            }

            if (audioFormat != null)
            {
                var aFormat = new WinRtAudioFormat(audioMimeType)
                {
                    bitrate       = audioFormat.bitrate,
                    bitsPerSample = audioFormat.bitsPerSample,
                    channelCount  = audioFormat.channelCount,
                    sampleRate    = audioFormat.sampleRate
                };

                mediaComposer.setTargetAudioFormat(aFormat);
            }
        }
Esempio n. 4
0
        private void SetTranscodeParameters()
        {
            IVideoFormat videoFormat = Preview.VideoFormat;
            IAudioFormat audioFormat = Preview.AudioFormat;

            mediaComposer.addSourceFile(new File(Preview.File));

            ComboBoxItem framerateItem = (ComboBoxItem)FramerateSelect.SelectedItem;
            String       videoProfile  = ((ComboBoxItem)ProfileSelect.SelectedItem).Content.ToString();

            var match = Regex.Match(videoProfile, @"\(([0-9]+)x([0-9]+)\)");

            uint width     = uint.Parse(match.Groups[1].Value);
            uint height    = uint.Parse(match.Groups[2].Value);
            uint framerate = uint.Parse(framerateItem.Content.ToString());
            uint bitrate   = (uint)(BitrateSelect.Value * 1000);

            if (videoFormat != null)
            {
                var vFormat = new WinRtVideoFormat(videoMimeType, width, height)
                {
                    bitrate = bitrate
                };

                vFormat.frameRate.Numerator   = framerate;
                vFormat.frameRate.Denominator = 1;

                mediaComposer.setTargetVideoFormat(vFormat);
            }

            if (audioFormat != null)
            {
                var aFormat = new WinRtAudioFormat(audioMimeType)
                {
                    bitrate       = audioFormat.bitrate,
                    bitsPerSample = audioFormat.bitsPerSample,
                    channelCount  = audioFormat.channelCount,
                    sampleRate    = audioFormat.sampleRate
                };

                mediaComposer.setTargetAudioFormat(aFormat);
            }

            for (int i = 0; i < EffectsMenu.Items.Count; ++i)
            {
                ToggleMenuFlyoutItem item = (ToggleMenuFlyoutItem)EffectsMenu.Items[i];

                if (item.IsChecked)
                {
                    mediaComposer.addVideoEffect(SamplesUtils.GetVideoEffectByName(item.Text));
                }
            }
        }
Esempio n. 5
0
        protected void SetTranscodeParameters()
        {
            IVideoFormat videoFormat = Preview.VideoFormat;
            IAudioFormat audioFormat = Preview.AudioFormat;

            mediaComposer.addSourceFile(new File(Preview.File));
            mediaComposer.addSourceFile(new File(Preview2.File));

            ComboBoxItem framerateItem = (ComboBoxItem)FramerateSelect.SelectedItem;
            String       videoProfile  = ((ComboBoxItem)ProfileSelect.SelectedItem).Content.ToString();

            var match = Regex.Match(videoProfile, @"\(([0-9]+)x([0-9]+)\)");

            uint width     = uint.Parse(match.Groups[1].Value);
            uint height    = uint.Parse(match.Groups[2].Value);
            uint framerate = uint.Parse(framerateItem.Content.ToString());
            uint bitrate   = (uint)(BitrateSelect.Value * 1000);

            if (videoFormat != null)
            {
                var vFormat = new WinRtVideoFormat(videoMimeType, width, height)
                {
                    bitrate = bitrate
                };

                vFormat.frameRate.Numerator   = framerate;
                vFormat.frameRate.Denominator = 1;

                mediaComposer.setTargetVideoFormat(vFormat);
            }

            if (audioFormat != null)
            {
                var aFormat = new WinRtAudioFormat(audioMimeType)
                {
                    bitrate       = audioFormat.bitrate,
                    bitsPerSample = audioFormat.bitsPerSample,
                    channelCount  = audioFormat.channelCount,
                    sampleRate    = audioFormat.sampleRate
                };

                mediaComposer.setTargetAudioFormat(aFormat);
            }
        }
Esempio n. 6
0
 public void LoadVideoFile(IVideoFormat fileFormat)
 {
     VideoFormat = fileFormat;
 }
Esempio n. 7
0
        private bool UpdateMediaInfo(MediaFileInfo mediaFileInfo) {
            if (mediaFileInfo == null) {
                return false;
            }

            string videoMimeType = "unknown";
            string audioMimeType = "unknown";

            videoFormat = mediaFileInfo.getVideoFormat();
            audioFormat = mediaFileInfo.getAudioFormat();

            try
            {
                videoMimeType = videoFormat.mimeType.asString();
            }
            catch (Exception) 
            {
                videoFormat = null;
            }

            try 
            {
                audioMimeType = audioFormat.mimeType.asString();
            }
            catch (Exception) 
            {
                audioFormat = null;
            }

            if (videoFormat != null) {
                float frameRate = videoFormat.frameRate.Numerator;

                if (videoFormat.frameRate.Denominator != 0) {
                    frameRate /= videoFormat.frameRate.Denominator;
                }

                VideoCodecText.Text = videoMimeType;
                ResolutionText.Text = String.Format("{0} x {1}", videoFormat.resolution.Width, videoFormat.resolution.Height);
                FramerateText.Text = String.Format("{0}", frameRate);
                BitrateVideoText.Text = String.Format("{0}", videoFormat.bitrate);
            }
            else {
                ResolutionText.Text = "";
                FramerateText.Text = "";
                BitrateVideoText.Text = "";
            }

            if (audioFormat != null) {
                AudioCodecText.Text = audioMimeType;
                ChannelsText.Text = String.Format("{0}", audioFormat.channelCount);
                SamplerateText.Text = String.Format("{0}", audioFormat.sampleRate);
                BitspersampleText.Text = String.Format("{0}", audioFormat.bitsPerSample);
                BitrateAudioText.Text = String.Format("{0}", audioFormat.bitrate);
            }

            if (videoFormat == null && audioFormat == null) {
                return false;
            }

            Info.Visibility = Visibility.Visible;

            return true;
        }
Esempio n. 8
0
        private bool UpdateMediaInfo(MediaFileInfo mediaFileInfo)
        {
            if (mediaFileInfo == null)
            {
                return(false);
            }

            string videoMimeType = "unknown";
            string audioMimeType = "unknown";

            videoFormat = mediaFileInfo.getVideoFormat();
            audioFormat = mediaFileInfo.getAudioFormat();

            try
            {
                videoMimeType = videoFormat.mimeType.asString();
            }
            catch (Exception)
            {
                videoFormat = null;
            }

            try
            {
                audioMimeType = audioFormat.mimeType.asString();
            }
            catch (Exception)
            {
                audioFormat = null;
            }

            if (videoFormat != null)
            {
                float frameRate = videoFormat.frameRate.Numerator;

                if (videoFormat.frameRate.Denominator != 0)
                {
                    frameRate /= videoFormat.frameRate.Denominator;
                }

                VideoCodecText.Text   = videoMimeType;
                ResolutionText.Text   = String.Format("{0} x {1}", videoFormat.resolution.Width, videoFormat.resolution.Height);
                FramerateText.Text    = String.Format("{0}", frameRate);
                BitrateVideoText.Text = String.Format("{0}", videoFormat.bitrate);
            }
            else
            {
                ResolutionText.Text   = "";
                FramerateText.Text    = "";
                BitrateVideoText.Text = "";
            }

            if (audioFormat != null)
            {
                AudioCodecText.Text    = audioMimeType;
                ChannelsText.Text      = String.Format("{0}", audioFormat.channelCount);
                SamplerateText.Text    = String.Format("{0}", audioFormat.sampleRate);
                BitspersampleText.Text = String.Format("{0}", audioFormat.bitsPerSample);
                BitrateAudioText.Text  = String.Format("{0}", audioFormat.bitrate);
            }

            if (videoFormat == null && audioFormat == null)
            {
                return(false);
            }

            Info.Visibility = Visibility.Visible;

            return(true);
        }