Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: AvformatNewStream2 improperly sets the denominator for time base #94

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ Golang binding for FFmpeg

A comprehensive binding to the ffmpeg video/audio manipulation library.

[![GoDoc](https://godoc.org/github.com/giorgisio/goav?status.svg)](https://godoc.org/github.com/giorgisio/goav)
[![GoDoc](https://godoc.org/github.com/sigmaseven/goav?status.svg)](https://godoc.org/github.com/sigmaseven/goav)

## Usage

`````go

import "github.com/giorgisio/goav/avformat"
import "github.com/sigmaseven/goav/avformat"

func main() {

Expand Down Expand Up @@ -69,7 +69,7 @@ export LD_LIBRARY_PATH=$HOME/ffmpeg/lib
```

```
go get github.com/giorgisio/goav
go get github.com/sigmaseven/goav

```

Expand Down
4 changes: 2 additions & 2 deletions avformat/avformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import "C"
import (
"unsafe"

"github.com/giorgisio/goav/avcodec"
"github.com/giorgisio/goav/avutil"
"github.com/sigmaseven/goav/avcodec"
"github.com/sigmaseven/goav/avutil"
)

type (
Expand Down
2 changes: 1 addition & 1 deletion avformat/avformat_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package avformat_test
import (
"testing"

"github.com/giorgisio/goav/avformat"
"github.com/sigmaseven/goav/avformat"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion avformat/codec_context_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"reflect"
"unsafe"

"github.com/giorgisio/goav/avcodec"
"github.com/sigmaseven/goav/avcodec"
)

func (cctxt *CodecContext) Type() MediaType {
Expand Down
6 changes: 3 additions & 3 deletions avformat/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ import (
"time"
"unsafe"

"github.com/giorgisio/goav/avcodec"
"github.com/giorgisio/goav/avutil"
"github.com/sigmaseven/goav/avcodec"
"github.com/sigmaseven/goav/avutil"
)

const (
Expand Down Expand Up @@ -222,7 +222,7 @@ func (s *Context) AvformatNewStream2(c *AvCodec) *Stream {
stream.codec.width = 640
stream.codec.height = 480
stream.time_base.num = 1
stream.time_base.num = 25
stream.time_base.den = 25
return stream
}

Expand Down
2 changes: 1 addition & 1 deletion avformat/context_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"reflect"
"unsafe"

"github.com/giorgisio/goav/avutil"
"github.com/sigmaseven/goav/avutil"
)

func (ctxt *Context) Chapters() **AvChapter {
Expand Down
2 changes: 1 addition & 1 deletion avformat/packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import "C"
import (
"unsafe"

"github.com/giorgisio/goav/avcodec"
"github.com/sigmaseven/goav/avcodec"
)

func toCPacket(pkt *avcodec.Packet) *C.struct_AVPacket {
Expand Down
2 changes: 1 addition & 1 deletion avformat/rational.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package avformat
//#cgo pkg-config: libavutil
//#include <libavutil/avutil.h>
import "C"
import "github.com/giorgisio/goav/avcodec"
import "github.com/sigmaseven/goav/avcodec"

func newRational(r C.struct_AVRational) avcodec.Rational {
return avcodec.NewRational(int(r.num), int(r.den))
Expand Down
18 changes: 0 additions & 18 deletions avformat/stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,24 +6,6 @@ package avformat
//#cgo pkg-config: libavformat
//#include <libavformat/avformat.h>
import "C"
import (
"github.com/giorgisio/goav/avcodec"
)

//Rational av_stream_get_r_frame_rate (const Stream *s)
func (s *Stream) AvStreamGetRFrameRate() avcodec.Rational {
return newRational(C.av_stream_get_r_frame_rate((*C.struct_AVStream)(s)))
}

//void av_stream_set_r_frame_rate (Stream *s, Rational r)
func (s *Stream) AvStreamSetRFrameRate(r avcodec.Rational) {
rat := C.struct_AVRational{
num: C.int(r.Num()),
den: C.int(r.Den()),
}

C.av_stream_set_r_frame_rate((*C.struct_AVStream)(s), rat)
}

//struct CodecParserContext * av_stream_get_parser (const Stream *s)
func (s *Stream) AvStreamGetParser() *CodecParserContext {
Expand Down
9 changes: 7 additions & 2 deletions avformat/stream_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import "C"
import (
"unsafe"

"github.com/giorgisio/goav/avcodec"
"github.com/giorgisio/goav/avutil"
"github.com/sigmaseven/goav/avcodec"
"github.com/sigmaseven/goav/avutil"
)

func (avs *Stream) CodecParameters() *avcodec.AvCodecParameters {
Expand Down Expand Up @@ -61,6 +61,11 @@ func (avs *Stream) TimeBase() avcodec.Rational {
return newRational(avs.time_base)
}

func (avs *Stream) SetTimeBase(value avcodec.Rational) {
avs.time_base.num = C.int(value.Num())
avs.time_base.den = C.int(value.Den())
}

// func (avs *Stream) RecommendedEncoderConfiguration() string {
// return C.GoString(avs.recommended_encoder_configuration)
// }
Expand Down
8 changes: 4 additions & 4 deletions example/tutorial01.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ import (
"os"
"unsafe"

"github.com/giorgisio/goav/swscale"
"github.com/sigmaseven/goav/swscale"

"github.com/giorgisio/goav/avcodec"
"github.com/giorgisio/goav/avformat"
"github.com/giorgisio/goav/avutil"
"github.com/sigmaseven/goav/avcodec"
"github.com/sigmaseven/goav/avformat"
"github.com/sigmaseven/goav/avutil"
)

// SaveFrame writes a single frame to disk as a PPM file
Expand Down
14 changes: 7 additions & 7 deletions example/versions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ package main
import (
"log"

"github.com/giorgisio/goav/avcodec"
"github.com/giorgisio/goav/avdevice"
"github.com/giorgisio/goav/avfilter"
"github.com/giorgisio/goav/avformat"
"github.com/giorgisio/goav/avutil"
"github.com/giorgisio/goav/swresample"
"github.com/giorgisio/goav/swscale"
"github.com/sigmaseven/goav/avcodec"
"github.com/sigmaseven/goav/avdevice"
"github.com/sigmaseven/goav/avfilter"
"github.com/sigmaseven/goav/avformat"
"github.com/sigmaseven/goav/avutil"
"github.com/sigmaseven/goav/swresample"
"github.com/sigmaseven/goav/swscale"
)

func main() {
Expand Down
7 changes: 4 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module github.com/giorgisio/goav
module github.com/sigmaseven/goav

go 1.15

require (
github.com/gosuri/uilive v0.0.0-20170323041506-ac356e6e42cd // indirect
github.com/gosuri/uiprogress v0.0.0-20170224063937-d0567a9d84a1 // indirect
github.com/stretchr/testify v1.6.1
)
13 changes: 13 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/sigmaseven/goav v0.1.0 h1:ZyfG3NfX7PMSimv4ulhmnQJf/XeHpMdGCn+afRmY5Oc=
github.com/sigmaseven/goav v0.1.0/go.mod h1:RtH8HyxLRLU1iY0pjfhWBKRhnbsnmfoI+FxMwb5bfEo=
github.com/gosuri/uilive v0.0.0-20170323041506-ac356e6e42cd h1:1e+0Z+T4t1mKL5xxvxXh5FkjuiToQGKreCobLu7lR3Y=
github.com/gosuri/uilive v0.0.0-20170323041506-ac356e6e42cd/go.mod h1:qkLSc0A5EXSP6B04TrN4oQoxqFI7A8XvoXSlJi8cwk8=
github.com/gosuri/uiprogress v0.0.0-20170224063937-d0567a9d84a1 h1:4iPLwzjiWGBQnYdtKbg/JNlGlEEvklrrMdjypdA1LKQ=
github.com/gosuri/uiprogress v0.0.0-20170224063937-d0567a9d84a1/go.mod h1:C1RTYn4Sc7iEyf6j8ft5dyoZ4212h8G1ol9QQluh5+0=
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/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.6.1 h1:hDPOHmpOpP40lSULcqw7IrRb/u7w6RpDC9399XyoNd0=
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
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.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=