HOW-TO create video preview thumbnails automatically
#16
i cook up this ver of batch

Code:
@echo off

    set FFMPEG=C:\Windows\System32\ffmpeg.exe
    set THUMB="%%~di%%~pi%%~ni.tbn"
    set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss 5 -y %THUMB%
    set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] Trailers
ECHO [2] Drags
ECHO [3] Camcorder
ECHO [4] Music
ECHO [5] TV Series
ECHO [6] Quit
ECHO.
SET DirsType=
SET /P DirsType="Please select a Folder and press <ENTER>: "

IF /I "%DirsType%"=="1" (
    for /r  F:\Videos\Trailers %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
    for /r  F:\Videos\Sports\Drag %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="3" (
    for /r  F:\Videos\Camcorder %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="4" (
    for /r  F:\Videos\Music %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="5" (
    for /r  F:\Videos\TV Series %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="6" (
    GOTO Quit
)
hope someone can do a proper batch. say with an option to set second to take screenshot
Reply
#17
where the edit button?

i redone the batch with the option to set second to skip to take screenshot

Code:
@echo off

    set FFMPEG="C:\Program Files\FFmpeg\ffmpeg.exe"
    set THUMB="%%~di%%~pi%%~ni.tbn"
    set /P SEC="Set second to skip to take screenshot and press <ENTER>: "
    set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss %SEC% -y %THUMB%
    set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] Trailers
ECHO [2] Drags
ECHO [3] Camcorder
ECHO [4] Music
ECHO [5] TV Series
ECHO [6] Quit
ECHO.
SET DirsType=
SET /P DirsType="Please select a Folder and press <ENTER>: "

IF /I "%DirsType%"=="1" (
    for /r  F:\Videos\Trailers %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
    for /r  F:\Videos\Sports\Drag %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="3" (
    for /r  F:\Videos\Camcorder %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="4" (
    for /r  F:\Videos\Music %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="5" (
    for /r  F:\Videos\TV Series %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="6" (
    GOTO Quit
)
Reply
#18
Question 
Does it only grab the next key-frame after a certain amounts of seconds into each video, or does it grab just any frame at that second?

The difference is that a key-frame has higher quality, which is why you preferably want to grab a key-frame instead of just any frame).
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply
#19
Man this makes thumbs much easier! Once I delete videos I still have the thumbs left over tho. Is there any way add a "cleanup" option to this script to somehow delete unneeded thumbs?
Reply
#20
Attro Wrote:Man this makes thumbs much easier! Once I delete videos I still have the thumbs left over tho. Is there any way add a "cleanup" option to this script to somehow delete unneeded thumbs?

Something like:

Code:
set MOVIE=%%~di%%~pi%%~ni
for /r  f:\series\ %%i in ( *.tbn ) do if not exist %MOVIE%.mov if not exist %MOVIE%.mpg if not exist %MOVIE%.avi if not exist %MOVIE%.flv if not exist %MOVIE%.wmv if not exist %MOVIE%.mp4 del "%%i"

should do the trick.
Make sure you have an 'if exists' for every file extension you use. This can also be used to clean up other stuff with the same name as the movie, like .srt .edl etc.
Reply
#21
Maybe something like this? I can't test it right now, as I'm at work, but I think this should work.

Code:
@echo off

    set FFMPEG="C:\Program Files\FFmpeg\ffmpeg.exe"
    set THUMB="%%~di%%~pi%%~ni.tbn"
    set /P SEC="Set second to skip to take screenshot and press <ENTER>: "
    set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss %SEC% -y %THUMB%
    set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4" "*.mkv"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] TV Series
ECHO [2] Clean old thumbnails
ECHO.
ECHO [3] Quit
ECHO.
SET /P DirsType="Please select a Folder and press <ENTER>: "

IF /I "%DirsType%"=="1" (
    for /r  M:\TV Shows\ %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
    for /r  M:\TV Shows\ %%i in ( *.tbn ) do if not exist %MOVIE%.mov if not exist %MOVIE%.mpg if not exist %MOVIE%.avi if not exist %MOVIE%.flv if not exist %MOVIE%.wmv if not exist %MOVIE%.mp4 if not exist %MOVIE%.mkv del "%%i"
)
IF /I "%DirsType%"=="3" (
    GOTO Quit
)
Reply
#22
--------------------------------------------------------------------------------

I was wondering if anyone knows how I can create a batch file and if I could use Task Scheduler to auto launch it to update my thumbnails. I am able to open a command prompt in C:\Users\Public\Recorded TV and generate thumbs, but it would be very helpful if it could be done all automaticaly.

Thanks
Reply
#23
Gamester17 Wrote:Does it only grab the next key-frame after a certain amounts of seconds into each video, or does it grab just any frame at that second?

The difference is that a key-frame has higher quality, which is why you preferably want to grab a key-frame instead of just any frame).

I think it's the latter because I get some bad frames when running the cmd.

jaredharley Wrote:Maybe something like this? I can't test it right now, as I'm at work, but I think this should work.

Code:
@echo off

    set FFMPEG="C:\Program Files\FFmpeg\ffmpeg.exe"
    set THUMB="%%~di%%~pi%%~ni.tbn"
    set /P SEC="Set second to skip to take screenshot and press <ENTER>: "
    set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss %SEC% -y %THUMB%
    set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4" "*.mkv"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] TV Series
ECHO [2] Clean old thumbnails
ECHO.
ECHO [3] Quit
ECHO.
SET /P DirsType="Please select a Folder and press <ENTER>: "

IF /I "%DirsType%"=="1" (
    for /r  M:\TV Shows\ %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
    for /r  M:\TV Shows\ %%i in ( *.tbn ) do if not exist %MOVIE%.mov if not exist %MOVIE%.mpg if not exist %MOVIE%.avi if not exist %MOVIE%.flv if not exist %MOVIE%.wmv if not exist %MOVIE%.mp4 if not exist %MOVIE%.mkv del "%%i"
)
IF /I "%DirsType%"=="3" (
    GOTO Quit
)

I've changed the directory to where I have my TV shows but whenever I run the batch file it just flashs up 'The system cannot find the path specified'.
Reply
#24
Hello Hitcher,

Quote:I've changed the directory to where I have my TV shows but whenever I run the batch file it just flashs up 'The system cannot find the path specified'.

I think all that is missing is quotes around your TV Show directories:

Code:
@echo off

    set FFMPEG="C:\Program Files\FFmpeg\ffmpeg.exe"
    set THUMB="%%~di%%~pi%%~ni.tbn"
    set /P SEC="Set second to skip to take screenshot and press <ENTER>: "
    set MAKETHUMB=%FFMPEG% -i "%%i" -f mjpeg -t 0.001 -ss %SEC% -y %THUMB%
    set FILES="*.mov" "*.mpg" "*.avi" "*.flv" "*.wmv" "*.mp4" "*.mkv"

ECHO ----------------------------------------------------------------------
ECHO.
ECHO [1] TV Series
ECHO [2] Clean old thumbnails
ECHO.
ECHO [3] Quit
ECHO.
SET /P DirsType="Please select an option and press <ENTER>: "

IF /I "%DirsType%"=="1" (
    for /r  "C:\TVSHOW" %%i in ( %FILES% ) do if not exist %THUMB% %MAKETHUMB%
)
IF /I "%DirsType%"=="2" (
    for /r  "C:\TVSHOW" %%i in ( *.tbn ) do if not exist %MOVIE%.mov if not exist %MOVIE%.mpg if not exist %MOVIE%.avi if not exist %MOVIE%.flv if not exist %MOVIE%.wmv if not exist %MOVIE%.mp4 if not exist %MOVIE%.mkv del "%%i"
)
IF /I "%DirsType%"=="3" (
    GOTO Quit
)

regards
moonoo
Reply
#25
Thanks, but still the same message.
Reply
#26
It was the location of FFmpeg.exe I'd overlooked.

Code:
set FFMPEG=C:\Windows\System32\ffmpeg.exe

I feel stupid.Rolleyes
Reply
#27
Tried this last night, worked good for a lot of TV episodes I didn't have thumbs for. Thanks!Smile
Reply
#28
Don't forget to upload them to TVDB.
Reply
#29
Yea, that's on my agenda for tonight. Too bad tvdb doesn't have a section for "Chilly Willy" cartoons tho.... But I do have some good ones to upload for "Man Vs. Wild Season 2" and "Saving Planet Earth"
Reply
#30
Wink 
joebrady Wrote:Too bad tvdb doesn't have a section for "Chilly Willy" cartoons tho.... But I do have some good ones to upload for "Man Vs. Wild Season 2" and "Saving Planet Earth"
Try posting in TheTVDB.com forums and asking them to add it or something similar:
http://forums.thetvdb.com

Wink
Always read the XBMC online-manual, FAQ and search the forum before posting.
Do not e-mail XBMC-Team members directly asking for support. Read/follow the forum rules.
For troubleshooting and bug reporting please make sure you read this first.
Reply

Logout Mark Read Team Forum Stats Members Help
HOW-TO create video preview thumbnails automatically0