examples fix path
This commit is contained in:
parent
d16d14210e
commit
147fdb7d93
@ -1,39 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"github.com/nareix/joy4/av"
|
|
||||||
"github.com/nareix/joy4/av/avutil"
|
|
||||||
"github.com/nareix/joy4/format"
|
|
||||||
)
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
format.RegisterAll()
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
file, _ := avutil.Open("projectindex.flv")
|
|
||||||
|
|
||||||
streams, _ := file.Streams()
|
|
||||||
for _, stream := range streams {
|
|
||||||
if stream.Type().IsAudio() {
|
|
||||||
astream := stream.(av.AudioCodecData)
|
|
||||||
fmt.Println(astream.Type(), astream.SampleRate(), astream.SampleFormat(), astream.ChannelLayout())
|
|
||||||
} else if stream.Type().IsVideo() {
|
|
||||||
vstream := stream.(av.VideoCodecData)
|
|
||||||
fmt.Println(vstream.Type(), vstream.Width(), vstream.Height())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for i := 0; i < 10; i++ {
|
|
||||||
var pkt av.Packet
|
|
||||||
var err error
|
|
||||||
if pkt, err = file.ReadPacket(); err != nil {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
fmt.Println("pkt", i, streams[pkt.Idx].Type(), "len", len(pkt.Data), "keyframe", pkt.IsKeyFrame)
|
|
||||||
}
|
|
||||||
|
|
||||||
file.Close()
|
|
||||||
}
|
|
||||||
|
|
@ -1,45 +0,0 @@
|
|||||||
package main
|
|
||||||
|
|
||||||
import (
|
|
||||||
"github.com/nareix/joy4/av"
|
|
||||||
"github.com/nareix/joy4/av/transcode"
|
|
||||||
"github.com/nareix/joy4/format"
|
|
||||||
"github.com/nareix/joy4/av/avutil"
|
|
||||||
"github.com/nareix/joy4/cgo/ffmpeg"
|
|
||||||
)
|
|
||||||
|
|
||||||
// need ffmpeg with libfdkaac installed
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
format.RegisterAll()
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
infile, _ := avutil.Open("speex.flv")
|
|
||||||
|
|
||||||
findcodec := func(stream av.AudioCodecData, i int) (need bool, dec av.AudioDecoder, enc av.AudioEncoder, err error) {
|
|
||||||
need = true
|
|
||||||
dec, _ = ffmpeg.NewAudioDecoder(stream)
|
|
||||||
enc, _ = ffmpeg.NewAudioEncoderByName("libfdk_aac")
|
|
||||||
enc.SetSampleRate(stream.SampleRate())
|
|
||||||
enc.SetChannelLayout(av.CH_STEREO)
|
|
||||||
enc.SetBitrate(12000)
|
|
||||||
enc.SetOption("profile", "HE-AACv2")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
trans := &transcode.Demuxer{
|
|
||||||
Options: transcode.Options{
|
|
||||||
FindAudioDecoderEncoder: findcodec,
|
|
||||||
},
|
|
||||||
Demuxer: infile,
|
|
||||||
}
|
|
||||||
|
|
||||||
outfile, _ := avutil.Create("out.ts")
|
|
||||||
avutil.CopyFile(outfile, trans)
|
|
||||||
|
|
||||||
outfile.Close()
|
|
||||||
infile.Close()
|
|
||||||
trans.Close()
|
|
||||||
}
|
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user