While working on a video content management system, I was in need of capturing frames from video files so they can be used as a preview for video. The system already had some code in place but it only worked for video encoding in Windows Media format (.wmv extension). That would not do, I thought, not in this day and age when we have so many file formats and video codecs. So I need to able to:
Stolen directly from the Information [1] page of MPlayer, "MPlayer is a movie player which runs on many systems (see the documentation). It plays most MPEG/VOB, AVI, Ogg/OGM, VIVO, ASF/WMA/WMV, QT/MOV/MP4, RealMedia, Matroska, NUT [2], NuppelVideo, FLI, YUV4MPEG, FILM, RoQ, PVA files, supported by many native, XAnim, and Win32 DLL codecs. You can watch VideoCD, SVCD, DVD, 3ivx, DivX 3/4/5 and even WMV movies..". To add my own description, MPlayer is an open source command line video player.
Metallica has an old song called "So What", great tune for the metal heads in all of us. The answer is simple, MPlayer can do a lot more than play video. It can capture images, stream video over http and even transcode video from one format to another (but the last feature is grounds for another article).
You will need:
// Specify the path to the video file string videoFilePath = @"drive letter:\path\to\myVideo.mpg"; // Declare the mplayer instance with the mplayer executable residing in the // same directory as your executable mPlayerWrapper mPlayerInstance = new mPlayerWrapper(); // Capture frames mPlayerInstance.captureFrames(videoFilePath);
' Specify the path to the video file dim videoFilePath As String = "drive letter:\path\to\myVideo.mpg" ' Declare the mplayer instance with the mplayer executable residing in the ' same directory as your executable dim mPlayerInstance As new mPlayerWrapper() ' Capture frames mPlayerInstance.captureFrames(videoFilePath)
// Specify the path to the video file string videoFilePath = @"drive letter:\path\to\myVideo.mpg"; // Specify the output directory string outputPath = @"drive letter:\path\to\output directory"; // Declare the mplayer instance with the mplayer executable residing in the // same directory as your executable mPlayerWrapper mPlayerInstance = new mPlayerWrapper(); // Capture frames mPlayerInstance.captureFrames(videoFilePath, outputPath);
' Specify the path to the video file dim videoFilePath As String = "drive letter:\path\to\myVideo.mpg" ' Specify the output directory dim outputPath As String = @"drive letter:\path\to\output directory" ' Declare the mplayer instance with the mplayer executable residing in the ' same directory as your executable dim mPlayerInstance As new mPlayerWrapper() ' Capture frames mPlayerInstance.captureFrames(videoFilePath, outputDirectory)
mPlayerWrapper: http://blog.tech-cats.net/examples/dotnet/mPlayerWrapper.dll [5]
mPlayerWrapper Source: http://blog.tech-cats.net/examples/dotnet/mplayerWrapper-v0.1.zip [6]
Links:
[1] http://www.mplayerhq.hu/design7/info.html
[2] http://www.nut-container.org
[3] http://www.mplayerhq.hu/design7/dload.html
[4] http://www.mplayerhq.hu/design7/dload.html
[5] http://blog.tech-cats.net/examples/dotnet/mPlayerWrapper.dll
[6] http://blog.tech-cats.net/examples/dotnet/mplayerWrapper-v0.1.zip
[7] http://blog.tech-cats.com/2008/03/how-to-extract-video-still-frames-with.html