feat: sync GIFv and saved GIF support
This commit is contained in:
parent
c0088f1160
commit
5f7c0b9804
21 changed files with 641 additions and 50 deletions
39
internal/app/files/gif_transcoder_test.go
Normal file
39
internal/app/files/gif_transcoder_test.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package files
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"context"
|
||||
"image"
|
||||
"image/color"
|
||||
"image/gif"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestFFmpegGIFTranscoderProducesCanonicalMP4(t *testing.T) {
|
||||
transcoder, err := NewFFmpegGIFTranscoder()
|
||||
if err != nil {
|
||||
t.Skipf("ffmpeg/ffprobe unavailable: %v", err)
|
||||
}
|
||||
palette := color.Palette{color.Black, color.White}
|
||||
first := image.NewPaletted(image.Rect(0, 0, 3, 5), palette)
|
||||
second := image.NewPaletted(image.Rect(0, 0, 3, 5), palette)
|
||||
for i := range second.Pix {
|
||||
second.Pix[i] = 1
|
||||
}
|
||||
var input bytes.Buffer
|
||||
if err := gif.EncodeAll(&input, &gif.GIF{
|
||||
Image: []*image.Paletted{first, second}, Delay: []int{10, 10}, LoopCount: 0,
|
||||
}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
result, err := transcoder.Transcode(context.Background(), input.Bytes())
|
||||
if err != nil {
|
||||
t.Fatalf("Transcode: %v", err)
|
||||
}
|
||||
if len(result.Data) < 12 || string(result.Data[4:8]) != "ftyp" {
|
||||
t.Fatalf("output is not MP4: %x", result.Data[:min(len(result.Data), 16)])
|
||||
}
|
||||
if result.Width != 4 || result.Height != 6 || result.Duration <= 0 {
|
||||
t.Fatalf("metadata = %+v, want even 4x6 positive duration", result)
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue