Ejemplo n.º 1
0
        public void CreateByTimeSpanTest(int expected, FrameRate frameRate, bool isDropFrame, string input)
        {
            var attempt = Timecode.FromString(input, frameRate, isDropFrame).ToTimeSpan();
            var actual  = Timecode.FromTimeSpan(attempt, frameRate, isDropFrame);

            Assert.Equal(expected, actual.TotalFrames);
        }
Ejemplo n.º 2
0
		private void tbPaddingAmount_TextChanged(object sender, EventArgs e)
		{
			Timecode tc = Timecode.FromString(tbPaddingAmount.Text, RulerFormat.Seconds);
			if (tc == null)
				return;
			lbPaddingPreview.Text = tc.ToString();
		}
        public void Test_Add_NTSC_HD_VideoClip_To_A_PAL_HD_VideoReel()
        {
            // Arrange
            var videoReel = new VideoReel()
            {
                VideoDefinition = VideoDefinition.HD,
                VideoStandard   = VideoStandard.PAL,
                Name            = "Video Two",
                TotalDuration   = Timecode.Subtract(Timecode.FromString("00:00:20:10", FrameRate.FPS25), Timecode.FromString("00:00:00:00", FrameRate.FPS25)).ToString(),
                Id         = 1,
                VideoClips = new List <VideoClip>()
                {
                    DataHelper.GetaPALHDVideoClip()
                }
            };

            this._videoClipService.Setup(x => x.GetClip(4)).Returns(DataHelper.GetaNTSCHDVideoClip());

            // Act
            var viewModel = new VideoReelAddViewModel(this._videoReelService.Object, this._videoClipService.Object);
            var result    = viewModel.AddClipToReel(videoReel, 4);

            viewModel.VideoClip = DataHelper.GetaNTSCHDVideoClip();

            // Assert
            Assert.AreEqual(viewModel.CanAddClipToReel, false);
            Assert.AreEqual(viewModel.ErrorMessage, "Add failed.Video Standards do not match.");
            Assert.IsFalse(result);

            this._videoClipService.VerifyAll();
        }
        public void Test_Get_Video_Clip_Details()
        {
            // Arrange
            var videoReel = new VideoReel()
            {
                VideoDefinition = VideoDefinition.HD,
                VideoStandard   = VideoStandard.NTSC,
                Name            = "Video Two",
                TotalDuration   = Timecode.Subtract(Timecode.FromString("00:00:20:10", FrameRate.FPS30), Timecode.FromString("00:00:00:00", FrameRate.FPS30)).ToString(),
                Id         = 1,
                VideoClips = new List <VideoClip>()
                {
                    DataHelper.GetaNTSCHDVideoClip()
                }
            };

            this._videoClipService.Setup(x => x.GetClip(3)).Returns(DataHelper.GetaPALHDVideoClip());
            var viewModel = new VideoReelAddViewModel(this._videoReelService.Object, this._videoClipService.Object);

            viewModel.GetVideoClipDetails(3);

            Assert.AreEqual(viewModel.VideoClip.Id, 3);
            Assert.AreEqual(viewModel.VideoClip.VideoStandard, VideoStandard.PAL);
            Assert.AreEqual(viewModel.VideoClip.VideoDefinition, VideoDefinition.HD);
            Assert.AreEqual(viewModel.VideoClip.Description, "Video Promo");
            Assert.AreEqual(viewModel.VideoClip.Name, "Captain America: The First Avenger");
        }
Ejemplo n.º 5
0
        public void Test_Add_PAL_HD_VideoClip_To_A_PAL_HD_VideoReel()
        {
            // Arrange
            var videoReel = new VideoReel()
            {
                VideoDefinition = VideoDefinition.HD,
                VideoStandard   = VideoStandard.PAL,
                Name            = "Video Two",
                TotalDuration   = Timecode.Subtract(Timecode.FromString("00:00:20:10", FrameRate.FPS25), Timecode.FromString("00:00:00:00", FrameRate.FPS25)).ToString(),
                Id         = 1,
                VideoClips = new List <VideoClip>()
                {
                    DataHelper.GetaPALHDVideoClip()
                }
            };

            this._videoClipService.Setup(x => x.GetClip(3))
            .Returns(
                new VideoClip()
            {
                Id              = 4,
                Name            = "Captain America: The First Avenger New",
                Description     = "Video Promo",
                VideoStandard   = VideoStandard.PAL,
                VideoDefinition = VideoDefinition.HD,
                StartTime       = "00:00:00:00",
                EndTime         = "00:00:20:10"
            });

            this._videoReelService.Setup(x => x.GetClipsForaReel(It.IsAny <int>())).Returns(new List <VideoClip>()
            {
                DataHelper.GetaPALHDVideoClip()
            });

            var viewModel = new VideoReelAddViewModel(this._videoReelService.Object, this._videoClipService.Object);

            viewModel.VideoClips = new List <VideoClip>()
            {
                DataHelper.GetaPALHDVideoClip()
            };
            viewModel.VideoClip = new VideoClip()
            {
                Id              = 4,
                Name            = "Captain America: The First Avenger New",
                Description     = "Video Promo",
                VideoStandard   = VideoStandard.PAL,
                VideoDefinition = VideoDefinition.HD,
                StartTime       = "00:00:00:00",
                EndTime         = "00:00:20:10"
            };


            // Act
            var result = viewModel.AddClipToReel(videoReel, 3);

            // Assert
            Assert.AreEqual(viewModel.CanAddClipToReel, true);
            Assert.AreEqual(viewModel.ErrorMessage, string.Empty);
            Assert.IsTrue(result);
        }
Ejemplo n.º 6
0
        public static void MoveElement(ElementStep elementStep)
        {
            if (!elementStep.Selector.IsValid() || elementStep.Selector.ElementType == ElementType.None || elementStep.Selector.ElementType == ElementType.Track)
            {
                return;
            }
            TrackEvent eventToMove = SelectorService.GetEvent(elementStep.Selector);
            Timecode   timecode    = Timecode.FromString(elementStep.DataPropertyList[DataPropertyHolder.TIMECODE].Value);

            eventToMove.Start = timecode;
        }
Ejemplo n.º 7
0
    Timecode AttributeTimecode(XmlElement elt, String name)
    {
        // First try to use the Nanos value.
        String nanosVal = elt.GetAttribute("Nanos");

        if (!String.IsNullOrEmpty(nanosVal))
        {
            return(Timecode.FromNanos(Int64.Parse(nanosVal, myNumberFormat)));
        }
        // Fall back to using the string reprsentation.
        String val = AttributeString(elt, name);

        return(Timecode.FromString(val, myTimecodeFormat));
    }
Ejemplo n.º 8
0
 public void CreateFailingTest()
 {
     Assert.Throws <ArgumentException>(
         "isDropFrame",
         () => Timecode.FromFrames(0, FrameRate.fps23_98, true));
     Assert.Throws <ArgumentException>(
         "isDropFrame",
         () => Timecode.FromString("DROPFRAME", FrameRate.fps23_98, true));
     Assert.Throws <ArgumentNullException>(
         "input",
         () => Timecode.FromString(string.Empty, FrameRate.fps23_98, false));
     Assert.Throws <ArgumentException>(
         "input",
         () => Timecode.FromString("NOTVALID", FrameRate.fps23_98, false));
 }
Ejemplo n.º 9
0
    Timecode ChildTimecode(XmlElement parent, String childName)
    {
        XmlElement childElt = parent[childName];

        if (null == childElt)
        {
            new Timecode();
        }
        // first try to get the Nanos attribute
        String nanoVal = childElt.GetAttribute("Nanos");

        if (!String.IsNullOrEmpty(nanoVal))
        {
            return(Timecode.FromNanos(Int64.Parse(nanoVal, myNumberFormat)));
        }
        // fall back to using the string representation
        String val = childElt.InnerText;

        return(Timecode.FromString(val, myTimecodeFormat));
    }
        private string CalculateDuration(VideoReel videoReel)
        {
            Timecode timeCode = Timecode.FromString("00:00:00:00", videoReel.VideoStandard.FrameRate().ToFrameRate());

            foreach (var videoClip in videoReel.VideoClips)
            {
                if (timeCode != null)
                {
                    timeCode = Timecode.Add(timeCode, Timecode.Subtract(
                                                Timecode.FromString(videoClip.EndTime, videoClip.VideoStandard.FrameRate().ToFrameRate()),
                                                Timecode.FromString(videoClip.StartTime, videoClip.VideoStandard.FrameRate().ToFrameRate())));
                }
                else
                {
                    timeCode = Timecode.Subtract(
                        Timecode.FromString(videoClip.EndTime, videoClip.VideoStandard.FrameRate().ToFrameRate()),
                        Timecode.FromString(videoClip.StartTime, videoClip.VideoStandard.FrameRate().ToFrameRate()));
                }
            }

            return(videoReel.TotalDuration = timeCode.ToString());
        }
Ejemplo n.º 11
0
        public void CreateByStringTest(int expected, FrameRate frameRate, bool isDropFrame, string input)
        {
            var actual = Timecode.FromString(input, frameRate, isDropFrame);

            Assert.Equal(expected, actual.TotalFrames);
        }
Ejemplo n.º 12
0
        public static void AddElement(ElementStep elementStep)
        {
            if (!elementStep.Selector.IsValid() || elementStep.Selector.ElementType == ElementType.None)
            {
                return;
            }

            if (elementStep.Selector.ElementType == ElementType.Event)
            {
                Track track      = SelectorService.GetTrack(elementStep.Selector);
                var   trackRegEx = new Regex(elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                Media media      = MainContainer.Vegas.Project.MediaPool.Cast <Media>().FirstOrDefault(x =>
                                                                                                       trackRegEx.IsMatch(Path.GetFileName(x.FilePath)));
                if (elementStep.Selector.IsAudio() && media.Streams.Any(x => x.MediaType == MediaType.Audio))
                {
                    TrackEvent trackEvent = new AudioEvent(
                        Timecode.FromString(elementStep.DataPropertyList[DataPropertyHolder.TIMECODE].Value),
                        media.Length,
                        elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                    track.Events.Add(trackEvent);
                    trackEvent.AddTake(media.Streams[0], true, elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                }
                if (elementStep.Selector.IsVideo() && media.Streams.Any(x => x.MediaType == MediaType.Video))
                {
                    TrackEvent trackEvent = new VideoEvent(Timecode.FromString(elementStep.DataPropertyList[DataPropertyHolder.TIMECODE].Value),
                                                           media.Length,
                                                           elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                    if (media.Streams.Any(x => x.MediaType == MediaType.Audio))
                    {
                        elementStep.Selector.ElementMediaType = ElementMediaType.Audio;
                        AudioTrack  syncAudioTrack = SelectorService.GetTrack(elementStep.Selector) as AudioTrack;
                        MediaStream audioStream    = media.Streams.FirstOrDefault(x => x.MediaType == MediaType.Audio);
                        MediaStream videoStream    = media.Streams.FirstOrDefault(x => x.MediaType == MediaType.Video);
                        var         audioEvent     = new AudioEvent(
                            Timecode.FromString(elementStep.DataPropertyList[DataPropertyHolder.TIMECODE].Value),
                            media.Length,
                            elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                        track.Events.Add(trackEvent);
                        trackEvent.AddTake(videoStream, true, elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                        syncAudioTrack.Events.Add(audioEvent);
                        audioEvent.AddTake(audioStream, true, elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                    }
                    else
                    {
                        track.Events.Add(trackEvent);
                        trackEvent.AddTake(media.Streams[0], true, elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value);
                    }
                }
            }
            if (elementStep.Selector.ElementType == ElementType.Track)
            {
                if (elementStep.Selector.IsAudio())
                {
                    MainContainer.Vegas.Project.AddAudioTrack().Name = elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value;
                }
                if (elementStep.Selector.IsVideo())
                {
                    MainContainer.Vegas.Project.AddVideoTrack().Name = elementStep.DataPropertyList[DataPropertyHolder.RESOURCE_NAME].Value;
                }
            }
        }