Ejemplo n.º 1
0
func main() {
	flag.Parse()
	if *in == "" {
		flag.Usage()
		return
	}
	for i := 0; i < *encoders; i++ {
		ch := make(chan encjob, 0)
		chans = append(chans, ch)
		ech := make(chan int, 0)
		endchans = append(endchans, ech)
		go encoder(ch, ech)
	}
	r, err := os.Open(*in)
	defer r.Close()
	if err != nil {
		log.Fatalf("Unable to open file '%s'", *in)
	}
	var wm webm.WebM
	reader, err := webm.Parse(r, &wm)
	if err != nil {
		log.Fatal("Unable to parse file: ", err)
	}
	vtrack := wm.FindFirstVideoTrack()
	vstream := webm.NewStream(vtrack)
	splitter := webm.NewSplitter(reader.Chan)
	splitter.Split(vstream)
	write(vstream.VideoChannel())
}
Ejemplo n.º 2
0
func (a *app) OnInit() {
	var err error
	a.r, err = os.Open(*in)
	if err != nil {
		log.Fatalf("Unable to open file '%s': %s", *in, err)
	}
	var wm webm.WebM
	a.reader, err = webm.Parse(a.r, &wm)
	if err != nil {
		log.Fatal("Unable to parse file: ", err)
	}
	a.duration = wm.GetDuration()
	var vtrack *webm.TrackEntry
	if !*justaudio {
		vtrack = wm.FindFirstVideoTrack()
	}
	var vstream *webm.Stream
	if vtrack != nil {
		vstream = webm.NewStream(vtrack)
		a.fduration = vtrack.GetDefaultDuration()
		a.vchan = vstream.VideoChannel()
	}
	var atrack *webm.TrackEntry
	if !*justvideo {
		atrack = wm.FindFirstAudioTrack()
	}
	var astream *webm.Stream
	if atrack != nil {
		astream = webm.NewStream(atrack)
	}
	splitter := webm.NewSplitter(a.reader.Chan)
	splitter.Split(astream, vstream)

	a.steps = uint(0xffffffff)
	a.img = <-a.vchan
	a.pimg = a.img

	chk := func(err error) {
		if err != nil {
			panic(err)
		}
	}
	if atrack != nil {
		channels := int(atrack.Audio.Channels)
		a.aw = &AudioWriter{ch: astream.AudioChannel(),
			channels: channels, active: true}
		a.pastream, err = portaudio.OpenDefaultStream(0, channels,
			atrack.Audio.SamplingFrequency, 0, a.aw)
		chk(err)
		chk(a.pastream.Start())
	}
}