-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathvideoToImagePoster.cmd
More file actions
59 lines (49 loc) · 1.65 KB
/
videoToImagePoster.cmd
File metadata and controls
59 lines (49 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
REM filepath: d:\workspace\media-utility-scripts\videoToImagePoster.cmd
@echo off
echo ###################################################
echo # Description: Extract a poster frame from a video or videos in a directory
echo # Usage: videoToImagePoster.cmd /path/to/video.mov [2.0]
echo # videoToImagePoster.cmd /path/to/videos/directory [2.0]
echo # Param 1: Video file or directory containing video files
echo # Param 2 [Optional]: Time in seconds
echo # Requires: ffmpeg
echo ###################################################
echo.
REM Check parameters
IF "%~1"=="" (
echo Error: 1st arg must be a video file or directory
exit /b 1
)
REM Set defaults
set "extractTime=0"
IF NOT "%~2"=="" set "extractTime=%~2"
REM Function to process a single video file
call :ProcessVideoFile "%~1"
exit /b
:ProcessVideoFile
REM Check if path is a directory or a file
IF EXIST "%~1\" (
echo Processing all video files in directory: %~1
REM Process all video files in the directory
FOR %%F IN ("%~1\*.mp4" "%~1\*.mov" "%~1\*.avi" "%~1\*.mkv" "%~1\*.wmv") DO (
echo.
echo Processing: %%F
call :ExtractPosterFrame "%%F"
)
echo.
echo Finished processing all videos in directory: %~1
) ELSE (
REM Process single file
call :ExtractPosterFrame "%~1"
)
exit /b
:ExtractPosterFrame
set "videoFile=%~1"
set "outputFile=%~dpn1.%extractTime%.jpg"
echo Saving thumbnail for movie: %videoFile% at %extractTime% seconds
REM Do conversion
ffmpeg -ss %extractTime% -i "%videoFile%" -frames:v 1 -q:v 2 -update 1 "%outputFile%" 2>nul
REM Complete
echo Extracted poster frame at %extractTime% seconds:
echo # %outputFile%
exit /b