fix(ffmpeg): 0s frame handling

* handle 0 duration

* test: update golden files
This commit is contained in:
Adrian Shum 2022-10-24 16:07:51 +08:00 committed by GitHub
parent f716d9b95b
commit 77554f272f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
20 changed files with 15 additions and 2 deletions

View file

@ -110,8 +110,10 @@ func (av *AVContext) SelectDuration(ts time.Duration) (err error) {
if err = av.SeekDuration(ts); err != nil {
return
}
return av.ProcessFrames(-1)
} else {
return av.ProcessFrames(1)
}
return av.ProcessFrames(-1)
}
func (av *AVContext) SeekPosition(f float64) error {

View file

@ -55,7 +55,7 @@ func TestAVContext(t *testing.T) {
require.NoError(t, os.MkdirAll(baseDir+"golden/export", 0755))
t.Parallel()
for _, filename := range files {
for _, n := range []int{-1, 5, 10, 9999, 99999} {
for _, n := range []int{-1, 1, 5, 10, 9999, 99999} {
name := filename
if n > -1 {
name = fmt.Sprintf("%s-%d", filename, n)
@ -84,6 +84,8 @@ func TestAVContext(t *testing.T) {
require.NoError(t, av.SelectDuration(time.Second))
} else if n == 9999 {
require.NoError(t, av.SelectPosition(0.7))
} else if n == 1 {
require.NoError(t, av.SelectDuration(0))
} else if n == 5 {
require.NoError(t, av.SelectFrame(n))
} else {

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

BIN
testdata/golden/export/macabre.mp4-1.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

BIN
testdata/golden/export/schizo.flv-1.jpg vendored Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 27 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

View file

@ -0,0 +1 @@
{"orientation":1,"duration":12040,"width":720,"height":576,"fps":25,"has_video":true,"has_audio":false}

View file

@ -0,0 +1 @@
{"orientation":1,"duration":7407,"width":640,"height":480,"fps":29.97002997002997,"has_video":true,"has_audio":true}

View file

@ -0,0 +1 @@
{"orientation":1,"duration":3925,"width":492,"height":360,"fps":29.97002997002997,"has_video":true,"has_audio":true}

View file

@ -0,0 +1 @@
{"orientation":1,"duration":2560,"width":480,"height":360,"fps":29.97002997002997,"has_video":true,"has_audio":true}

View file

@ -0,0 +1 @@
{"orientation":1,"duration":2544,"width":480,"height":360,"fps":29.97002997002997,"has_video":true,"has_audio":true}

View file

@ -0,0 +1 @@
{"orientation":3,"duration":2544,"width":480,"height":360,"fps":29.97002997002997,"has_video":true,"has_audio":true}

View file

@ -0,0 +1 @@
{"orientation":6,"duration":2544,"width":360,"height":480,"fps":29.97002997002997,"has_video":true,"has_audio":true}

View file

@ -0,0 +1 @@
{"orientation":8,"duration":2544,"width":360,"height":480,"fps":29.97002997002997,"has_video":true,"has_audio":true}

View file

@ -0,0 +1 @@
{"orientation":1,"duration":1906,"width":1280,"height":720,"fps":90000,"has_video":true,"has_audio":true}