-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from abema/add-timecode
add timecode
- Loading branch information
Showing
7 changed files
with
1,125 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,29 @@ | ||
# go-timecode | ||
go-timecode | ||
=========== | ||
|
||
[![GoDoc](https://godoc.org/github.com/abema/go-timecode/timecode?status.svg)](https://godoc.org/github.com/abema/go-timecode/timecode) | ||
|
||
go-timecode is a Go library for SMPTE 12M timecodes. | ||
|
||
Features | ||
----------- | ||
|
||
- supports drop-frame (DF) and non-drop-frame (NDF) | ||
- supports standard film, video, and television editing rates of 10, 15, 23.976, 24, 25, 29.97, 30, 48, 50, 59.94, 60 | ||
- timecode and number of frames can be calculated | ||
- convertable between timecode and number of frames | ||
|
||
Installation | ||
----------- | ||
|
||
```shell | ||
go get github.com/abema/go-timecode/timecode | ||
``` | ||
|
||
Usage | ||
----------- | ||
[GoDoc Examples](https://godoc.org/github.com/abema/go-timecode/timecode/#pkg-examples). | ||
|
||
License | ||
----------- | ||
go-timecode is available under the [MIT License](https://opensource.org/license/mit/). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
module github.com/abema/go-timecode | ||
|
||
go 1.19 | ||
|
||
require github.com/stretchr/testify v1.8.4 | ||
|
||
require ( | ||
github.com/davecgh/go-spew v1.1.1 // indirect | ||
github.com/pmezard/go-difflib v1.0.0 // indirect | ||
gopkg.in/yaml.v3 v3.0.1 // indirect | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= | ||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= | ||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= | ||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= | ||
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= | ||
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= | ||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= | ||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= | ||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
package timecode_test | ||
|
||
import ( | ||
"fmt" | ||
|
||
"github.com/abema/go-timecode/timecode" | ||
) | ||
|
||
func ExampleNewTimecode() { | ||
tc, err := timecode.NewTimecode(1800, 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
fmt.Println(tc) | ||
// Output: 00:01:00:02 | ||
} | ||
|
||
func ExampleParseTimecode() { | ||
tc, err := timecode.ParseTimecode("00:09:00:00", 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
fmt.Println(tc) | ||
// Output: 00:09:00:02 | ||
} | ||
|
||
func ExampleReset() { | ||
tc, err := timecode.NewTimecode(1798, 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
tcc, _ := timecode.Reset(tc, 1800) | ||
fmt.Println(tcc) | ||
// Output: 00:01:00:02 | ||
} | ||
|
||
func ExampleTimecode_Add() { | ||
tc1, err := timecode.NewTimecode(1798, 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
tc2, err := timecode.NewTimecode(2, 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
tc3, _ := tc1.Add(tc2) | ||
fmt.Println(tc3) | ||
// Output: | ||
// 00:01:00:02 | ||
} | ||
|
||
func ExampleTimecode_AddFrames() { | ||
tc1, err := timecode.NewTimecode(1798, 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
|
||
tc2, _ := tc1.AddFrames(2) | ||
fmt.Println(tc2) | ||
// Output: 00:01:00:02 | ||
} | ||
|
||
func ExampleTimecode_Sub() { | ||
tc1, err := timecode.NewTimecode(1800, 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
tc2, err := timecode.NewTimecode(2, 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
tc3, _ := tc1.Sub(tc2) | ||
fmt.Println(tc3) | ||
// Output: 00:00:59:28 | ||
} | ||
|
||
func ExampleTimecode_SubFrames() { | ||
tc1, err := timecode.NewTimecode(1800, 30000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
tc2, _ := tc1.SubFrames(2) | ||
fmt.Println(tc2) | ||
// Output: 00:00:59:28 | ||
} | ||
|
||
func ExampleTimecode_String() { | ||
tc, err := timecode.NewTimecode(3600, 60000, 1001) | ||
if err != nil { | ||
panic(1) | ||
} | ||
fmt.Println(tc.String()) | ||
// Output: 00:01:00:04 | ||
} |
Oops, something went wrong.