TheAMM / mpv_thumbnail_script

A Lua script to show preview thumbnails in mpv's OSC seekbar, sans external dependencies
GNU General Public License v3.0
679 stars 68 forks source link

When used with ffmpeg leverage vaapi for much faster generation #58

Open barolo opened 4 years ago

barolo commented 4 years ago

I've been experimenting with hw accelerated ffmpeg thumbnailer via changing ffmpeg command to:


    local ffmpeg_command = {
        "ffmpeg",
        "-loglevel", "quiet",
        "-noaccurate_seek",
        "-hwaccel", "vaapi",
        "-hwaccel_device", "/dev/dri/renderD128",
        "-hwaccel_output_format", "vaapi", 
        "-ss", format_time(timestamp, ":"),
        "-i", file_path,

        "-frames:v", "1",
        "-an",

        "-vf", ("scale_vaapi=%d:%d,scale_vaapi=format=rgb32,hwdownload,format=rgb32"):format(size.w, size.h),
        "-c:v", "rawvideo",
        "-pix_fmt", "bgra",
        "-f", "rawvideo",

        "-y", output_path
    }```

And it is much much faster. could it be used when ffmpeg is picked?
Steven79203 commented 3 years ago

I tested these same configurations but didn't worked properly without modifications. Here's my config if anyone with similar specs want to try: CPU: 3th Gen Intel Ivybridge, GPU: Intel Ivybridge (Gen 7) Integrated Graphics

local ffmpeg_command = {
        "ffmpeg",
        --"-loglevel", "quiet",
        "-noaccurate_seek",
        "-ss", format_time(timestamp, ":"),
        "-hwaccel_output_format","vaapi",
        "-hwaccel_device","/dev/dri/renderD128",
        "-hwaccel", "vaapi",
        "-i", file_path,
        "-frames:v", "1",
        "-an",

        "-vf", ("scale_vaapi=%d:%d,scale_vaapi=format=rgb32,hwdownload,format=nv12"):format(size.w, size.h),
        "-c:v", "rawvideo",
        "-pix_fmt", "bgra",
        "-f", "rawvideo",

        "-y", output_path
}

Works like a charm.