Jump to content

Get first frame of Video


Recommended Posts

You need an external tool !

See FFMPEG command line tool ! Posted Image

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.jpeg

This 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 by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

I modify it for get only the first frame ! Posted Image

#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 by wakillon

AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...