Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET Java
Hello,
I am working on a website which require video uploading and displaying. Uploading, buffering and playing is completed but I want to display the video thumbnails in my Gallery also. How it can be done? I think I should create the thumbnails at uploading time. But how to create thumbnails at upload time, I dont know. Answer this please.....
Posted 15-Feb-12 23:53pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Hi, I didn't try it with ASP yet, but MediaDetector should be the right way for you. If you don't won't to use
a 3rd library, you'll almost have no other options than using DShow or DirectX.
 

Something like this in a BackgroundWorker:
 
FileInfo finfo = new FileInfo(@"PATH TO TESTFILE");
                
if(string.Compare(finfo.Extension, ".avi", true) == 0 || string.Compare(finfo.Extension, ".mpg", true) == 0 || string.Compare(finfo.Extension, ".wmv", true) == 0)
{
                    string thumb_path = finfo.FullName + ".jpg";
                    if (File.Exists(thumb_path) != true)
                    {
                        MediaDetector capture_thumb = new MediaDetector();
                        capture_thumb.LoadMedia(finfo.FullName);
                        
                        int width = 128;
                        int height = width;
                        int stride = width / 8;
                        byte[] pixels = new byte[height * width];
 
                        // Define the Bitmap palette
                        BitmapPalette myPalette = BitmapPalettes.Halftone256;
 
                        // Creates a new empty image with palette settings
                        BitmapSource image =
                            BitmapSource.Create(
                            width,
                            height,
                            96,
                            96,
                            PixelFormats.Indexed1,
                            myPalette,
                            pixels,
                            stride);
 

                        Stream stream = new FileStream(finfo.FullName + ".jpg", FileMode.Create);
                        JpegBitmapEncoder encoder = new JpegBitmapEncoder();
                        encoder.FlipHorizontal = false;
                        encoder.FlipVertical = false;
                        encoder.QualityLevel = 80;
                        
 encoder.Frames.Add(BitmapFrame.Create(capture_thumb.GetImage(new TimeSpan(0, 0, 30))));
                        encoder.Save(stream);
                       
                  }
} 
 
Cheers,
Bjoern
  Permalink  
v5
Comments
NeptuneHACK! at 16-Feb-12 20:58pm
   
5
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Hi there..
 
Try visiting this website.. I think this will be very much important..
http://jasonjano.wordpress.com/2010/02/09/a-simple-c-wrapper-for-ffmpeg/[^]
 
All the best.. Smile | :)
  Permalink  
v2
Comments
ProEnggSoft at 25-Feb-12 3:17am
   
Good link.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 120
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,611
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 25 Feb 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100