Kodi Community Forum
quick script for generating tbn files in linux - Printable Version

+- Kodi Community Forum (http://forum.kodi.tv)
+-- Forum: Help and Support (/forumdisplay.php?fid=33)
+--- Forum: Supplementary Tools for Kodi (/forumdisplay.php?fid=116)
+--- Thread: quick script for generating tbn files in linux (/showthread.php?tid=55168)



quick script for generating tbn files in linux - Killarny - 2009-07-22 04:44

I haven't contributed to the community in about 5 years, and this isn't much of a contribution, but I figure I'll stick it up here in case it's useful to anyone Smile

This is a simple python script that will use ffmpeg to generate JPEG thumbnails from every video in the folder you specify, saving the thumbs as tbn files.

Code:
#!/usr/bin/python
import commands
import os
import sys


if not len(sys.argv) > 1 or not os.path.isdir(sys.argv[1]):
    print
    print 'Please specify a valid path.'
    print
    sys.exit()

files = [x for x in os.listdir(sys.argv[1]) if os.path.isfile(x)]
for file in files:
    print 'Processing:', file
    error_code, output = commands.getstatusoutput(
        'ffmpeg -y -ss 30 -i "%(source)s" -f mjpeg '
        '-vframes 1 -s 150x113 -an "%(dest)s.tbn"' % {
            'source': os.path.join(sys.argv[1], file),
            'dest': os.path.splitext(file)[0],
        }
    )
    if error_code:
        print '..error.'

After writing this script, I found webmosher's thumber program, which looks really nice (although I haven't tried it yet). I recommend you check out his/her program too.