Created
July 14, 2010 17:33
-
-
Save JoshMock/475714 to your computer and use it in GitHub Desktop.
Recurses through directories and creates a screen capture for each FLV video file and outputs as a JPG.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
' Results: Recurses through all subdirectories of FOLDER_TO_SCAN and finds all .FLV files that do not have an associated JPG splash image, then creates one 5 seconds into the video using FFMPEG command line tool. | |
' Assumes: FFMPEG (http://ffmpeg.org) command line tool is installed and its install directory is in the system Path variable. | |
Dim FOLDER_TO_SCAN | |
FOLDER_TO_SCAN = "C:\Folder\to\scan\" | |
Dim fso, rootFolder, convertedCount | |
Set fso = CreateObject("Scripting.FileSystemObject") | |
Set rootFolder = fso.GetFolder(FOLDER_TO_SCAN) | |
convertedCount = 0 | |
GetFolders rootFolder ' Starts recursive file traversal that looks for all FLV files with no associated JPG | |
Set rootFolder = Nothing | |
Set fso = Nothing | |
MsgBox "Created preview images for " & convertedCount & " files." | |
Sub GetFolders(thisFolder) | |
GenerateSplashImages(thisFolder) | |
For Each subfolder In thisFolder.SubFolders | |
'Recurse to next level of folders | |
GetFolders(subfolder) | |
Next | |
End Sub | |
Sub GenerateSplashImages(thisFolder) | |
For Each file In thisFolder.Files | |
Dim fileName, filePath | |
fileName = file.Name | |
filePath = file.Path | |
' Only checking on FLV files | |
If (Right(fileName, 4) = ".flv") Then | |
' Create .jpg version of file name | |
Dim strSplashImagePath | |
strSplashImagePath = Left(filePath, Len(filePath) - 4) & ".jpg" | |
If Not fso.FileExists(strSplashImagePath) Then | |
' Generate splash file using FFMPEG command line | |
Dim wsshell | |
Set wsshell = WScript.CreateObject("WScript.Shell") | |
' The "-ss 5" part of this command is specifying that it should take a screenshot 5 seconds in. | |
' TODO: Make a variable called SCREENSHOT_TIME_IN_SECONDS to store this value. | |
wsshell.Run "ffmpeg -i """ & filePath & """ -r 1 -f image2 """ & strSplashImagePath & """ -t 1 -ss 5", 0, True | |
Set wsshell = Nothing | |
convertedCount = convertedCount + 1 | |
End If | |
End If | |
Next | |
End Sub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment