Comments (12)
Sorry, what issue are you having?
from opus.
Sorry, I pressed enter to fast by mistake.
I'm having issues packaging the encoded opus data into Ogg packets, especially how to create ID and Comment headers in Objective-C/Swift. And I'm having a hard time finding examples of how to do it.
from opus.
Do these help?
https://github.com/xiph/opus-tools/blob/master/src/opus_header.c
https://github.com/xiph/opus-tools/blob/master/src/opusenc.c#L1134
from opus.
Here's another example:
https://github.com/mozilla/gecko-dev/blob/master/dom/media/encoder/OpusTrackEncoder.cpp#L70
from opus.
Yes, well I went through all of that. I guess I will have to learn C to get this to work.
from opus.
The spec for the format is https://tools.ietf.org/html/draft-ietf-codec-oggopus if you haven't looked at that. If there's anything unclear, please let me know. Or I can answer specific questions. I don't know any swift, so I can't help with direct examples.
from opus.
Yes so I'm having trouble creating ID and Comment Headers in Objective C from this part:
/*Write header*/
===============================================================================
{
unsigned char header_data[100];
int packet_size=opus_header_to_packet(&header, header_data, 100);
op.packet=header_data;
op.bytes=packet_size;
op.b_o_s=1;
op.e_o_s=0;
op.granulepos=0;
op.packetno=0;
ogg_stream_packetin(&os, &op); #### ID Header? ####
while((ret=ogg_stream_flush(&os, &og))){
if(!ret)break;
ret=oe_write_page(&og, fout);
if(ret!=og.header_len+og.body_len){
fprintf(stderr,"Error: failed writing header to output stream\n");
exit(1);
}
bytes_written+=ret;
pages_out++;
}
===============================================================================
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
comment_pad(&inopt.comments, &inopt.comments_length, comment_padding);
op.packet=(unsigned char *)inopt.comments;
op.bytes=inopt.comments_length;
op.b_o_s=0;
op.e_o_s=0;
op.granulepos=0;
op.packetno=1;
ogg_stream_packetin(&os, &op); #### Comment Header? ####
}
/* writing the rest of the opus header packets */
while((ret=ogg_stream_flush(&os, &og))){
if(!ret)break;
ret=oe_write_page(&og, fout);
if(ret!=og.header_len + og.body_len){
fprintf(stderr,"Error: failed writing header to output stream\n");
exit(1);
}
bytes_written+=ret;
pages_out++;
}
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Are my marks correct that the upper part is for creating the ID Header and the lower for Comment Header?
If so, what is the oe_enc_opt inopt;
? In which file can I find it?
from opus.
Are my marks correct that the upper part is for creating the ID Header and the lower for Comment Header?
The first section converts an OpusHeader struct to an ogg packet and writes it out to the stream. The second does the same for an array of strings containing the message data key-value pairs. So they create the headers and write them to the stream, but the code you've quoted doesn't actually constuct the OpusHeader or comment structures or fill in any data. You'll need to do that to get valid output.
If so, what is the
oe_enc_opt inopt;
?
This is a parameter structure filled in during opusenc's long argument parsing section, which isn't very easy to read. It's declared in https://github.com/xiph/opus-tools/blob/master/src/opusenc.h#L23
from opus.
Aha, so the comment is constructed with this function:
static void comment_pad(char **comments, int* length, int amount)
{
if(amount>0){
int i;
int newlen;
char* p=*comments;
/*Make sure there is at least amount worth of padding free, and
round up to the maximum that fits in the current ogg segments.*/
newlen=(*length+amount+255)/255*255-1;
p=realloc(p,newlen);
if(p==NULL){
fprintf(stderr,"realloc failed in comment_pad()\n");
exit(1);
}
for(i=*length;i<newlen;i++)p[i]=0;
*comments=p;
*length=newlen;
}
}
I don't seem to find oe_enc_opt
in libopus.a/libogg.a. Do I need to add some header files?
Thanks for your help.
from opus.
static void comment_pad(char **comments, int* length, int amount)
Sort of. This adds padding to the end of the comment data. See comment_init() and comment_add() for the rest of the implementation.
I don't seem to find oe_enc_opt in libopus.a/libogg.a. Do I need to add some header files?
Perhaps confusingly, neither libopus nor libogg provide code for the id and comment header generation. This code is from the opus-tools project. You'd need to borrow or re-implement what's there. https://github.com/xiph/opus-tools/
from opus.
Okay, I'm sorry but can you be more specific on what is needed to create the id and comment header and perhaps just point out the elements that are used in opus-tools?
from opus.
Sorry for dropping the thread. See for example:
https://github.com/xiph/opus-tools/blob/master/src/opus_header.c#L219
https://github.com/mozilla/gecko-dev/blob/master/dom/media/encoder/OpusTrackEncoder.cpp#L70
https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/oggenc.c#L381
https://github.com/FFmpeg/FFmpeg/blob/master/libavcodec/libopusenc.c#L80
from opus.
Related Issues (20)
- arm build with meson fails with: Unknown variable "opus_arm_may_have_dotprod" HOT 4
- opus/meson.build:636:24: ERROR: File dnn/fargan_data.h does not exist. HOT 2
- LACE / NoLACE and DRED on Fixed Point implementations? HOT 10
- autogen downloads latest model data every time HOT 2
- Missing opus 1.5 github release HOT 4
- Windows: Meson build fails with nnet_avx2.c compiled without AVX2 HOT 23
- Compiling libopus 1.5.1 with Linux fails on ARM Cortex-A53 and Cortex-A55 HOT 21
- opus 1.5.1-1 seems to be incompatible with musescore 4.2.1 HOT 1
- Question about DRED HOT 4
- Undefined reference to opus_select_arch HOT 2
- opus_repacketizer_cat sometimes fails
- Limiting the stack allocation request HOT 2
- Please update opus-tools to support new features
- Deep PLC performance on Android HOT 16
- Compiling with CMake for Windows/MSVC only supports DLL runtime libraries HOT 9
- Added the OPUS_SET_INBAND_FEC(2) option HOT 1
- Please provide an option to not depend on downloading model data HOT 10
- v1.5.2 compile warnings
- Error: Range coder state mismatch between encoder and decoder in frame 1: 0x f3b1240 vs 0x40123b0f HOT 1
- Opus.lib: 1.3.1 version crashing in some windows machines in opus_encoder_create HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from opus.