2014-08-31 6 views
0

우선 재생 및 HD 비디오 (1920x1080), 카메라 해상도를 1920x1080 프로그램 표시 및 검정색 배경으로 변경하면 카메라 해상도가 720x576 경우 문제없이 작동합니다. . 문제가 내 솔루션에 있다고 확신합니다. Blackmagic Decklink Studio 2에 포함 된 DesktopVideo를 사용할 때 카메라의 HD 비디오를 보여주기 때문입니다. 둘째, 어떻게 AForge로 비디오를 변환합니까? 해상도 및 프레임 레이트 변경과 같이 코덱 및 비트 전송률을 변경할 수 있지만 "FileWriter.Open"에서 Resolution 및 FrameRate를 변경하면 명령에서 오류 해상도가 표시되고 FrameRate가 Bitmap과 같아야합니다. 카메라에서 캡처하고 있습니다.AF 변환 및 문제와 HD

누구든지 이러한 문제를 해결하는 방법을 알고 있다면 정보를 공유해주세요. 감사합니다!

여기서 코드

using System; 

using System.Collections.Generic; 

using System.ComponentModel; 

using System.Data; 

using System.Drawing; 
using System.Linq; 
using System.Text; 
using System.Windows.Forms; 
using AForge.Video; 
using AForge.Video.DirectShow; 
using AForge.Video.FFMPEG; 
using AForge.Video.VFW; 

namespace WindowsFormsApplication12 
{ 
    public partial class Form1 : Form 
    { 
     private FilterInfoCollection VideoCaptureDevices; 

     private VideoCaptureDevice FinalVideo = null; 
     private VideoCaptureDeviceForm captureDevice; 
     private Bitmap video; 
     //private AVIWriter AVIwriter = new AVIWriter(); 
     private VideoFileWriter FileWriter = new VideoFileWriter(); 
     private SaveFileDialog saveAvi; 
     public Form1() 
     { 
      InitializeComponent(); 
     } 

     private void Form1_Load(object sender, EventArgs e) 
     { 


      VideoCaptureDevices = new FilterInfoCollection(FilterCategory.VideoInputDevice); 
      captureDevice = new VideoCaptureDeviceForm(); 
     } 

     private void button1_Click(object sender, EventArgs e) 
     { 
      /////capture device list 
      if (captureDevice.ShowDialog(this) == DialogResult.OK) 
      { 

       VideoCaptureDevice videoSource = captureDevice.VideoDevice; 
       FinalVideo = captureDevice.VideoDevice; 
       FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame); 
       FinalVideo.Start(); 
      } 
     } 
     void FinalVideo_NewFrame(object sender, NewFrameEventArgs eventArgs) 
     { 
      if (butStop.Text == "Stop Record") 
      { 
       video = (Bitmap)eventArgs.Frame.Clone(); 
       pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone(); 
       //AVIwriter.Quality = 0; 
       FileWriter.WriteVideoFrame(video); 
       //AVIwriter.AddFrame(video); 
      } 
      else 
      { 
       video = (Bitmap)eventArgs.Frame.Clone(); 
       pictureBox1.Image = (Bitmap)eventArgs.Frame.Clone(); 
      } 
     } 

     private void button2_Click(object sender, EventArgs e) 
     { 
      ////record button 
      saveAvi = new SaveFileDialog(); 
      saveAvi.Filter = "Avi Files (*.avi)|*.avi"; 
      if (saveAvi.ShowDialog() == System.Windows.Forms.DialogResult.OK) 
      { 
       int h = captureDevice.VideoDevice.VideoResolution.FrameSize.Height; 
       int w = captureDevice.VideoDevice.VideoResolution.FrameSize.Width; 
       FileWriter.Open(saveAvi.FileName, w, h,25,VideoCodec.Default,5000000); 
       FileWriter.WriteVideoFrame(video); 

       //AVIwriter.Open(saveAvi.FileName, w, h); 
       butStop.Text = "Stop Record"; 
       //FinalVideo = captureDevice.VideoDevice; 
       //FinalVideo.NewFrame += new NewFrameEventHandler(FinalVideo_NewFrame); 
       //FinalVideo.Start(); 
      } 
     } 

     private void butStop_Click(object sender, EventArgs e) 
     { 
      if (butStop.Text == "Stop Record") 
      { 
       butStop.Text = "Stop"; 
       if (FinalVideo == null) 
       { return; } 
       if (FinalVideo.IsRunning) 
       { 
        //this.FinalVideo.Stop(); 
        FileWriter.Close(); 
        //this.AVIwriter.Close(); 
        pictureBox1.Image = null; 
       } 
      } 
      else 
      { 
       this.FinalVideo.Stop(); 
       FileWriter.Close(); 
       //this.AVIwriter.Close(); 
       pictureBox1.Image = null; 
      } 
     } 

     private void button3_Click(object sender, EventArgs e) 
     { 
      pictureBox1.Image.Save("IMG" + DateTime.Now.ToString("hhmmss") + ".jpg"); 
     } 

     private void button4_Click(object sender, EventArgs e) 
     { 
      this.Close(); 
     } 

     private void Form1_FormClosing(object sender, FormClosingEventArgs e) 
     { 
      if (FinalVideo == null) 
      { return; } 
      if (FinalVideo.IsRunning) 
      { 
       this.FinalVideo.Stop(); 
       FileWriter.Close(); 
       //this.AVIwriter.Close(); 
      } 
     } 


    } 
} 

답변

0

제공된 코드 단순히 캡처하고 캡처 장치 선정 현재 활성 포맷 /에 저장된다. 일반적으로 해상도 변경은 "비싼"작업이므로 무료 작업으로 사용할 수 없습니다.

캡쳐 장치를보다 적합한 형식으로 전환하여 해상도를 변경 한 다음이 해상도로 캡처하고 모든 추가 데이터 조작을 올바른 해상도로 수행하려고합니다. 사용 가능한 해상도 및 옵션은 해당 하드웨어에서만 가능합니다.

적절한 캡처 해결 옵션을 사용할 수없는 경우 일반적으로 비디오를 새 해상도로 다시 샘플링합니다. Windows API에는 적절한 기능이 있지만 특수한 경우에는이 라이브러리를 AForge 라이브러리와 통합하고 해당 설명서를 확인하여 해당 래퍼가 제공되는지 여부와 캡쳐 프로세스 전반에 통합 될 수 있는지 여부를 확인해야합니다. 스케일링을 처리하려면이 코드를 직접 작성해야합니다.

+0

아무 것도 변환하지 않을 것입니다. HD에서 캡처 장치 (카메라)의 옵션을 FullHD로 변경하면 검은 색 화면이 표시되고 HD 일 때는 제대로 작동합니다. –

+0

구성이 신호 소스 및/또는 형식과 일치하지 않으면 Blackmagic 장치가 검정색을 표시합니다. 원본 필터를 올바르게 설정해야합니다 (올바른 해상도, 프로그래밍 방식으로 소스를 수정하거나이 장치의 제어판에서 각각의 기본값을 변경해야합니다). 데스크톱 비디오가 정상적으로 작동한다고해서 필터를 사용하여 비디오를 캡처 할 수있는 것은 아닙니다. 데스크톱 비디오는 사용자가 사용하는 필터를 사용하지 않고 대신 캡처를 위해 DeckLink SDK를 공유하고 Blackmagic은 이미 사용중인 DirectShow 인터페이스를 더 이상 사용하지 않습니다. –