thitgaluoc Posted May 3, 2011 Share Posted May 3, 2011 How to get first frame of Video file after save to file jpg? Thank you I'm Vietnamese so my E not good, sory ^^ Link to comment Share on other sites More sharing options...
wakillon Posted May 3, 2011 Share Posted May 3, 2011 Welcome to the forums !Look at this ! AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
thitgaluoc Posted May 3, 2011 Author Share Posted May 3, 2011 But i don't want a software I need What is func to do that ? Thank you. Link to comment Share on other sites More sharing options...
wakillon Posted May 3, 2011 Share Posted May 3, 2011 (edited) You need an external tool !See FFMPEG command line tool ! You can extract images from a video, or create a video from many images:For extracting images from a video:ffmpeg -i foo.avi -r 1 -s WxH -f image2 foo-%03d.jpegThis will extract one video frame per second from the video and will output them in files named `foo-001.jpeg', `foo-002.jpeg', etc. Images will be rescaled to fit the new WxH values.If you want to extract just a limited number of frames, you can use the above command in combination with the -vframes or -t option, or in combination with -ss to start extracting from a certain point in time. Edited May 3, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
wakillon Posted May 3, 2011 Share Posted May 3, 2011 (edited) An AutoIt example with ffmpeg by eukalyptus Edited July 11, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
thitgaluoc Posted May 3, 2011 Author Share Posted May 3, 2011 Thank you very much! Link to comment Share on other sites More sharing options...
wakillon Posted May 3, 2011 Share Posted May 3, 2011 (edited) I modify it for get only the first frame ! #include <WindowsConstants.au3> #include <GdiPlus.au3> #include <Misc.au3> #include <Date.au3> If Not _Singleton ( @ScriptName, 1 ) Then Exit Global $_JpegPath _GDIPlus_Startup ( ) DirRemove ( @ScriptDir & "\FFMpegThumbTemp", 1 ) DirCreate ( @ScriptDir & "\FFMpegThumbTemp" ) $sMovieFile = FileOpenDialog ( '', @DesktopDir & "\", "Videos (*.avi;*.flv;*.mp4)", 1 + 4 ) _CreateThumbnails ( $sMovieFile ) _GDIPlus_Shutdown ( ) ShellExecute ( $_JpegPath ) Exit Func _CreateThumbnails ( $sMovieFile ) Local $tempGraph = _GDIPlus_GraphicsCreateFromHWND ( _WinAPI_GetDesktopWindow ( ) ) Local $hBitmap = _GDIPlus_BitmapCreateFromGraphics ( 520, 400, $tempGraph ) _GDIPlus_GraphicsDispose ( $tempGraph ) Local $hGraphics = _GDIPlus_ImageGetGraphicsContext ( $hBitmap ), $hImage _GDIPlus_GraphicsClear ( $hGraphics, 0xFFFFFFFF ) RunWait ( '"' & @ScriptDir & '\ffmpeg.exe" -vframes 1 -ss 00:00:01 -i "' & $sMovieFile & '" -s 500×380 -an -y "' & @ScriptDir & '\FFMpegThumbTemp\1.jpg"', @ScriptDir, @SW_HIDE ) $hImage = _GDIPlus_ImageLoadFromFile ( @ScriptDir & "\FFMpegThumbTemp\1.jpg" ) _GDIPlus_GraphicsDrawImage ( $hGraphics, $hImage, 10, 10 ) _GDIPlus_ImageDispose ( $hImage ) $_JpegPath = StringLeft ( $sMovieFile, StringInStr ( $sMovieFile, ".", 0, -1 ) ) & 'jpg' _GDIPlus_ImageSaveToFile ( $hBitmap, $_JpegPath ) _GDIPlus_BitmapDispose ( $hBitmap ) _GDIPlus_GraphicsDispose ( $hGraphics ) EndFunc ;==> _CreateThumbnails ( ) Edited July 11, 2011 by wakillon AutoIt 3.3.14.2 X86 - SciTE 3.6.0 - WIN 8.1 X64 - Other Example Scripts Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now