refactor(ffmpeg): selected_frame and frame(n) starts from 1

* refactor(ffmpeg): selected_frame and frame(n) starts from 1

* test: update golden files
This commit is contained in:
Adrian Shum 2022-10-21 10:42:51 +08:00 committed by GitHub
parent 33c1d38a21
commit 6f9a3d085a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
38 changed files with 30 additions and 30 deletions

View file

@ -88,7 +88,7 @@ func (av *AVContext) ProcessFrames(maxFrames int) (err error) {
} }
func (av *AVContext) SelectFrame(n int) (err error) { func (av *AVContext) SelectFrame(n int) (err error) {
nn := C.int(n) nn := C.int(n - 1)
if av.thumbContext != nil && nn > av.availableIndex { if av.thumbContext != nil && nn > av.availableIndex {
nn = av.availableIndex nn = av.availableIndex
} }
@ -123,7 +123,7 @@ func (av *AVContext) Metadata() *Metadata {
} }
var selectedFrame int var selectedFrame int
if av.availableIndex > 0 && av.selectedIndex > -1 { if av.availableIndex > 0 && av.selectedIndex > -1 {
selectedFrame = int(av.selectedIndex) selectedFrame = int(av.selectedIndex) + 1
} }
return &Metadata{ return &Metadata{
Orientation: av.orientation, Orientation: av.orientation,

Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 7.9 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 13 KiB

After

Width:  |  Height:  |  Size: 13 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 27 KiB

After

Width:  |  Height:  |  Size: 27 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before After
Before After

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Before After
Before After

View file

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

View file

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

View file

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

View file

@ -1 +1 @@
{"orientation":1,"duration":7407,"width":640,"height":480,"fps":30,"selected_frame":5,"has_video":true,"has_audio":true} {"orientation":1,"duration":7407,"width":640,"height":480,"fps":30,"selected_frame":6,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":1,"duration":7407,"width":640,"height":480,"fps":29.9,"selected_frame":5,"has_video":true,"has_audio":true} {"orientation":1,"duration":7407,"width":640,"height":480,"fps":30.1,"selected_frame":5,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":1,"duration":7407,"width":640,"height":480,"fps":30,"selected_frame":99,"has_video":true,"has_audio":true} {"orientation":1,"duration":7407,"width":640,"height":480,"fps":30,"selected_frame":100,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":1,"duration":7407,"width":640,"height":480,"fps":30,"selected_frame":99,"has_video":true,"has_audio":true} {"orientation":1,"duration":7407,"width":640,"height":480,"fps":30,"selected_frame":100,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":1,"duration":3925,"width":492,"height":360,"fps":30,"selected_frame":4,"has_video":true,"has_audio":true} {"orientation":1,"duration":3925,"width":492,"height":360,"fps":30,"selected_frame":5,"has_video":true,"has_audio":true}

View file

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

View file

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

View file

@ -1 +1 @@
{"orientation":1,"duration":2560,"width":480,"height":360,"fps":27.9,"selected_frame":5,"has_video":true,"has_audio":true} {"orientation":1,"duration":2560,"width":480,"height":360,"fps":27.9,"selected_frame":6,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":1,"duration":2560,"width":480,"height":360,"fps":26.3,"selected_frame":5,"has_video":true,"has_audio":true} {"orientation":1,"duration":2560,"width":480,"height":360,"fps":25.6,"selected_frame":5,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":1,"duration":2560,"width":480,"height":360,"fps":29.7,"selected_frame":75,"has_video":true,"has_audio":true} {"orientation":1,"duration":2560,"width":480,"height":360,"fps":29.7,"selected_frame":76,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":1,"duration":2560,"width":480,"height":360,"fps":29.7,"selected_frame":75,"has_video":true,"has_audio":true} {"orientation":1,"duration":2560,"width":480,"height":360,"fps":29.7,"selected_frame":76,"has_video":true,"has_audio":true}

View file

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

View file

@ -1 +1 @@
{"orientation":1,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":19,"has_video":true,"has_audio":true} {"orientation":1,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":20,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":1,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":19,"has_video":true,"has_audio":true} {"orientation":1,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":20,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":3,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":4,"has_video":true,"has_audio":true} {"orientation":3,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":5,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":3,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":19,"has_video":true,"has_audio":true} {"orientation":3,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":20,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":3,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":19,"has_video":true,"has_audio":true} {"orientation":3,"duration":2544,"width":480,"height":360,"fps":30,"selected_frame":20,"has_video":true,"has_audio":true}

View file

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

View file

@ -1 +1 @@
{"orientation":6,"duration":2544,"width":360,"height":480,"fps":30,"selected_frame":19,"has_video":true,"has_audio":true} {"orientation":6,"duration":2544,"width":360,"height":480,"fps":30,"selected_frame":20,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":6,"duration":2544,"width":360,"height":480,"fps":30,"selected_frame":19,"has_video":true,"has_audio":true} {"orientation":6,"duration":2544,"width":360,"height":480,"fps":30,"selected_frame":20,"has_video":true,"has_audio":true}

View file

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

View file

@ -1 +1 @@
{"orientation":8,"duration":2544,"width":360,"height":480,"fps":30,"selected_frame":19,"has_video":true,"has_audio":true} {"orientation":8,"duration":2544,"width":360,"height":480,"fps":30,"selected_frame":20,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"orientation":8,"duration":2544,"width":360,"height":480,"fps":30,"selected_frame":19,"has_video":true,"has_audio":true} {"orientation":8,"duration":2544,"width":360,"height":480,"fps":30,"selected_frame":20,"has_video":true,"has_audio":true}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.3 KiB

After

Width:  |  Height:  |  Size: 2.3 KiB

Before After
Before After

View file

@ -1 +1 @@
{"format":"mkv","content_type":"video/x-matroska","orientation":1,"duration":7407,"width":640,"height":480,"fps":30,"selected_frame":43,"has_video":true,"has_audio":true} {"format":"mkv","content_type":"video/x-matroska","orientation":1,"duration":7407,"width":640,"height":480,"fps":30,"selected_frame":44,"has_video":true,"has_audio":true}

View file

@ -1 +1 @@
{"format":"mkv","content_type":"video/x-matroska","orientation":1,"duration":7407,"width":640,"height":480,"fps":29.9,"selected_frame":3,"has_video":true,"has_audio":true} {"format":"mkv","content_type":"video/x-matroska","orientation":1,"duration":7407,"width":640,"height":480,"fps":29.9,"selected_frame":4,"has_video":true,"has_audio":true}