This go package can generate thumbnails or snapshots of video files using VLC. See Godoc.


This package currently only works on Linux machines. And requires VLC to be installed. To test if your machine has VLC enter the following command in your terminal;

whereis -b cvlc

Outputs, when installed;

cvlc: /usr/bin/cvlc


Install the package

Open your terminal in the root folder of your go project and go get;

go get github.com/mrwaggel/go-vlc-thumbnail

Code example

This code would generate a jpeg snapshot of 2 seconds in the video. It's recommended to use absolute paths of the source file.

package main

import vlcsnap "github.com/mrwaggel/go-vlc-thumbnail"

func main()  {
	video := vlcsnap.Video{
		Source:       "location_to_video.mp4",
		OutputFormat: vlcsnap.FORMAT_JPEG,
		Time:         2,

	// Get the snapshot in memory
	jpgBytes, err := video.Generate()
	if err != nil {
		// ...

	// Save to snapshot to a file
	err = video.GenerateTo("location_of_snapshot.jpg")
	if err != nil {
		// ...

The following output formats are available:

const (
	FORMAT_JPEG = pictureOutputFormat(iota)

Extra options

By default the package will find the VLC/CVLC binary by itself, however if you have installed it to a custom location set the following variable.

vlcsnap.CVLCBinPath = "/path/to/cvlc"

You can also enable hardware encoding, by default this is disabled since nvidia drivers may end up halting VLC, the performance gain is negligible since the CPU only has to render a couple of frames, however if you wish to enable it.

vlcsnap.DisableHardwareAudioVideoCodec = false

Since VLC generates snapshots to disk, and not to memory, temporary files will be created inside a folder, by default this folder is the current process working directory. This package cleans up temporary files after generating snapshots. But you can define your own working directory.

vlcsnap.TempWorkDir = "/path/to/temporary/working/dir"