diff --git a/examples/transform/main.go b/examples/transform/main.go index 4c83ea0..36183b6 100644 --- a/examples/transform/main.go +++ b/examples/transform/main.go @@ -4,6 +4,7 @@ import ( "fmt" "image" + "github.com/disintegration/imaging" "github.com/pion/mediadevices" "github.com/pion/mediadevices/examples/internal/signal" _ "github.com/pion/mediadevices/pkg/codec/vpx" // This is required to register VP8/VP9 video encoder @@ -17,19 +18,14 @@ const ( videoCodecName = webrtc.VP8 ) -func removeBlue(r video.Reader) video.Reader { +func rotate180(r video.Reader) video.Reader { return video.ReaderFunc(func() (img image.Image, err error) { img, err = r.Read() if err != nil { return } - yuvImg, ok := img.(*image.YCbCr) - if !ok { - return img, nil - } - - yuvImg.Cb = make([]uint8, len(yuvImg.Cb)) + img = imaging.Rotate180(img) return }) } @@ -74,7 +70,7 @@ func main() { c.Width = 640 c.Height = 480 c.BitRate = 100000 // 100kbps - c.VideoTransform = removeBlue + c.VideoTransform = rotate180 }, }) if err != nil { diff --git a/go.mod b/go.mod index 9d51633..0ab9bf1 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.13 require ( github.com/blackjack/webcam v0.0.0-20191123110216-08fa32efcb67 + github.com/disintegration/imaging v1.6.2 github.com/faiface/beep v1.0.2 github.com/jfreymuth/pulse v0.0.0-20200118113426-7cf5f487291e github.com/pion/rtp v1.2.0 diff --git a/go.sum b/go.sum index 17e9a8d..646a775 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wX github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= 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/disintegration/imaging v1.6.2 h1:w1LecBlG2Lnp8B3jk5zSuNqd7b4DXhcjwek1ei82L+c= +github.com/disintegration/imaging v1.6.2/go.mod h1:44/5580QXChDfwIclfc/PCwrr44amcmDAg8hxG0Ewe4= github.com/faiface/beep v1.0.2 h1:UB5DiRNmA4erfUYnHbgU4UB6DlBOrsdEFRtcc8sCkdQ= github.com/faiface/beep v1.0.2/go.mod h1:1yLb5yRdHMsovYYWVqYLioXkVuziCSITW1oarTeduQM= github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= @@ -101,6 +103,8 @@ golang.org/x/exp v0.0.0-20180710024300-14dda7b62fcd h1:nLIcFw7GiqKXUS7HiChg6OAYW golang.org/x/exp v0.0.0-20180710024300-14dda7b62fcd/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81 h1:00VmoueYNlNz/aHIilyyQz/MHSqGoWJzpFv/HW8xpzI= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8 h1:hVwzHzIUGRjiF7EcUjqNxk3NCfkPxbDKRdnNE1Rpg0U= +golang.org/x/image v0.0.0-20191009234506-e7c1f5e7dbb8/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= golang.org/x/mobile v0.0.0-20180806140643-507816974b79 h1:t2JRgCWkY7Qaa1J2jal+wqC9OjbyHCHwIA9rVlRUSMo= golang.org/x/mobile v0.0.0-20180806140643-507816974b79/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4=