Skip to content

mbiamont/go-pgs-parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-pgs-parser

Golang PGS Parser

Installation

go get github.com/mbiamont/go-pgs-parser

Getting started

The parser requires you specify a SUP file's path.

More info about PGS and SUP file here: https://fileinfo.com/extension/sup

For each subtitle bitmap, it'll ask you in which file to write it.

Save as PNG images (recommended)

package main

import (
	"fmt"
	"github.com/mbiamont/go-pgs-parser/pgs"
	"os"
)

func main() {
	parser := pgs.NewPgsParser()

	parser.ConvertToPngImages("./sample/input.sup", func(index int) (*os.File, error) {
		return os.Create(fmt.Sprintf("./sample/subs/input.%d.png", index))
	})
}

Save as JPG images

package main

import (
	"fmt"
	"github.com/mbiamont/go-pgs-parser/pgs"
	"os"
)

func main() {
	parser := pgs.NewPgsParser()

	parser.ConvertToJpgImages("./sample/input.sup", func(index int) (*os.File, error) {
		return os.Create(fmt.Sprintf("./sample/subs/input.%d.jpg", index))
	})
}

Output example

Extract SUP from MKV

You can extract a SUP file using ffmpeg like this:

ffmpeg -i input.mkv -map 0:s:0 -c copy input.sup -y