Click here to Skip to main content
15,883,984 members
Home / Discussions / C#
   

C#

 
GeneralRe: how to know which control is focused Pin
Programm3r22-Sep-09 21:57
Programm3r22-Sep-09 21:57 
AnswerRe: how to know which control is focused Pin
Programm3r22-Sep-09 21:38
Programm3r22-Sep-09 21:38 
AnswerRe: how to know which control is focused Pin
benjymous22-Sep-09 23:30
benjymous22-Sep-09 23:30 
AnswerRe: how to know which control is focused Pin
Henry Minute23-Sep-09 1:20
Henry Minute23-Sep-09 1:20 
Questionget GUID from Assembly Information Pin
Jassim Rahma22-Sep-09 20:56
Jassim Rahma22-Sep-09 20:56 
AnswerRe: get GUID from Assembly Information Pin
Ravi Mori22-Sep-09 21:00
Ravi Mori22-Sep-09 21:00 
AnswerRe: get GUID from Assembly Information Pin
0x3c022-Sep-09 23:42
0x3c022-Sep-09 23:42 
QuestionIBasicVideo2 GetCurrentImage returns black frames Pin
smilefishcc22-Sep-09 20:45
smilefishcc22-Sep-09 20:45 
I want to extract frames from video files without playing them. I used the GetCurrentImage of IBasicVideo2 to extract frames of videos as thumbnails of them. I Successfully extracted frames from video files of the format of WMV, AVI, DAT, ASF except MPG and VOB. When I extract frames of MPG and VOB files, It returns black frames.(The frames extracted are Successfully saved as bmp image files on my pc. however, they are all black frames.) Why??Confused | :confused:

Here is my code:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Runtime.InteropServices;
using System.Drawing;
using System.Drawing.Imaging;
using DShowNet;
using QuartzTypeLib;

namespace test2
{
/// <summary>
/// Window1.xaml 的交互逻辑
/// </summary>
public partial class Window1 : Window
{


public Window1()
{
InitializeComponent();
}

private void Window_Loaded(object sender, RoutedEventArgs e)
{
string videoFileName = "d:\\aaaa\\《OVER IT》MV.MPG";
string bitmapFileName = "d:\\《OVER IT》MV.MPG.bmp";
GetThumbnail(videoFileName, bitmapFileName);
}

private bool GetThumbnail(string videoFileName, string bitmapFileName)
{

FilgraphManagerClass filgraph = new FilgraphManagerClass();


try
{

filgraph.RenderFile(videoFileName);


filgraph.CurrentPosition = filgraph.Duration / 2;


int width = filgraph.SourceWidth;


int height = filgraph.SourceHeight;


int pBufferSize = 0;

DShowNet.IBasicVideo2 video = (DShowNet.IBasicVideo2)filgraph;

video.GetCurrentImage(ref pBufferSize, IntPtr.Zero);

IntPtr pDIBImage = Marshal.AllocHGlobal(pBufferSize);


video.GetCurrentImage(ref pBufferSize, pDIBImage);


int stride = -4 * width;


System.Drawing.Imaging.PixelFormat format = System.Drawing.Imaging.PixelFormat.Format32bppRgb;


IntPtr scan0 = (IntPtr)(((int)pDIBImage) + (pBufferSize - (4 * width)));


Bitmap bmp = new Bitmap(width, height, stride, format, scan0);


bmp.Save(bitmapFileName);


Marshal.FreeHGlobal(pDIBImage);
}
catch
{

return false;
}


while (Marshal.ReleaseComObject(filgraph) > 0) ;
return true;

}

}
}

BR,
Smilefishcc
QuestionTest Cases for the Code Pin
jpk42022-Sep-09 20:36
jpk42022-Sep-09 20:36 
AnswerRe: Test Cases for the Code Pin
Richard MacCutchan22-Sep-09 22:59
mveRichard MacCutchan22-Sep-09 22:59 
AnswerRe: Test Cases for the Code Pin
N a v a n e e t h23-Sep-09 0:18
N a v a n e e t h23-Sep-09 0:18 
QuestionODBC Data Error Pin
sateesh villa22-Sep-09 20:35
sateesh villa22-Sep-09 20:35 
QuestionAccessing Non-Public Members [modified] Pin
John Jak22-Sep-09 20:15
John Jak22-Sep-09 20:15 
QuestionSkins in C# Pin
vivasaayi22-Sep-09 19:11
vivasaayi22-Sep-09 19:11 
AnswerRe: Skins in C# Pin
egenis22-Sep-09 19:25
egenis22-Sep-09 19:25 
GeneralRe: Skins in C# Pin
vivasaayi22-Sep-09 19:52
vivasaayi22-Sep-09 19:52 
GeneralRe: Skins in C# Pin
Ravi Mori22-Sep-09 20:00
Ravi Mori22-Sep-09 20:00 
GeneralRe: Skins in C# Pin
vivasaayi22-Sep-09 20:33
vivasaayi22-Sep-09 20:33 
GeneralRe: Skins in C# Pin
egenis22-Sep-09 20:36
egenis22-Sep-09 20:36 
QuestionNeed help with updating SQL server express DB from c# Pin
Mark-12345678922-Sep-09 16:15
Mark-12345678922-Sep-09 16:15 
Answerrepost Pin
Luc Pattyn22-Sep-09 16:29
sitebuilderLuc Pattyn22-Sep-09 16:29 
AnswerRe: Need help with updating SQL server express DB from c# Pin
Michael Eber22-Sep-09 18:53
Michael Eber22-Sep-09 18:53 
GeneralRe: Need help with updating SQL server express DB from c# Pin
Mark-12345678923-Sep-09 2:43
Mark-12345678923-Sep-09 2:43 
GeneralRe: Need help with updating SQL server express DB from c# Pin
PIEBALDconsult23-Sep-09 5:12
mvePIEBALDconsult23-Sep-09 5:12 
GeneralRe: Need help with updating SQL server express DB from c# - Done IT! Pin
Mark-12345678924-Sep-09 9:02
Mark-12345678924-Sep-09 9:02 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.