Ruby FFI bindings for libogg, the OGG container format library.
- Ruby 3.1+
- libogg installed on your system
macOS:
brew install liboggDebian/Ubuntu:
sudo apt-get install libogg-devFedora/RHEL:
sudo dnf install libogg-develAdd this line to your application's Gemfile:
gem"ogg-ruby"And then execute:
bundle installOr install it yourself as:
gem install ogg-rubyrequire"ogg"stream=Ogg::StreamState.new(1)# serial number# Add packets to the streampacket=Ogg::Packet.new(data: "Hello, OGG!",bos: true,granulepos: 0,packetno: 0)stream.packetin(packet)packet2=Ogg::Packet.new(data: "More data",eos: true,granulepos: 1,packetno: 1)stream.packetin(packet2)# Extract pagespages=[]while(page=stream.flush)pages << page.to_sendstream.clearrequire"ogg"sync=Ogg::SyncState.new# Write encoded data into syncsync.write(encoded_page_data)# Extract pageswhile(page=sync.pageout)# Create a stream decoder with the same serial numberstream=Ogg::StreamState.new(page.serialno)stream.pagein(page)# Extract packetswhile(packet=stream.packetout)putspacket.dataendstream.clearendsync.clearlibogg functions are not thread-safe. Do not share SyncState or StreamState objects across threads without external synchronization.
The gem is available as open source under the terms of the MIT License.