Windows – Creating PSP Thumbnails Using VLC and the Command Line

Windows 8 Logo

In my previous post I detailed the Handbrake settings that I am using to convert YouTube (and other) videos to play on my Play Station Portable (PSP).

Creating thumbnails for these PSP videos is a “nice to have” – but it is time consuming if it is not automated.

PSP thumbnails are simple to understand – they are jpeg files (160 x 120 pixels) that have had their extension changed to .thm. Videos and thumbnails must share the same filename on the PSP. So for a video called my_video.mp4 we would create a thumbnail called my_video.thm.

After looking at a lot of blogs and the VLC documentation I came up with a command line script that created a single jpeg thumbnail for each mp4 file in the current working directory:

for %i in (*.mp4) do if NOT exist "%~ni_*.jpg" start /WAIT "" "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" --rate=2.0 --video-filter=scene --start-time=280 --stop-time=281 --scene-format=jpg --scene-replace --scene-ratio=18 --scene-width=160 --scene-height=120 --scene-path="%CD%" --scene-prefix="%~ni" "%CD%\%i" vlc://quit

The above command line is modified from this post. It can be broken down as follows:

  • for %i in (*.mp4): filters the media to process (in my case .mp4 files)
  • do if NOT exist “%~ni_*.jpg”: creates a jpeg snapshot (if it does not already exist)
  • start /WAIT “”: is required to only process one video at a time
  • “C:\Program Files (x86)\VideoLAN\VLC\vlc.exe”: This is the path to vlc.exe on Windows 8 x64.
  • –rate=2.0: sets the playback speed. I set this to 2.0 so that vlc plays the specified video segments at twice the normal speed.
  • –video-filter=scene: the scene video filter sends video to picture files
  • –start-time=280: the stream will start at this position (in seconds)
  • –stop-time=281: the stream will stop at this position (in seconds)
  • –scene-format=jpg: specifies the screenshot format
  • –scene-replace: always writes to the same output file. This is used so that I can obtain a single screenshot that only needs the extension to be renamed.
  • –scene-ratio=18: the ratio of images to record. Initially this was set to 24 (1 image every 24 frames) – however with a start and stop time interval of one second I found that some of the screenshots that vlc output were black screens. I lowered this value until I could consistently generate screenshots from multiple .mp4 files. Your mileage may vary.
  • –scene-width=160: output image width
  • –scene-height=120: output image height
  • –scene-path=”%CD%”: output image directory – %CD% specifies current working directory
  • –scene-prefix=”%~ni” “%CD%\%i”: output image name – in this case the same name as the .mp4 video and the same working directory
  • vlc://quit: Quit vlc

The above script works when it is pasted into a command prompt window – but it required me to navigate to the drive and directory that contained my videos – and I still needed to change the extension of the screenshots produced to .thm. So the next step was to modify the script so that it would run in a batch file.

cd PSP

for %%i in (*.mp4) do if NOT exist "%%~ni_*.jpg" start /WAIT "" "C:\Program Files (x86)\VideoLAN\VLC\vlc.exe" --rate=2.0 --video-filter=scene --start-time=280 --stop-time=281 --scene-format=jpg --scene-replace --scene-ratio=18 --scene-width=160 --scene-height=120 --scene-path="D:\PSP" --scene-prefix="%%~ni" "D:\PSP\%%i" vlc://quit

ren *.jpg *.thm

The differences made between the first and second scripts are as follows:

  • d: changes drive from c: to d:
  • cd PSP: changes directory to PSP
  • single percentage signs % are all changed to double percentage signs %% to allow the script to run in a batch file
  • –scene-path=”D:\PSP: the output image directory is changes to D:\PSP
  • –scene-prefix=”%%~ni” “D:\PSP\%%i”: the output image name also specifies the D:\PSP directory
  • ren *.jpg *.thm: renames all jpeg files in D:\PSP to .thm files

Many thanks to ComCBoVudLaBa on the VLC forum for providing a script with supporting comments that does all of the heavy lifting required. After some experimentation and tweaking I ended up with a batch file that completely automated the creation of PSP thumbnails from .mp4 videos!


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s