Hello there, guys from all over the world... I need your help a little. It's about DexterLib and MediaDet Class. Every tutorial, or article on the internet suggested that this should be the solution for me to export a frame from a movie into a Bitmap object. But I can't. The code I copied the code character by character and still does not work. Do you have any ideas? What u have below is the exporting to byte array with GetBitmapBits() function
using System;
using System.Collections.Generic;
using System.Text;
using DexterLib;
using System.Drawing;
using System.Drawing.Imaging;
using System.Runtime.InteropServices;
namespace mediad
{
class Program
{
public static Guid MEDIATYPE_Video = new Guid(0x73646976, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);
static void Main(string[] args)
{
System.Console.WriteLine("** MediaD test app //");
MediaDetClass md = new MediaDetClass();
_AMMediaType mt;
bool found = false;
md.Filename = "e:\\torrents\\Evanescence - Bring Me To Life.avi";
int streamsNumber = md.OutputStreams;
for (int i = 0; i < streamsNumber; i++)
{
md.CurrentStream = i;
mt = md.StreamMediaType;
if (mt.majortype == MEDIATYPE_Video) found = true;
}
if (!found) Console.WriteLine("File \""+md.Filename+"\" does not have video stream.");
else
{
Console.WriteLine("Video stream found. Moving forward...");
unsafe
{
int size = 0;
byte* buff = null;
try
{
md.GetBitmapBits(5.3, ref size, ref *buff, 640, 480);
Console.WriteLine("Buffer size found: " + size.ToString());
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
try
{
buff = (byte*)Marshal.AllocHGlobal(size);
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
try
{
md.GetBitmapBits(md.StreamLength * 0.3, ref size, ref *buff, 640, 480);
Console.WriteLine("Frame loaded");
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
}
}
}
}
}
}