DS捕捉摄像头视频 
怎么把音频文件附加到视频里?
RenderStream 可以附加话筒音频到视频 里
我现在想做的是把硬盘里的音频 文件附加到视频里.

解决方案 »

  1.   

    高手帮忙:http://topic.csdn.net/u/20100510/09/50a51ee4-acd1-4254-88c3-c8c0b390f42f.html
      

  2.   

    up这里发言,表示您接受了CSDN社区的用户行为准则。
      

  3.   


    RenderStream不是也要制定Source的输出pin么?
    加入一个source加载你这个音频文件然后RenderStream从这个source的输出pin开始,截止端不变
      

  4.   

    谢谢
    我现在不知道怎么把 Wav 音频文件读入处理成 和 IBaseFilter 兼容的接口
    因为 ICaptureGraphBuilder 的 RenderStream 接受的参数是 IBaseFilter 接口的
    再就是 能同时录入 话筒声音 吗? 和这Wav文件 混合.
    就是K歌
      

  5.   

    用这个SDK包好了:http://www.anychat.cn
      

  6.   

    uses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ComCtrls, ExtCtrls, Menus, ImgList, DSPack, DSUtil, DirectShow9, ToolWin, ActnList,
      jpeg;
    procedure Tfrm_Main.VMRTextOut(AText: string);
    var
      VMRBitmap: TVMRBitmap;
    begin
      if AText = '' then exit;
      VMRBitmap := TVMRBitmap.Create(VideoWindow1);
      with VMRBitmap, Canvas do
      begin
        LoadEmptyBitmap(VideoWindow1.Width, VideoWindow1.Height, pf24bit, clSilver);
        Source := VMRBitmap.Canvas.ClipRect;
        Options := VMRBitmap.Options + [vmrbSrcColorKey];
        ColorKey := clSilver;
        Brush.Color := clSilver;
        Font := frm_Option.AFont;
        TextOut(0, 0, AText);
        DrawTo(0, 0, 1, 1, 0.5);
      end;
      VMRBitmap.Free;
    end;procedure Tfrm_Main.A_PlayExecute(Sender: TObject);
    var
      Multiplexer: IBaseFilter;
      Writer: IFileSinkFilter;
      PinList: TPinList;
      i: integer;
      FSize: TPoint;
    begin
      with frm_Option do
      begin
        if CB_VideoFormats.ItemIndex <> -1 then
        begin
          FSize := GetMediaTypeOfSize(VideoMediaTypes.Items[CB_VideoFormats.ItemIndex].AMMediaType^);
          if FSize.X <> 0 then
            frm_Main.Width := FSize.X + 8;
          if FSize.Y <> 0 then
            frm_Main.Height := FSize.Y + 94;
        end;
        FilterGraph.Mode := gmCapture;
        FilterGraph.Active := true;
        if AudioSourceFilter.FilterGraph <> nil then
        begin
          PinList := TPinList.Create(AudioSourceFilter as IBaseFilter);
          i := 0;
          while i < PinList.Count do
            if PinList.PinInfo[i].dir = PINDIR_OUTPUT then
            begin
              if CB_AudioFormats.ItemIndex <> -1 then
                with (PinList.Items[i] as IAMStreamConfig) do
                  SetFormat(AudioMediaTypes.Items[CB_AudioFormats.ItemIndex].AMMediaType^);
              PinList.Delete(i);
            end else inc(i);
          if CB_InputLines.ItemIndex <> -1 then
            with (PinList.Items[CB_InputLines.ItemIndex] as IAMAudioInputMixer) do
              put_Enable(true);
          PinList.Free;
        end;
        if VideoSourceFilter.FilterGraph <> nil then
        begin
          PinList := TPinList.Create(VideoSourceFilter as IBaseFilter);
          if CB_VideoFormats.ItemIndex <> -1 then
            with (PinList.First as IAMStreamConfig) do
              SetFormat(VideoMediaTypes.Items[CB_VideoFormats.ItemIndex].AMMediaType^);
          PinList.Free;
        end;
        with FilterGraph as IcaptureGraphBuilder2 do
        begin
          if VideoSourceFilter.BaseFilter.DataLength > 0 then
            RenderStream(@PIN_CATEGORY_PREVIEW, nil, VideoSourceFilter as IBaseFilter,
              nil, VideoWindow1 as IBaseFilter);
          if A_Capture.Checked then
          begin
            SetOutputFileName(MEDIASUBTYPE_Avi, PWideChar(CapFName), Multiplexer, Writer);
            if VideoSourceFilter.FilterGraph <> nil then
              RenderStream(@PIN_CATEGORY_CAPTURE, nil, VideoSourceFilter as IBaseFilter,
                nil, Multiplexer as IBaseFilter);
            if AudioSourceFilter.FilterGraph <> nil then
            begin
              RenderStream(nil, nil, AudioSourceFilter as IBaseFilter,
                nil, Multiplexer as IBaseFilter);
            end;
          end;
        end;
        FilterGraph.Play;
        VMRTextOut(frm_Option.E_Text.Text); //字幕
        Timer1.Enabled := true;
      end;
      A_Play.Checked := True;
      A_Capture.Enabled := True;
    end;procedure Tfrm_Main.A_StopExecute(Sender: TObject);
    begin
      Timer1.Enabled := False;
      A_Play.Checked := False;
      frm_Option.FilterGraph.Stop;
      frm_Option.FilterGraph.Active := False;
      
      VideoWindow1.Canvas.Lock;
      try
        VideoWindow1.Canvas.StretchDraw(VideoWindow1.Canvas.ClipRect, Image1.Picture.Graphic);
      finally
        VideoWindow1.Canvas.Unlock;
      end;
    end;