public void GetGroupGroup() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); Assert.AreSame(group, group.Group); } }
public void GetGroupContainer() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ICompositionContainer container = group.Container; } }
public void ConstructWithNullVideoClip() { using (ITimeline timeline = new DefaultTimeline()) { IClip audioClip = timeline.AddAudioGroup().AddTrack().AddAudio("1sec.wav"); var pair = new AudioVideoClipPair(audioClip, null); } }
public void AddCompositionWithName() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); IComposition composition = group.AddComposition("named", -1); Assert.AreEqual("named", composition.Name); } }
public void Construct() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); var args = new AddedGroupEventArgs(group, timeline); Assert.AreSame(group, args.Item); Assert.AreSame(timeline, args.Container); } }
public void AddAudioAndVideo() { // test all the overloads for AddVideoWithAudio using (ITimeline timeline = new DefaultTimeline()) { timeline.AddVideoGroup(24, 320, 240).AddTrack(); timeline.AddAudioGroup().AddTrack(); IAudioVideoClipPair clip1 = timeline.AddVideoWithAudio("1sec.wmv"); Assert.AreEqual(0, clip1.AudioClip.Offset); Assert.AreEqual(1, clip1.AudioClip.Duration); Assert.AreEqual(0, clip1.VideoClip.Offset); Assert.AreEqual(1, clip1.VideoClip.Duration); IAudioVideoClipPair clip2 = timeline.AddVideoWithAudio("1sec.wmv", 1); Assert.AreEqual(2, clip2.AudioClip.Offset); Assert.AreEqual(1, clip2.AudioClip.Duration); Assert.AreEqual(2, clip2.VideoClip.Offset); Assert.AreEqual(1, clip2.VideoClip.Duration); IAudioVideoClipPair clip3 = timeline.AddVideoWithAudio("1sec.wmv", 0, 0.5); Assert.AreEqual(3, clip3.AudioClip.Offset); Assert.AreEqual(0.5, clip3.AudioClip.Duration); Assert.AreEqual(3, clip3.VideoClip.Offset); Assert.AreEqual(0.5, clip3.VideoClip.Duration); IAudioVideoClipPair clip4 = timeline.AddVideoWithAudio("1sec.wmv", 0, 0.5, 1.0); Assert.AreEqual(3.5, clip4.AudioClip.Offset); Assert.AreEqual(0.5, clip4.AudioClip.Duration); Assert.AreEqual(0.5, clip4.AudioClip.MediaStart); Assert.AreEqual(3.5, clip4.VideoClip.Offset); Assert.AreEqual(0.5, clip4.VideoClip.Duration); Assert.AreEqual(0.5, clip4.VideoClip.MediaStart); IAudioVideoClipPair clip5 = timeline.AddVideoWithAudio("1sec.wmv", InsertPosition.Absolute, 6, 0, -1); Assert.AreEqual(6, clip5.AudioClip.Offset); Assert.AreEqual(1, clip5.AudioClip.Duration); Assert.AreEqual(6, clip5.VideoClip.Offset); Assert.AreEqual(1, clip5.VideoClip.Duration); IAudioVideoClipPair clip6 = timeline.AddVideoWithAudio("myclip", "1sec.wmv", InsertPosition.Absolute, 8, 0, 0.5); Assert.AreEqual(8, clip6.AudioClip.Offset); Assert.AreEqual(0, clip6.AudioClip.MediaStart); Assert.AreEqual(0.5, clip6.AudioClip.Duration); Assert.AreEqual("myclip", clip6.AudioClip.Name); Assert.AreEqual(8, clip6.VideoClip.Offset); Assert.AreEqual(0, clip6.VideoClip.MediaStart); Assert.AreEqual(0.5, clip6.VideoClip.Duration); Assert.AreEqual("myclip", clip6.VideoClip.Name); } }
public void AddTransitionSetsSwappedInputsProperly() { using (ITimeline timeline = new DefaultTimeline()) { TransitionDefinition def = StandardTransitions.CreateIris(); IGroup group = timeline.AddAudioGroup(); ITransition groupTransition1 = group.AddTransition(0, 5, def, false); Assert.IsFalse(groupTransition1.SwapInputs); ITransition groupTransition2 = group.AddTransition(5, 5, def, true); Assert.IsTrue(groupTransition2.SwapInputs); } }
public void AddingTransitionsChecksForOverlap() { using (ITimeline timeline = new DefaultTimeline()) { TransitionDefinition def = StandardTransitions.CreateIris(); IGroup group = timeline.AddAudioGroup(); ITransition groupTransition1 = group.AddTransition(0, 5, def, false); Assert.IsFalse(groupTransition1.SwapInputs); ITransition groupTransition2 = group.AddTransition(1, 7, def, true); Assert.IsTrue(groupTransition2.SwapInputs); } }
public void AddClipIgnoresUnrequiredAssistant() { using (ITimeline timeline = new DefaultTimeline()) { var assistant = new MockMediaFileAssistant(false); timeline.InstallAssistant(assistant); Assert.AreEqual(0, assistant.ExecutionCount); ITrack track = timeline.AddAudioGroup().AddTrack(); track.AddAudio("1sec.wav"); Assert.AreEqual(0, assistant.ExecutionCount); } }
public void AddTransitionSetsAppropriateContainerAndGroup() { using (ITimeline timeline = new DefaultTimeline()) { TransitionDefinition def = StandardTransitions.CreateIris(); IGroup group = timeline.AddAudioGroup(); ITransition groupTransition = group.AddTransition(0, 0, def); Assert.AreSame(group, groupTransition.Container); Assert.AreSame(group, groupTransition.Group); ITrack track = group.AddTrack(); ITransition trackTransition = track.AddTransition(0, 0, def); Assert.AreSame(track, trackTransition.Container); Assert.AreSame(group, trackTransition.Group); IComposition composition = group.AddComposition(); ITransition compositionTransition = composition.AddTransition(0, 0, def); Assert.AreSame(composition, compositionTransition.Container); Assert.AreSame(group, compositionTransition.Group); } }
public void RenderAudio() { // create the timeline using (ITimeline timeline = new DefaultTimeline()) { IGroup audioGroup = timeline.AddAudioGroup(); ITrack rootTrack = audioGroup.AddTrack(); rootTrack.AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Relative, 0, 0, 2); // render the timeline using (var renderer = new NullRenderer(timeline)) { ExecuteRenderer(renderer, @"<timeline framerate=""30.0000000""> <group type=""audio"" framerate=""30.0000000"" previewmode=""0""> <track> <clip start=""0"" stop=""2"" src=""testinput.wav"" mstart=""0""/> </track> </group> </timeline>"); } } }
public void AddOverlappingClips1() { // Though we've added 3 clips, the DES track only contains 2 tracks because the third has been occluded. // this behaviour is mimicked by the virtual clip collection, which demonstrates which clips are actually // visible at run time (only on clip on a track is being rendered at any one time) // clip 1 is added, 2 thru 10 secs (8 sec duration) // clip 2 is added 1 second before clip 1, and completely occluded it at 56 secs in length - clip 1 is gone // clip 3 is added 1 second before clip 1, it will play to completion, so the start position for clip 2 is placed // and the end of clip3, and it's media start value is incremented accordingly. using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack track = group.AddTrack(); track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 2, 0, -1); track.AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Absoloute, 1, 0, -1); track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, -1); Assert.AreEqual( @"<clip start=""0"" stop=""8.051875"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""8.051875"" stop=""56.125"" src=""testinput.wav"" mstart=""7.051875"" />", track.VirtualClips.ToString()); Console.WriteLine(track.VirtualClips.ToString()); PrepareToExecute(timeline, @"<timeline framerate=""30.0000000""> <group type=""audio"" framerate=""30.0000000"" previewmode=""0""> <track> <clip start=""0"" stop=""8.0518750"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""8.0518750"" stop=""56.1250000"" src=""testinput.wav"" mstart=""7.0518750"" /> </track> </group> </timeline>"); } }
public void AddOverlappingClips2() { // What's happening here is.. // clip 1 is added, 2 thru 10 secs (8 sec duration) // clip 2 is added 1 second before clip 1, and completely occluded it at 56 secs in length - clip 1 is gone // clip 3 is added 1 second before clip 1, it will play to completion, so the start position for clip 2 is placed // and the end of clip3, and it's media start value is incremented accordingly. using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack track = group.AddTrack(); track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, -1); track.AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Absoloute, 1, 0, -1); track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 2, 0, -1); Assert.AreEqual( @"<clip start=""0"" stop=""1"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""1"" stop=""2"" src=""testinput.wav"" mstart=""0"" /> <clip start=""2"" stop=""10.051875"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""10.051875"" stop=""56.125"" src=""testinput.wav"" mstart=""9.051875"" />", track.VirtualClips.ToString()); PrepareToExecute(timeline, @"<timeline framerate=""30.0000000""> <group type=""audio"" framerate=""30.0000000"" previewmode=""0""> <track> <clip start=""0"" stop=""1"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""1"" stop=""2"" src=""testinput.wav"" mstart=""0"" /> <clip start=""2"" stop=""10.0518750"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""10.0518750"" stop=""56.1250000"" src=""testinput.wav"" mstart=""9.0518750"" /> </track> </group> </timeline>"); } }
public void RemoveClipEventHandlers() { int count = 0; EventHandler incrementBefore = new EventHandler( delegate { count++; } ); EventHandler <AfterEffectAddedEventArgs> incrementAfter = new EventHandler <AfterEffectAddedEventArgs>(delegate { count++; }); using (ITimeline timeline = new DefaultTimeline()) { IClip clip = timeline.AddAudioGroup().AddTrack().AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, -1); clip.AfterEffectAdded += incrementAfter; clip.BeforeEffectAdded += incrementBefore; clip.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); Assert.AreEqual(2, count); count = 0; clip.AfterEffectAdded -= incrementAfter; clip.BeforeEffectAdded -= incrementBefore; clip.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); Assert.AreEqual(0, count); } }
public void AddComposition() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); IComposition composition = group.AddComposition(); Assert.AreSame(group, composition.Container); Assert.AreSame(group, composition.Group); bool firedBefore = false; bool firedAfter = false; composition.AddingComposition += delegate { firedBefore = true; }; composition.AddedComposition += delegate { firedAfter = true; }; IComposition childComposition = composition.AddComposition(); Assert.AreSame(composition, childComposition.Container); Assert.AreSame(group, childComposition.Group); Assert.AreEqual(1, composition.Compositions.Count); Assert.IsTrue(firedBefore); Assert.IsTrue(firedAfter); } }
public void RenderToCompletion() { bool eventTriggered = false; using (ITimeline timeline = new DefaultTimeline()) { IGroup audioGroup = timeline.AddAudioGroup(); ITrack track = audioGroup.AddTrack(); track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, 1); using (NullRenderer renderer = new NullRenderer(timeline)) { renderer.RenderCompleted += new EventHandler(delegate { eventTriggered = true; }); renderer.Render(); Assert.AreEqual(RendererState.GraphCompleted, renderer.State); Assert.IsTrue(eventTriggered); } } }
public void AddClipInChildBubblestoTimeline() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.BeforeClipAdded += new EventHandler(delegate { beforeCount++; }); timeline.AfterClipAdded += new EventHandler <AfterClipAddedEventArgs>(delegate { afterCount++; }); IGroup group = timeline.AddAudioGroup(); group.AddTrack().AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, 5); } Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); }
public void AddAudio() { // test all the overloads for AddAudio using (ITimeline timeline = new DefaultTimeline()) { timeline.AddAudioGroup().AddTrack(); IClip clip1 = timeline.AddAudio("1sec.wav"); Assert.AreEqual(0, clip1.Offset); Assert.AreEqual(1, clip1.Duration); IClip clip2 = timeline.AddAudio("1sec.wav", 1); Assert.AreEqual(2, clip2.Offset); Assert.AreEqual(1, clip2.Duration); IClip clip3 = timeline.AddAudio("1sec.wav", 0, 0.5); Assert.AreEqual(3, clip3.Offset); Assert.AreEqual(0.5, clip3.Duration); IClip clip4 = timeline.AddAudio("1sec.wav", 0, 0.5, 1.0); Assert.AreEqual(3.5, clip4.Offset); Assert.AreEqual(0.5, clip4.Duration); Assert.AreEqual(0.5, clip4.MediaStart); IClip clip5 = timeline.AddAudio("1sec.wav", InsertPosition.Absolute, 6, 0, -1); Assert.AreEqual(6, clip5.Offset); Assert.AreEqual(1, clip5.Duration); IClip clip6 = timeline.AddAudio("myclip", "1sec.wav", InsertPosition.Absolute, 8, 0, 0.5); Assert.AreEqual(8, clip6.Offset); Assert.AreEqual(0, clip6.MediaStart); Assert.AreEqual(0.5, clip6.Duration); Assert.AreEqual("myclip", clip6.Name); } }
public async Task MakeVideo(double BPM, double BPM_Multiplier, double offset, string videoTitle, string audioFilePath, double videoDuration = 30) { string temporaryVideoFileName = tempFilesPath + videoMakerIOUtilities.ReturnNameWithExtension(videoTitle, true); string VideoFileName = finalFilesPath + videoMakerIOUtilities.ReturnNameWithExtension(videoTitle, false); double FrameTimeFromBPM = videoMakerTimingUtilities.ReturnFrameTimeBasedOnBPM(BPM, BPM_Multiplier); await Task.Run(() => { if (videoMakerIOUtilities.CheckIfImageFilesExist(imageFilesPath: $@"jpg2\", 19)) { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddVideoGroup(32, 738, 650); ITrack videoTrack = group.AddTrack(); videoTrack.AddImage($@"jpg2\1.jpg", 0, offset); int framesNumber = videoMakerTimingUtilities.ReturnNumberOfFrames(videoDuration, offset, FrameTimeFromBPM); for (int i = 1; i <= framesNumber; i++) { int picNumber = i % 18; videoTrack.AddImage($@"jpg2\{picNumber + 1}.jpg", 0, FrameTimeFromBPM); } ITrack audioTrack = timeline.AddAudioGroup().AddTrack(); audioTrack.AddAudio(audioFilePath, 0, videoTrack.Duration + 2.75); using (WindowsMediaRenderer renderer = new WindowsMediaRenderer(timeline, temporaryVideoFileName, WindowsMediaProfiles.HighQualityVideo)) { renderer.Render(); } } } } ); if (CutVideo(temporaryVideoFileName, VideoFileName, videoDuration)) { Messaging.ShowMessage($"Your video was generated successfully. Look for your {VideoFileName} file in app folder.", "Success"); } }
public void GroupAddEffectBubblesToTimeline() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.BeforeEffectAdded += new EventHandler(delegate { beforeCount++; }); timeline.AfterEffectAdded += new EventHandler <AfterEffectAddedEventArgs>(delegate { afterCount++; }); IGroup group = timeline.AddAudioGroup(); group.AddEffect(0, 1, StandardEffects.CreateDefaultBlur()); } Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); }
public void AddAndRemoveHandler() { bool eventTriggered = false; using (ITimeline timeline = new DefaultTimeline()) { IGroup audioGroup = timeline.AddAudioGroup(); ITrack track = audioGroup.AddTrack(); track.AddClip("..\\..\\testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, -1); using (var renderer = new NullRenderer(timeline)) { EventHandler handler = delegate { eventTriggered = true; }; renderer.RenderCompleted += handler; renderer.RenderCompleted -= handler; renderer.BeginRender(null, null); renderer.Cancel(); Assert.IsFalse(eventTriggered); } } }
public void AddAudioGroupWithDefaultFPS() { bool beforeFired = false; bool afterFried = false; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.BeforeGroupAdded += new EventHandler(delegate { beforeFired = true; }); timeline.AfterGroupAdded += new EventHandler <AfterGroupAddedEventArgs>(delegate { afterFried = true; }); IGroup group = timeline.AddAudioGroup(); Assert.AreSame(timeline, group.Timeline); Assert.AreEqual(timeline.FPS, group.FPS); Assert.IsTrue(beforeFired); Assert.IsTrue(afterFried); } }
public void GroupAddCompositionBubblesToTimeline() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.BeforeCompositionAdded += new EventHandler(delegate { beforeCount++; }); timeline.AfterCompositionAdded += new EventHandler <AfterCompositionAddedEventArgs>(delegate { afterCount++; }); IGroup group = timeline.AddAudioGroup(); group.AddComposition(); } Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); }
public void AddAudioGroupWithName() { using (ITimeline timeline = new DefaultTimeline(12)) { IGroup group = timeline.AddAudioGroup("my audio"); Assert.AreEqual(group.Name, "my audio"); Assert.AreSame(timeline, group.Timeline); PrepareToExecute(timeline, @"<timeline framerate=""12.0000000""><group username=""my audio"" type=""audio"" framerate=""12.0000000"" previewmode=""0"" /></timeline>"); } }
public void AddAudioGroupWithDefaultFPS() { bool beforeFired = false; bool afterFried = false; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.AddingGroup += delegate { beforeFired = true; }; timeline.AddedGroup += delegate { afterFried = true; }; IGroup group = timeline.AddAudioGroup(); Assert.AreSame(timeline, group.Timeline); Assert.AreEqual(timeline.Fps, group.Fps); Assert.IsTrue(beforeFired); Assert.IsTrue(afterFried); } }
public void AddAudioClipWhenNoSupportingTrackExists() { using (ITimeline timeline = new DefaultTimeline()) { timeline.AddAudioGroup(); timeline.AddAudio("1sec.wav"); } }
public void RemoveEvents() { int count = 0; EventHandler increment = delegate { count++; }; EventHandler <AddedCompositionEventArgs> incrementForAfterCompositionAdded = delegate { count++; }; EventHandler <AddedEffectEventArgs> incrementForAfterEffectAdded = delegate { count++; }; EventHandler <AddedTrackEventArgs> incrementForAfterTrackAdded = delegate { count++; }; EventHandler <AddedTransitionEventArgs> incrementForAfterTransitionAdded = delegate { count++; }; EventHandler <AddedClipEventArgs> incrementForAfterClipAdded = delegate { count++; }; EventHandler <AddedGroupEventArgs> incrementForAfterGroupAdded = delegate { count++; }; using (ITimeline timeline = new DefaultTimeline()) { timeline.AddedComposition += incrementForAfterCompositionAdded; timeline.AddedEffect += incrementForAfterEffectAdded; timeline.AddedTrack += incrementForAfterTrackAdded; timeline.AddedTransition += incrementForAfterTransitionAdded; timeline.AddedClip += incrementForAfterClipAdded; timeline.AddedGroup += incrementForAfterGroupAdded; timeline.AddingComposition += increment; timeline.AddingEffect += increment; timeline.AddingTrack += increment; timeline.AddingTransition += increment; timeline.AddingClip += increment; timeline.AddingGroup += increment; IGroup group = timeline.AddAudioGroup(); group.AddComposition(); group.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); group.AddTrack().AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, 1); group.AddTransition(0, 2, StandardTransitions.CreateFade()); Assert.AreEqual(12, count); count = 0; timeline.AddedComposition -= incrementForAfterCompositionAdded; timeline.AddedEffect -= incrementForAfterEffectAdded; timeline.AddedTrack -= incrementForAfterTrackAdded; timeline.AddedTransition -= incrementForAfterTransitionAdded; timeline.AddedClip -= incrementForAfterClipAdded; timeline.AddedGroup -= incrementForAfterGroupAdded; timeline.AddingComposition -= increment; timeline.AddingEffect -= increment; timeline.AddingTrack -= increment; timeline.AddingTransition -= increment; timeline.AddingClip -= increment; timeline.AddingGroup -= increment; IGroup group2 = timeline.AddAudioGroup(); group2.AddComposition(); group2.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); group2.AddTrack().AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Relative, 0, 0, 1); group2.AddTransition(2, 2, StandardTransitions.CreateFade()); Assert.AreEqual(0, count); } }
public void RemoveEvents() { int count = 0; EventHandler increment = new EventHandler(delegate { count++; }); EventHandler <AfterCompositionAddedEventArgs> incrementForAfterCompositionAdded = new EventHandler <AfterCompositionAddedEventArgs>(delegate { count++; }); EventHandler <AfterEffectAddedEventArgs> incrementForAfterEffectAdded = new EventHandler <AfterEffectAddedEventArgs>(delegate { count++; }); EventHandler <AfterTrackAddedEventArgs> incrementForAfterTrackAdded = new EventHandler <AfterTrackAddedEventArgs>(delegate { count++; }); EventHandler <AfterTransitionAddedEventArgs> incrementForAfterTransitionAdded = new EventHandler <AfterTransitionAddedEventArgs>(delegate { count++; }); EventHandler <AfterClipAddedEventArgs> incrementForAfterClipAdded = new EventHandler <AfterClipAddedEventArgs>(delegate { count++; }); using (ITimeline timeline = new DefaultTimeline()) { IComposition composition = timeline.AddAudioGroup().AddComposition(); composition.AfterCompositionAdded += incrementForAfterCompositionAdded; composition.AfterEffectAdded += incrementForAfterEffectAdded; composition.AfterTrackAdded += incrementForAfterTrackAdded; composition.AfterTransitionAdded += incrementForAfterTransitionAdded; composition.AfterClipAdded += incrementForAfterClipAdded; composition.BeforeCompositionAdded += increment; composition.BeforeEffectAdded += increment; composition.BeforeTrackAdded += increment; composition.BeforeTransitionAdded += increment; composition.BeforeClipAdded += increment; composition.AddComposition(); composition.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); composition.AddTrack().AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absoloute, 0, 0, 1); composition.AddTransition(0, 2, StandardTransitions.CreateFade()); Assert.AreEqual(10, count); count = 0; composition.AfterCompositionAdded -= incrementForAfterCompositionAdded; composition.AfterEffectAdded -= incrementForAfterEffectAdded; composition.AfterTrackAdded -= incrementForAfterTrackAdded; composition.AfterTransitionAdded -= incrementForAfterTransitionAdded; composition.AfterClipAdded -= incrementForAfterClipAdded; composition.BeforeCompositionAdded -= increment; composition.BeforeEffectAdded -= increment; composition.BeforeTrackAdded -= increment; composition.BeforeTransitionAdded -= increment; composition.BeforeClipAdded -= increment; composition.AddComposition(); composition.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); composition.AddTrack(); composition.AddTransition(2, 2, StandardTransitions.CreateFade()); Assert.AreEqual(0, count); } }
public void AddTrack() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); IComposition composition = group.AddComposition(); bool firedBefore = false; bool firedAfter = false; composition.AddingTrack += delegate { firedBefore = true; }; composition.AddedTrack += delegate { firedAfter = true; }; ITrack track = composition.AddTrack(); Assert.AreEqual(1, composition.Tracks.Count); Assert.IsTrue(firedBefore); Assert.IsTrue(firedAfter); } }
public void GroupAddTransitionBubblesToTimeline() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.AddingTransition += delegate { beforeCount++; }; timeline.AddedTransition += delegate { afterCount++; }; IGroup group = timeline.AddAudioGroup(); group.AddTransition(0, 0, StandardTransitions.CreateFade()); } Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); }
public void AddClipInChildBubblestoTimeline() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.AddingClip += delegate { beforeCount++; }; timeline.AddedClip += delegate { afterCount++; }; IGroup group = timeline.AddAudioGroup(); group.AddTrack().AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, 5); } Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); }
public void TrackPrioirities() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack first = group.AddTrack("first", -1); ITrack second = group.AddTrack("second", 0); ITrack third = group.AddTrack("third", 1); ITrack fourth = group.AddTrack("fourth", -1); ITrack fifth = group.AddTrack("fifth", 2); Assert.AreEqual(3, first.Priority); Assert.AreEqual(0, second.Priority); Assert.AreEqual(1, third.Priority); Assert.AreEqual(4, fourth.Priority); Assert.AreEqual(2, fifth.Priority); } }
public void EffectPrioirities() { using (ITimeline timeline = new DefaultTimeline()) { EffectDefinition definition = StandardEffects.CreateBlurEffect(2, 10, 2); IGroup group = timeline.AddAudioGroup(); IEffect first = group.AddEffect("first", -1, 0, 10, definition); IEffect second = group.AddEffect("second", 0, 0, 10, definition); IEffect third = group.AddEffect("third", 1, 0, 10, definition); IEffect fourth = group.AddEffect("fourth", -1, 0, 10, definition); IEffect fifth = group.AddEffect("fifth", 2, 0, 10, definition); Assert.AreEqual(3, first.Priority); Assert.AreEqual(0, second.Priority); Assert.AreEqual(1, third.Priority); Assert.AreEqual(4, fourth.Priority); Assert.AreEqual(2, fifth.Priority); } }
public static void createVideo(string outputFile, string tempFileName, int width, int height, bool append) { if (!append) { tempFileName = outputFile; } using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddVideoGroup(32, width, height); ITrack videoTrack = group.AddTrack(); foreach (var filename in Directory.GetFiles(@"Output\")) { videoTrack.AddImage(filename, 0, (1.0 / 48.0)); } ITrack audioTrack = timeline.AddAudioGroup().AddTrack(); try { using (AviFileRenderer renderer = new AviFileRenderer(timeline, tempFileName)) { renderer.Render(); } } catch (Exception ex) { throw; } } if (append) { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddVideoGroup(32, width, height); ITrack videoTrack = group.AddTrack(); var firstVideoClip = group.AddTrack().AddVideo(outputFile); var secondVideoClip = group.AddTrack().AddVideo(tempFileName, firstVideoClip.Duration); ITrack audioTrack = timeline.AddAudioGroup().AddTrack(); try { using (AviFileRenderer renderer = new AviFileRenderer(timeline, "_" + outputFile)) { renderer.Render(); } Application.DoEvents(); System.Threading.Thread.Sleep(1000); File.Delete(outputFile); File.Delete(tempFileName); File.Move("_" + outputFile, outputFile); } catch (Exception ex) { throw; } } } }
public void RemoveGroupAddedHandlers() { int count = 0; EventHandler incrementBefore = delegate { count++; }; EventHandler<AddedGroupEventArgs> incrementAfter = delegate { count++; }; using (ITimeline timeline = new DefaultTimeline()) { timeline.AddingGroup += incrementBefore; timeline.AddedGroup += incrementAfter; timeline.AddAudioGroup(); Assert.AreEqual(2, count); count = 0; timeline.AddingGroup -= incrementBefore; timeline.AddedGroup -= incrementAfter; timeline.AddAudioGroup(); Assert.AreEqual(0, count); } }
public void CompositionPriorities() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); IComposition first = group.AddComposition("first", -1); IComposition second = group.AddComposition("second", 0); IComposition third = group.AddComposition("third", 1); IComposition fourth = group.AddComposition("fourth", -1); IComposition fifth = group.AddComposition("fifth", 2); Assert.AreEqual(3, first.Priority); Assert.AreEqual(0, second.Priority); Assert.AreEqual(1, third.Priority); Assert.AreEqual(4, fourth.Priority); Assert.AreEqual(2, fifth.Priority); } }
public void GroupAddEffectBubblesToTimeline() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.AddingEffect += delegate { beforeCount++; }; timeline.AddedEffect += delegate { afterCount++; }; IGroup group = timeline.AddAudioGroup(); group.AddEffect(0, 1, StandardEffects.CreateDefaultBlur()); } Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); }
public void GroupAddTrackBubblesToTimeline() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline(12)) { timeline.AddingTrack += delegate { beforeCount++; }; timeline.AddedTrack += delegate { afterCount++; }; IGroup group = timeline.AddAudioGroup(); group.AddTrack(); } Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); }
public void AddOverlappingClips2() { // What's happening here is.. // clip 1 is added, 2 thru 10 secs (8 sec duration) // clip 2 is added 1 second before clip 1, and completely occluded it at 56 secs in length - clip 1 is gone // clip 3 is added 1 second before clip 1, it will play to completion, so the start position for clip 2 is placed // and the end of clip3, and it's media start value is incremented accordingly. using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack track = group.AddTrack(); track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, -1); track.AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Absolute, 1, 0, -1); track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 2, 0, -1); Assert.AreEqual( @"<clip start=""0"" stop=""1"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""1"" stop=""2"" src=""testinput.wav"" mstart=""0"" /> <clip start=""2"" stop=""10.051875"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""10.051875"" stop=""56.125"" src=""testinput.wav"" mstart=""9.051875"" />", track.VirtualClips.ToString().Replace(Environment.CurrentDirectory +"\\","")); PrepareToExecute(timeline, @"<timeline framerate=""30.0000000""> <group type=""audio"" framerate=""30.0000000"" previewmode=""0""> <track> <clip start=""0"" stop=""1"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""1"" stop=""2"" src=""testinput.wav"" mstart=""0"" /> <clip start=""2"" stop=""10.0518750"" src=""testinput.mp3"" mstart=""0"" /> <clip start=""10.0518750"" stop=""56.1250000"" src=""testinput.wav"" mstart=""9.0518750"" /> </track> </group> </timeline>"); } }
public void RemoveEvents() { int count = 0; EventHandler increment = delegate { count++; }; EventHandler<AddedCompositionEventArgs> incrementForAfterCompositionAdded = delegate { count++; }; EventHandler<AddedEffectEventArgs> incrementForAfterEffectAdded = delegate { count++; }; EventHandler<AddedTrackEventArgs> incrementForAfterTrackAdded = delegate { count++; }; EventHandler<AddedTransitionEventArgs> incrementForAfterTransitionAdded = delegate { count++; }; EventHandler<AddedClipEventArgs> incrementForAfterClipAdded = delegate { count++; }; EventHandler<AddedGroupEventArgs> incrementForAfterGroupAdded = delegate { count++; }; using (ITimeline timeline = new DefaultTimeline()) { timeline.AddedComposition += incrementForAfterCompositionAdded; timeline.AddedEffect += incrementForAfterEffectAdded; timeline.AddedTrack += incrementForAfterTrackAdded; timeline.AddedTransition += incrementForAfterTransitionAdded; timeline.AddedClip += incrementForAfterClipAdded; timeline.AddedGroup += incrementForAfterGroupAdded; timeline.AddingComposition += increment; timeline.AddingEffect += increment; timeline.AddingTrack += increment; timeline.AddingTransition += increment; timeline.AddingClip += increment; timeline.AddingGroup += increment; IGroup group = timeline.AddAudioGroup(); group.AddComposition(); group.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); group.AddTrack().AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, 1); group.AddTransition(0, 2, StandardTransitions.CreateFade()); Assert.AreEqual(12, count); count = 0; timeline.AddedComposition -= incrementForAfterCompositionAdded; timeline.AddedEffect -= incrementForAfterEffectAdded; timeline.AddedTrack -= incrementForAfterTrackAdded; timeline.AddedTransition -= incrementForAfterTransitionAdded; timeline.AddedClip -= incrementForAfterClipAdded; timeline.AddedGroup -= incrementForAfterGroupAdded; timeline.AddingComposition -= increment; timeline.AddingEffect -= increment; timeline.AddingTrack -= increment; timeline.AddingTransition -= increment; timeline.AddingClip -= increment; timeline.AddingGroup -= increment; IGroup group2 = timeline.AddAudioGroup(); group2.AddComposition(); group2.AddEffect(0, 2, StandardEffects.CreateDefaultBlur()); group2.AddTrack().AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Relative, 0, 0, 1); group2.AddTransition(2, 2, StandardTransitions.CreateFade()); Assert.AreEqual(0, count); } }
public void AddTrack() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack rootTrack = group.AddTrack(); Assert.AreSame(group, rootTrack.Group); Assert.AreSame(group, rootTrack.Container); Assert.AreEqual(1, group.Tracks.Count); Assert.AreSame(group.Tracks[0], rootTrack); ITrack track2 = group.AddTrack(); Assert.AreEqual(2, group.Tracks.Count); Assert.AreEqual(group.Tracks[1], track2); PrepareToExecute(timeline, @"<timeline framerate=""30.0000000""> <group type=""audio"" framerate=""30.0000000"" previewmode=""0""> <track /> <track /> </group> </timeline>"); } }
public void ShadowCopyAudio() { using (ITimeline timeline = new DefaultTimeline()) { string fullPath = Path.GetFullPath("1sec.wmv"); timeline.AddAudioGroup().AddTrack(); timeline.AddVideoGroup(24, 320, 200).AddTrack(); IAudioVideoClipPair pair = timeline.AddVideoWithAudio("1sec.wmv", true); Assert.AreEqual(fullPath, pair.VideoClip.File.FileName); Assert.AreNotEqual(fullPath, pair.AudioClip.File.FileName); Assert.IsTrue(pair.AudioClip.File.FileName.EndsWith(".wmv")); } }
public void AddTrackWithNames() { using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack track1 = group.AddTrack("track1", -1); Assert.AreEqual("track1", track1.Name); Assert.AreEqual(1, group.Tracks.Count); track1.AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Relative, 0, 0, -1); Assert.AreSame(group.Tracks[0], track1); ITrack track2 = group.AddTrack("track2", -1); Assert.AreEqual("track2", track2.Name); track2.AddClip("testinput.wav", GroupMediaType.Audio, InsertPosition.Relative, 0, 0, -1); Assert.AreEqual(2, group.Tracks.Count); Assert.AreEqual(group.Tracks[1], track2); PrepareToExecute(timeline, @"<timeline framerate=""30.0000000""> <group type=""audio"" framerate=""30.0000000"" previewmode=""0""> <track username=""track1""> <clip start=""0"" stop=""55.1250000"" src=""testinput.wav"" mstart=""0"" /> </track> <track username=""track2""> <clip start=""0"" stop=""55.1250000"" src=""testinput.wav"" mstart=""0"" /> </track> </group> </timeline>"); } }
private void makeMovie(int imageName) { int simpleCount = 0; string simpleAudio = ""; string videoPath = ""; string title = ""; string description = ""; string tags = ""; foreach (VideoListModel videoItem in vList.getData()) { if (simpleCount == 0) { title = videoItem.VideoName; description = videoItem.VideoDescription; tags = videoItem.VideoTags; simpleAudio = videoItem.AudioLocation; videoPath = Application.StartupPath + "\\VideoData\\video\\" + videoItem.VideoName + ".wmv"; } simpleCount++; } label9.Text = title; Console.WriteLine(Application.StartupPath + "\\VideoData\\images\\merged\\" + imageName.ToString() + ".jpg"); using (ITimeline timeline = new DefaultTimeline(1)) { IGroup group = timeline.AddVideoGroup(32, 1920, 1080); ITrack videoTrack = group.AddTrack(); IClip clip1 = videoTrack.AddImage(Application.StartupPath + "\\VideoData\\images\\merged\\" + imageName.ToString() + ".jpg", 0, 0); ITrack audioTrack = timeline.AddAudioGroup().AddTrack(); IClip audio = audioTrack.AddAudio(simpleAudio); IClip clip2 = videoTrack.AddImage(Application.StartupPath + "\\VideoData\\images\\merged\\" + imageName.ToString() + ".jpg", 0, audio.Duration); var participant = new PercentageProgressParticipant(timeline); participant.ProgressChanged += new EventHandler <Splicer.Renderer.ProgressChangedEventArgs>(participant_ProgressChanged); using ( WindowsMediaRenderer renderer = new WindowsMediaRenderer(timeline, videoPath, WindowsMediaProfiles.HighQualityVideo)) { renderer.Render(); } } progressBar1.Value = 0; vList.getData().RemoveAt(0); vList.saveData(); refreshList(); try { //2. Get credentials and upload the file Run(title, description, videoPath, tags); } catch (AggregateException ex) { foreach (var exception in ex.InnerExceptions) { Console.WriteLine(exception.Message); } } }
public void EnsureClipBubblesBeforeAndAfterEffectAddedUp() { int beforeCount = 0; int afterCount = 0; using (ITimeline timeline = new DefaultTimeline()) { IGroup group = timeline.AddAudioGroup(); ITrack track = group.AddTrack(); track.AddingEffect += delegate { beforeCount++; }; track.AddedEffect += delegate { afterCount++; }; IClip clip = track.AddClip("testinput.mp3", GroupMediaType.Audio, InsertPosition.Absolute, 0, 0, -1); clip.AddEffect(0, 1, StandardEffects.CreateDefaultBlur()); Assert.AreEqual(1, beforeCount); Assert.AreEqual(1, afterCount); } }