mirror of
https://github.com/pion/webrtc.git
synced 2025-09-27 03:25:58 +08:00
Fix OpusWriter issues that break VLC
* Correctly calculate page CRC Ogg uses slightly non-standard version of CRC, we are unable to use the Go's version. You can see the details here[0], in summary "direct algorithm, initial val and final XOR = 0, generator polynomial=0x04c11db7" [0] https://xiph.org/vorbis/doc/framing.html * Properly set EOS value Before we created a new page with an EOS. Instead seek backwards and update the last page with valid Opus to have EOS header and re-generate the CRC * Only use 0 timestamp/granule for headers Audio itself should start from 0 * Rename OpusWriter -> OggWriter Ogg supports more then just Opus, renaming gives us the flexibility to expand in the future.
This commit is contained in:
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/pion/webrtc/v2"
|
||||
"github.com/pion/webrtc/v2/pkg/media"
|
||||
"github.com/pion/webrtc/v2/pkg/media/ivfwriter"
|
||||
"github.com/pion/webrtc/v2/pkg/media/opuswriter"
|
||||
"github.com/pion/webrtc/v2/pkg/media/oggwriter"
|
||||
|
||||
"github.com/pion/webrtc/v2/examples/internal/signal"
|
||||
)
|
||||
@@ -68,7 +68,7 @@ func main() {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
opusFile, err := opuswriter.New("output.opus", 48000, 2)
|
||||
oggFile, err := oggwriter.New("output.ogg", 48000, 2)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -95,7 +95,7 @@ func main() {
|
||||
codec := track.Codec()
|
||||
if codec.Name == webrtc.Opus {
|
||||
fmt.Println("Got Opus track, saving to disk as output.opus (48 kHz, 2 channels)")
|
||||
saveToDisk(opusFile, track)
|
||||
saveToDisk(oggFile, track)
|
||||
} else if codec.Name == webrtc.VP8 {
|
||||
fmt.Println("Got VP8 track, saving to disk as output.ivf")
|
||||
saveToDisk(ivfFile, track)
|
||||
@@ -112,7 +112,7 @@ func main() {
|
||||
} else if connectionState == webrtc.ICEConnectionStateFailed ||
|
||||
connectionState == webrtc.ICEConnectionStateDisconnected {
|
||||
|
||||
closeErr := opusFile.Close()
|
||||
closeErr := oggFile.Close()
|
||||
if closeErr != nil {
|
||||
panic(closeErr)
|
||||
}
|
||||
|
Reference in New Issue
Block a user