mccoyst / ogg Goto Github PK
View Code? Open in Web Editor NEWGo package for encoding/decoding OGG streams
License: MIT License
Go package for encoding/decoding OGG streams
License: MIT License
It's actually good now, so write it up.
I have just encoded a wav file to ogg using oggenc version 1.4.0. This package reports a bad CRC when reading that file. Same results with various other .ogg files I have downloaded from the Internet. I've been looking at the spec and the code and can't see anything obviously wrong.
Look at this more closely: https://freac.org/developer-blog-mainmenu-9/14-freac/277-fastcrc
i have ffmpeg transcode stdout
cmd:=exec.Command("ffmpeg","-re", "-i","http://ice912.echo.msk.ru:9120/stream", "-acodec","libopus","-ab","32k", "-ar","48000","-f","s16le","pipe:1")
serr, efdd := cmd.StderrPipe()
stdp, perr := cmd.StdoutPipe()
fmt.Println("ffmpeg start")
//cmder:=cmd.Run()
cmder := cmd.Start()
time.Sleep(250 * time.Millisecond)
fmt.Printf("ffmpeg start %+v", cmd.ProcessState)
//o,e:=cmd.CombinedOutput()
//fmt.Printf("ffmpeg stop,%s,,err %s\n",o,e)
f, f_err := os.OpenFile("/home/kino/opustest2.ogg", os.O_CREATE|os.O_RDWR, os.ModePerm)
if f_err != nil {
return f_err
}
fibd := bufio.NewWriter(f)
buffer := bufio.NewReader(stdp)
fmt.Printf("buf init buffered %s", buffer.Buffered())
if perr != nil {
fmt.Printf("process create err %s,", perr)
return perr
}
if cmder != nil {
return cmder
}
// Sleep for a specified amount of time before playing the sound
time.Sleep(250 * time.Millisecond)
and i can't understud how incopsulate opus in ogg.
please help me
See #3.
00000000: 4f67 6753 0002 0000 0000 0000 0000 50d7 OggS..........P.
00000010: 2f8d 0000 0000 9774 7857 0113 4f70 7573 /......txW..Opus
00000020: 4865 6164 0102 3801 80bb 0000 0000 004f Head..8........O
00000030: 6767 5300 0000 0000 0000 0000 0050 d72f ggS..........P./
00000040: 8d01 0000 0032 eb58 1701 3f4f 7075 7354 .....2.X..?OpusT
00000050: 6167 730d 0000 004c 6176 6635 382e 3736 ags....Lavf58.76
00000060: 2e31 3030 0100 0000 1e00 0000 656e 636f .100........enco
00000070: 6465 723d 4c61 7663 3538 2e31 3334 2e31 der=Lavc58.134.1
00000080: 3030 206c 6962 6f70 7573 4f67 6753 0000 00 libopusOggS..
d := ogg.NewDecoder(bytes.NewReader([]byte{0x4f, 0x67, 0x67, 0x53, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0xd7, 0x2f, 0x8d, 0x00, 0x00, 0x00, 0x00, 0x97, 0x74, 0x78, 0x57, 0x01, 0x13, 0x4f, 0x70, 0x75, 0x73, 0x48, 0x65, 0x61, 0x64, 0x01, 0x02, 0x38, 0x01, 0x80, 0xbb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4f, 0x67, 0x67, 0x53, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x50, 0xd7, 0x2f, 0x8d, 0x01, 0x00, 0x00, 0x00, 0x32, 0xeb, 0x58, 0x17, 0x01, 0x3f, 0x4f, 0x70, 0x75, 0x73, 0x54, 0x61, 0x67, 0x73, 0x0d, 0x00, 0x00, 0x00, 0x4c, 0x61, 0x76, 0x66, 0x35, 0x38, 0x2e, 0x37, 0x36, 0x2e, 0x31, 0x30, 0x30, 0x01, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x65, 0x6e, 0x63, 0x6f, 0x64, 0x65, 0x72, 0x3d, 0x4c, 0x61, 0x76, 0x63, 0x35, 0x38, 0x2e, 0x31, 0x33, 0x34, 0x2e, 0x31, 0x30, 0x30, 0x20, 0x6c, 0x69, 0x62, 0x6f, 0x70, 0x75, 0x73}))
for {
p, err := d.Decode()
if err != nil {
if errors.Is(err, io.EOF) {
break
}
panic(err)
}
fmt.Println(p.Type, p.Granule, p.Serial, p.Packets)
}
2 0 2368722768 [[79 112 117 115 72 101 97 100 1 2 56 1 128 187 0 0 0 0 0]]
0 0 2368722768 [[79 112 117 115 84 97 103 115 13 0 0 0 76 97 118 102 53 56 46 55 54 46 49 48 48 1 0 0 0 30 0 0 0 101 110 99 111 100 101 114 61 76 97 118 99 53 56 46 49 51 52 46 49 48 48 32 108 105 98 111 112 117 115]]
package main
import (
"fmt"
"os"
"github.com/mccoyst/ogg"
)
func main() {
f, err := os.Open(os.Args[1])
if err != nil {
panic(err)
}
decoder := ogg.NewDecoder(f)
var encoder *ogg.Encoder
for {
page, err := decoder.Decode()
if err != nil {
fmt.Fprint(os.Stderr, err)
break
}
if encoder == nil {
encoder = ogg.NewEncoder(page.Serial, os.Stdout)
encoder.EncodeBOS(page.Granule, page.Packet)
} else {
encoder.Encode(page.Granule, page.Packet)
}
}
}
./copy a.ogg > b.ogg
This code decode a stream, encodes it to stdout.
ogginfo
works well with my original stream, but doesn't handle the output stream.
Link to godoc.org, etc.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.