fix(ffmpeg): no codec handling

This commit is contained in:
Adrian Shum 2022-10-13 20:56:43 +08:00 committed by GitHub
parent 17b50dea3c
commit 66b74a271f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 6 additions and 0 deletions

View file

@ -85,6 +85,9 @@ func LoadAVContext(ctx context.Context, reader io.Reader, size int64) (*AVContex
} }
func (av *AVContext) ProcessFrames(maxFrames int) (err error) { func (av *AVContext) ProcessFrames(maxFrames int) (err error) {
if av.formatContext == nil || av.codecContext == nil {
return ErrDecoderNotFound
}
if av.thumbContext == nil { if av.thumbContext == nil {
return createThumbContext(av, C.int(maxFrames)) return createThumbContext(av, C.int(maxFrames))
} }

View file

@ -55,6 +55,8 @@ func TestProcessor(t *testing.T) {
{name: "image", path: "fit-in/100x100/demo.png"}, {name: "image", path: "fit-in/100x100/demo.png"},
{name: "alpha", path: "fit-in/filters:format(png)/alpha-webm.webm"}, {name: "alpha", path: "fit-in/filters:format(png)/alpha-webm.webm"},
{name: "corrupted", path: "fit-in/100x100/corrupt/everybody-betray-me.mkv", expectCode: 406}, {name: "corrupted", path: "fit-in/100x100/corrupt/everybody-betray-me.mkv", expectCode: 406},
{name: "no cover meta", path: "meta/no_cover.mp3"},
{name: "no cover 406", path: "fit-in/100x100/no_cover.mp3", expectCode: 406},
}, WithDebug(true), WithLogger(zap.NewExample())) }, WithDebug(true), WithLogger(zap.NewExample()))
doGoldenTests(t, filepath.Join(testDataDir, "golden/result-fallback-image"), []test{ doGoldenTests(t, filepath.Join(testDataDir, "golden/result-fallback-image"), []test{
{name: "corrupted with fallback image", path: "fit-in/100x100/corrupt/everybody-betray-me.mkv", expectCode: 406}, {name: "corrupted with fallback image", path: "fit-in/100x100/corrupt/everybody-betray-me.mkv", expectCode: 406},

Binary file not shown.

After

Width:  |  Height:  |  Size: 43 B

View file

@ -0,0 +1 @@
{"format":"mp3","content_type":"audio/mpeg","orientation":0,"duration":13536,"has_video":false,"has_audio":true}

BIN
testdata/no_cover.mp3 vendored Normal file

Binary file not shown.