Skip to content

Commit

Permalink
thumbnails: png output
Browse files Browse the repository at this point in the history
  • Loading branch information
gioelecerati committed Jul 25, 2024
1 parent ac85dfd commit e07531c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
4 changes: 1 addition & 3 deletions thumbnails/thumbnails.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,6 @@ func processSegment(input string, thumbOut string) error {
"vframes": "1",
// video filter to resize
"vf": fmt.Sprintf("scale=%s:force_original_aspect_ratio=decrease", resolution),
// set quality
"q:v": "2",
},
).OverWriteOutput().WithErrorOutput(&ffmpegErr).Run()
}, clients.DownloadRetryBackoff())
Expand Down Expand Up @@ -254,5 +252,5 @@ func thumbFilename(segmentURI string, segmentOffset int64) (string, error) {
if err != nil {
return "", err
}
return fmt.Sprintf("keyframes_%d.jpg", i-segmentOffset), nil
return fmt.Sprintf("keyframes_%d.png", i-segmentOffset), nil
}
14 changes: 7 additions & 7 deletions thumbnails/thumbnails_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,21 @@ func testGenerateThumbsRun(t *testing.T, outDir, input string) {

expectedVtt := `WEBVTT
00:00:00.000 --> 00:00:10.000
keyframes_0.jpg
keyframes_0.png
00:00:10.000 --> 00:00:20.000
keyframes_1.jpg
keyframes_1.png
00:00:20.000 --> 00:00:30.000
keyframes_2.jpg
keyframes_2.png
`

vtt, err := os.ReadFile(filepath.Join(outDir, "thumbnails/thumbnails.vtt"))
require.NoError(t, err)
require.Equal(t, expectedVtt, string(vtt))

files, err := filepath.Glob(filepath.Join(outDir, "thumbnails", "*.jpg"))
files, err := filepath.Glob(filepath.Join(outDir, "thumbnails", "*.png"))
require.NoError(t, err)
require.Len(t, files, 3)

Expand All @@ -143,19 +143,19 @@ func Test_thumbFilename(t *testing.T) {
name: "index",
segmentURI: "index0.ts",
segmentOffset: 0,
want: "keyframes_0.jpg",
want: "keyframes_0.png",
},
{
name: "clip",
segmentURI: "clip_1.ts",
segmentOffset: 0,
want: "keyframes_1.jpg",
want: "keyframes_1.png",
},
{
name: "clip",
segmentURI: "clip_101.ts",
segmentOffset: 100,
want: "keyframes_1.jpg",
want: "keyframes_1.png",
},
}
for _, tt := range tests {
Expand Down

0 comments on commit e07531c

Please sign in to comment.