Skip to content
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
28 changes: 14 additions & 14 deletions av/avconv/avconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import (
"fmt"
"io"
"time"
"github.com/nareix/joy4/av/avutil"
"github.com/nareix/joy4/av"
"github.com/nareix/joy4/av/pktque"
"github.com/nareix/joy4/av/transcode"

"github.com/youminxue/joy4/av"
"github.com/youminxue/joy4/av/avutil"
"github.com/youminxue/joy4/av/pktque"
"github.com/youminxue/joy4/av/transcode"
)

var Debug bool

type Option struct {
Transcode bool
Args []string
Args []string
}

type Options struct {
Expand All @@ -23,7 +24,7 @@ type Options struct {

type Demuxer struct {
transdemux *transcode.Demuxer
streams []av.CodecData
streams []av.CodecData
Options
Demuxer av.Demuxer
}
Expand Down Expand Up @@ -56,10 +57,10 @@ func (self *Demuxer) prepare() (err error) {
}

/*
var streams []av.CodecData
if streams, err = self.Demuxer.Streams(); err != nil {
return
}
var streams []av.CodecData
if streams, err = self.Demuxer.Streams(); err != nil {
return
}
*/

supports := self.Options.OutputCodecTypes
Expand All @@ -83,7 +84,7 @@ func (self *Demuxer) prepare() (err error) {
ok = true

var enctype av.CodecType
for _, typ:= range supports {
for _, typ := range supports {
if typ.IsAudio() {
if enc, _ = avutil.DefaultHandlers.NewAudioEncoder(typ); enc != nil {
enctype = typ
Expand Down Expand Up @@ -152,7 +153,7 @@ func ConvertCmdline(args []string) (err error) {
flagt = false
var f float64
fmt.Sscanf(arg, "%f", &f)
duration = time.Duration(f*float64(time.Second))
duration = time.Duration(f * float64(time.Second))

default:
output = arg
Expand Down Expand Up @@ -223,7 +224,7 @@ func ConvertCmdline(args []string) (err error) {
}
filterdemux := &pktque.FilterDemuxer{
Demuxer: convdemux,
Filter: filters,
Filter: filters,
}

for {
Expand Down Expand Up @@ -252,4 +253,3 @@ func ConvertCmdline(args []string) (err error) {

return
}

2 changes: 1 addition & 1 deletion av/avutil/avutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import (
"strings"
"fmt"
"bytes"
"github.com/nareix/joy4/av"
"github.com/youminxue/joy4/av"
"net/url"
"os"
"path"
Expand Down
2 changes: 1 addition & 1 deletion av/pktque/buf.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package pktque

import (
"github.com/nareix/joy4/av"
"github.com/youminxue/joy4/av"
)

type Buf struct {
Expand Down
27 changes: 15 additions & 12 deletions av/pktque/filters.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@

// Package pktque provides packet Filter interface and structures used by other components.
package pktque

import (
"time"
"github.com/nareix/joy4/av"

"github.com/youminxue/joy4/av"
)

type Filter interface {
Expand All @@ -30,8 +30,8 @@ func (self Filters) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoid
// Wrap origin Demuxer and Filter into a new Demuxer, when read this Demuxer filters will be called.
type FilterDemuxer struct {
av.Demuxer
Filter Filter
streams []av.CodecData
Filter Filter
streams []av.CodecData
videoidx int
audioidx int
}
Expand Down Expand Up @@ -81,9 +81,9 @@ func (self *WaitKeyFrame) ModifyPacket(pkt *av.Packet, streams []av.CodecData, v

// Fix incorrect packet timestamps.
type FixTime struct {
zerobase time.Duration
incrbase time.Duration
lasttime time.Duration
zerobase time.Duration
incrbase time.Duration
lasttime time.Duration
StartFromZero bool // make timestamp start from zero
MakeIncrement bool // force timestamp increment
}
Expand Down Expand Up @@ -114,14 +114,14 @@ func (self *FixTime) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoi
// Drop incorrect packets to make A/V sync.
type AVSync struct {
MaxTimeDiff time.Duration
time []time.Duration
time []time.Duration
}

func (self *AVSync) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoidx int, audioidx int) (drop bool, err error) {
if self.time == nil {
self.time = make([]time.Duration, len(streams))
if self.MaxTimeDiff == 0 {
self.MaxTimeDiff = time.Millisecond*500
self.MaxTimeDiff = time.Millisecond * 500
}
}

Expand Down Expand Up @@ -172,20 +172,23 @@ func (self *AVSync) check(i int) (start time.Duration, end time.Duration, correc

// Make packets reading speed as same as walltime, effect like ffmpeg -re option.
type Walltime struct {
firsttime time.Time
firsttime time.Time
firstSleep time.Duration
}

func (self *Walltime) ModifyPacket(pkt *av.Packet, streams []av.CodecData, videoidx int, audioidx int) (drop bool, err error) {
if pkt.Idx == 0 {
if self.firsttime.IsZero() {
self.firsttime = time.Now()
self.firstSleep = pkt.Time
return
}
pkttime := self.firsttime.Add(pkt.Time)
sub := (pkt.Time.Nanoseconds() - self.firstSleep.Nanoseconds()) / 1000
pkttime := self.firsttime.Add(time.Duration(sub) * time.Microsecond)
delta := pkttime.Sub(time.Now())
if delta > 0 {
time.Sleep(delta)
}
}
return
}

5 changes: 3 additions & 2 deletions av/pubsub/queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
package pubsub

import (
"github.com/nareix/joy4/av"
"github.com/nareix/joy4/av/pktque"
"io"
"sync"
"time"

"github.com/youminxue/joy4/av"
"github.com/youminxue/joy4/av/pktque"
)

// time
Expand Down
24 changes: 12 additions & 12 deletions av/transcode/transcode.go
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@

// Package transcoder implements Transcoder based on Muxer/Demuxer and AudioEncoder/AudioDecoder interface.
package transcode

import (
"fmt"
"time"
"github.com/nareix/joy4/av"
"github.com/nareix/joy4/av/pktque"

"github.com/youminxue/joy4/av"
"github.com/youminxue/joy4/av/pktque"
)

var Debug bool

type tStream struct {
codec av.CodecData
timeline *pktque.Timeline
codec av.CodecData
timeline *pktque.Timeline
aencodec, adecodec av.AudioCodecData
aenc av.AudioEncoder
adec av.AudioDecoder
aenc av.AudioEncoder
adec av.AudioDecoder
}

type Options struct {
Expand All @@ -27,7 +27,7 @@ type Options struct {
}

type Transcoder struct {
streams []*tStream
streams []*tStream
}

func NewTranscoder(streams []av.CodecData, options Options) (_self *Transcoder, err error) {
Expand Down Expand Up @@ -108,7 +108,7 @@ func (self *tStream) audioDecodeAndEncode(inpkt av.Packet) (outpkts []av.Packet,
}

// Do the transcode.
//
//
// In audio transcoding one Packet may transcode into many Packets
// packet time will be adjusted automatically.
func (self *Transcoder) Do(pkt av.Packet) (out []av.Packet, err error) {
Expand Down Expand Up @@ -150,8 +150,8 @@ func (self *Transcoder) Close() (err error) {
// Wrap transcoder and origin Muxer into new Muxer.
// Write to new Muxer will do transcoding automatically.
type Muxer struct {
av.Muxer // origin Muxer
Options // transcode options
av.Muxer // origin Muxer
Options // transcode options
transcoder *Transcoder
}

Expand Down Expand Up @@ -195,7 +195,7 @@ type Demuxer struct {
av.Demuxer
Options
transcoder *Transcoder
outpkts []av.Packet
outpkts []av.Packet
}

func (self *Demuxer) prepare() (err error) {
Expand Down
6 changes: 3 additions & 3 deletions cgo/ffmpeg/audio.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ import (
"runtime"
"fmt"
"time"
"github.com/nareix/joy4/av"
"github.com/nareix/joy4/av/avutil"
"github.com/nareix/joy4/codec/aacparser"
"github.com/youminxue/joy4/av"
"github.com/youminxue/joy4/av/avutil"
"github.com/youminxue/joy4/codec/aacparser"
)

const debug = false
Expand Down
4 changes: 2 additions & 2 deletions cgo/ffmpeg/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ import (
"fmt"
"image"
"reflect"
"github.com/nareix/joy4/av"
"github.com/nareix/joy4/codec/h264parser"
"github.com/youminxue/joy4/av"
"github.com/youminxue/joy4/codec/h264parser"
)

type VideoDecoder struct {
Expand Down
2 changes: 1 addition & 1 deletion codec/aacparser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package aacparser

import (
"github.com/nareix/bits"
"github.com/nareix/joy4/av"
"github.com/youminxue/joy4/av"
"time"
"fmt"
"bytes"
Expand Down
8 changes: 4 additions & 4 deletions codec/codec.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package codec

import (
"github.com/nareix/joy4/av"
"github.com/nareix/joy4/codec/fake"
"time"

"github.com/youminxue/joy4/av"
"github.com/youminxue/joy4/codec/fake"
)

type PCMUCodecData struct {
Expand Down Expand Up @@ -50,7 +51,7 @@ func (self SpeexCodecData) PacketDuration(data []byte) (time.Duration, error) {
// libavcodec/libspeexdec.c
// samples = samplerate/50
// duration = 0.02s
return time.Millisecond*20, nil
return time.Millisecond * 20, nil
}

func NewSpeexCodecData(sr int, cl av.ChannelLayout) SpeexCodecData {
Expand All @@ -61,4 +62,3 @@ func NewSpeexCodecData(sr int, cl av.ChannelLayout) SpeexCodecData {
codec.ChannelLayout_ = cl
return codec
}

2 changes: 1 addition & 1 deletion codec/fake/fake.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package fake

import (
"github.com/nareix/joy4/av"
"github.com/youminxue/joy4/av"
)

type CodecData struct {
Expand Down
2 changes: 1 addition & 1 deletion codec/h264parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
package h264parser

import (
"github.com/nareix/joy4/av"
"github.com/youminxue/joy4/av"
"github.com/nareix/bits"
"github.com/nareix/bits/pio"
"fmt"
Expand Down
10 changes: 4 additions & 6 deletions examples/audio_decode/main.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

package main

import (
"github.com/nareix/joy4/av"
"github.com/nareix/joy4/format"
"github.com/nareix/joy4/av/avutil"
"github.com/nareix/joy4/cgo/ffmpeg"
"github.com/youminxue/joy4/av"
"github.com/youminxue/joy4/av/avutil"
"github.com/youminxue/joy4/cgo/ffmpeg"
"github.com/youminxue/joy4/format"
)

// need ffmpeg installed
Expand Down Expand Up @@ -37,4 +36,3 @@ func main() {

file.Close()
}

15 changes: 8 additions & 7 deletions examples/http_flv_and_rtmp_server/main.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
package main

import (
"sync"
"io"
"net/http"
"github.com/nareix/joy4/format"
"github.com/nareix/joy4/av/avutil"
"github.com/nareix/joy4/av/pubsub"
"github.com/nareix/joy4/format/rtmp"
"github.com/nareix/joy4/format/flv"
"sync"

"github.com/youminxue/joy4/av/avutil"
"github.com/youminxue/joy4/av/pubsub"
"github.com/youminxue/joy4/format"
"github.com/youminxue/joy4/format/flv"
"github.com/youminxue/joy4/format/rtmp"
)

func init() {
Expand Down Expand Up @@ -78,7 +79,7 @@ func main() {

if ch != nil {
w.Header().Set("Content-Type", "video/x-flv")
w.Header().Set("Transfer-Encoding", "chunked")
w.Header().Set("Transfer-Encoding", "chunked")
w.Header().Set("Access-Control-Allow-Origin", "*")
w.WriteHeader(200)
flusher := w.(http.Flusher)
Expand Down
Loading