我想用dsPack在视频上叠加滚动字幕。
  在Mixer例子中用到的FilterGraph.RenderFile,可在视频上叠加一个gif或者另一个视频文件,强!不知道还可以叠加其他什么文件?
  另外,在VMRBitmap例子中用到的Filter.BaseFilter.Moniker,可以在视频上叠加一个bmp图片,或者把文字画成bmp叠加上去,我想做一个滚动的字幕,就用了一个Timer,定时重画,然而出来一帧过后,后面的图片就不出来了,请教大虾们如何解决该问题。
  或是有其它什么办法,在视频上叠加上滚动字幕呢?谢谢!

解决方案 »

  1.   

    有了dsPack还有什么办不到得?很容易啊;你打开SampleGrabber 这个demo ;然后按我添加代码得位置修改代码如下即可达到你得目的:var
      Form1             : TForm1;
      OffsetX           : Integer;          //by s.f.
    const
      ShowText          : string = '字幕啊字幕啊字幕啊字幕啊字幕啊'; //by s.f.
    implementation{$R *.dfm}procedure TForm1.OpenPlayClick(Sender: TObject);
    begin
      if OpenDialog.Execute then
      begin
        OffsetX := Image.Width;             //by s.f.    FilterGraph.Mode := gmCapture;
        FilterGraph.Active := False;
        FilterGraph.Active := true;    FilterGraph.RenderFile(OpenDialog.FileName);
        FilterGraph.Play;  end;
    end;procedure TForm1.VMRTextOut(AText: string);
    var
      VMRBitmap         : TVMRBitmap;
    begin
      if AText = '' then
        exit;end;procedure TForm1.SnapshotClick(Sender: TObject);
    begin
      SampleGrabber.GetBitmap(Image.Picture.Bitmap)
    end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
    begin
      CallBack.Checked := false;
      FilterGraph.ClearGraph;
      FilterGraph.Active := false;
    end;procedure TForm1.SampleGrabberBuffer(sender: TObject; SampleTime: Double;
      pBuffer: Pointer; BufferLen: Integer);
    var
      textLength        : integer;          //by s.f.
    begin
      if CallBack.Checked then
      begin
        Image.Canvas.Lock;                  // to avoid flickering
        try
          SampleGrabber.GetBitmap(Image.Picture.Bitmap, pBuffer, BufferLen);
          //draw my text.by s.f.
          textLength := Image.Picture.Bitmap.Canvas.TextWidth(ShowText);
          if (OffsetX + textLength) > 0 then
          begin
            Image.Picture.Bitmap.Canvas.Brush.Style := bsClear;
            Image.Picture.Bitmap.Canvas.Font.Color := clRed;
            Image.Picture.Bitmap.Canvas.TextOut(OffsetX, 10, ShowText);
            Dec(OffsetX, 1);
          end;    finally
          Image.Canvas.Unlock;
        end;
      end;
    end;
    原理再容易不过了,因为CallBack后,可以直接绘制视频到canvas上,这样可以对这个canvas进行操作,你加什么东西都行。