Exemplo n.º 1
0
 public void StartPreviewPlayback(VidkaProj proj, long frameStart, bool onlyLockedClips)
 {
     lock (mutex)
     {
         // ... what we are going to play
         long frameOffset;
         var  curClipIndex = proj.GetVideoClipIndexAtFrame(frameStart, out frameOffset);
         var  clip         = onlyLockedClips
                                 ? proj.GetNextLockedVideoClipStartingAtIndex(curClipIndex, out curClipIndex)
                                 : proj.GetVideoClipAtIndex(curClipIndex);
         if (clip == null)
         {
             editor.AppendToConsole(VidkaConsoleLogLevel.Info, "Nothing to play!");
             return;
         }
         // ... set up mutex
         mutex.Proj            = proj;
         mutex.OnlyLockedClips = onlyLockedClips;
         mutex.IsPlaying       = true;
         mutex.CurClipIndex    = curClipIndex;
         mutex.CurFrame        = frameStart;
         StartPlaybackOfClip(clip, frameOffset);
         // ... set up ticker
         ticker.Interval = (int)(1000 * proj.FrameToSec(1));                 // 1 tick per frame... its a hack but im too lazy
         ticker.Start();
         editor.AppendToConsole(VidkaConsoleLogLevel.Debug, "StartPlayback");
     }
 }
Exemplo n.º 2
0
        private void drawVideoClip(Graphics g,
                                   VidkaClipVideo vclip,
                                   long curFrame, int y1, int cliph, int clipvh,
                                   Brush brushClip,
                                   VidkaProj proj,
                                   VidkaFileMapping projMapping,
                                   ProjectDimensions dimdim)
        {
            int x1    = dimdim.convert_Frame2ScreenX(curFrame);
            int x2    = dimdim.convert_Frame2ScreenX(curFrame + vclip.LengthFrameCalc);
            int clipw = x2 - x1;

            // active video clip deserves a special outline, fill white otherwise to hide gray background
            g.FillRectangle(brushClip, x1, y1, clipw, clipvh);
            DrawClipBitmaps(
                g: g,
                proj: proj,
                projMapping: projMapping,
                vclip: vclip,
                x1: x1,
                y1: y1,
                clipw: clipw,
                clipvh: clipvh,
                secStart: proj.FrameToSec(vclip.FrameStart),
                len: proj.FrameToSec(vclip.LengthFrameCalc));
            DrawWaveform(g, proj, projMapping, vclip, x1, y1 + clipvh, clipw, cliph - clipvh,
                         proj.FrameToSec(vclip.FrameStart), proj.FrameToSec(vclip.FrameEnd));
            if (vclip.IsMuted)
            {
                g.FillRectangle(brushHazyMute, x1, y1 + clipvh, x2 - x1, cliph - clipvh);
            }
            // waveform separator
            g.DrawLine(penGray, x1, y1 + clipvh, x2, y1 + clipvh);
            // outline rect
            g.DrawRectangle(penDefault, x1, y1, clipw, cliph);
            // still analyzing...
            if (vclip.IsNotYetAnalyzed)
            {
                g.DrawString("Still analyzing...", fontDefault, brushDefault, x1 + 5, y1 + 5);
            }
        }
Exemplo n.º 3
0
        public void DrawTimeAxis(Graphics g, ProjectDimensions dimdim, int w, int h, VidkaProj proj)
        {
            // compute how many segments/ticks/etc to draw
            var  frameStart        = dimdim.convert_ScreenX2Frame(0);
            var  frameEnd          = dimdim.convert_ScreenX2Frame(w);
            int  nSegments         = w / Settings.Default.MinnimumTimelineSegmentSizeInPixels;
            long framesPerSegment  = (frameEnd - frameStart) / nSegments;
            int  secondsPerSegment = (int)(framesPerSegment / proj.FrameRate);

            secondsPerSegment = Utils.GetClosestSnapToSecondsForTimeAxis(secondsPerSegment);
            if (secondsPerSegment == 0)             // we are zoomed in so much, but still show seconds
            {
                secondsPerSegment = 1;
            }
            // now that everything is rounded, how many segments do we really have?
            var actualFramesPerSegment = secondsPerSegment * proj.FrameRate;
            var actualNSegments        = (int)((frameEnd - frameStart) / actualFramesPerSegment);
            var startingSecond         = (long)Math.Floor(proj.FrameToSec(frameStart));

            // compute dimensions...
            var y1 = h - dimdim.getY_timeAxisHeight(h);
            var y2 = h;

            g.DrawLine(penGray, 0, y1, w, y1);
            for (var i = 0; i < actualNSegments + 1; i++)
            {
                var curSecond = startingSecond + i * secondsPerSegment;
                var scrX      = dimdim.convert_Sec2ScreenX(curSecond);
                var ts        = TimeSpan.FromSeconds(curSecond);
                g.DrawLine(penGray, scrX, y1, scrX, y2);
                g.DrawString(ts.ToString_MinuteOrHour(), fontDefault, brushDefault, scrX + 2, y1 + 4);
            }
            if (secondsPerSegment == 1 && framesPerSegment <= proj.FrameRate)
            {
                // draw frame ticks as well
                for (var i = frameStart; i < frameEnd; i++)
                {
                    var scrX = dimdim.convert_Frame2ScreenX(i);
                    g.DrawLine(penGray, scrX, y1, scrX, y1 + 3);
                }
            }
        }