[ / / / / / / / / / / / / / ] [ dir / animu / feel9k / general / had / komica / mde / vg / voros ][Options][ watchlist ]

/tech/ - Technology

You can now write text to your AI-generated image at https://aiproto.com It is currently free to use for Proto members.
Email
Comment *
File
Select/drop/paste files here
Password (Randomized for file and post deletion; you may also set your own.)
* = required field[▶ Show post options & limits]
Confused? See the FAQ.
Expand all images

File (hide): a3e8c5429726645⋯.png (230 KB, 2510x1430, 251:143, opus-logo.png) (h) (u)

[–]

 No.996723>>996729 >>996978 [Watch Thread][Show All Posts]

Before I roll my own program, need to double-check:

Is it true that there's currently no solution for sample-accurate lossless cutting of Ogg/Opus files?

There is vcut for Ogg/Vorbis, which, not surprisingly, only works with Ogg/Vorbis but not with Ogg/Opus.

I also tested ffmpeg and it's neither accurate nor lossless and also produces files with invalid duration metadata. (I mean, of course I use -c copy, but when cutting Opus stream, one has to leave alone a few packets at the beginning to let the decoder converge before using its output and ffmpeg doesn't do that because the pre-skip value is still 312 while it clearly should be more when seeking to a middle of a stream; source: https://tools.ietf.org/html/rfc7845.html)

I'm too lazy to write (and read) in C in order to patch any of these, so that's out of question currently.

It seems the format itself isn't too complicated and the actual cutting doesn't require any computation intensive stuff so there's probably no problem doing that in Python (and that will remove all unnecessary troubles related to compilation and packaging and reduce chances of doing some nasty shit like memory corruption) but it's still quite a lot of spec reading and coding, so it'd be dumb to do this only to find it was unnecessary in the end.

 No.996729>>996932

>>996723 (OP)

I don't know of solutions, though I'd take a least effort approach to the problem.

ffmpeg -> alternate losless format -> cut -> encode as ogg/opus

/2¢


 No.996734>>996932

I've never messed around opus, but I've looked into it due to how space-efficient it is. Have you tried looking into the official opus library documentation? It's pretty well done http://www.opus-codec.org/docs/opus_api-1.2/index.html


 No.996760>>996763 >>996932

>Before I roll my own program

don't roll your own, just add this Ogg/Opus support to Mp3splt http://mp3splt.sourceforge.net/mp3splt_page/home.php


 No.996763>>996932

>>996760

It'd be better to fix ffmpeg than your literally-who software.


 No.996879>>996932 >>999525

HOW TO NORMALIZE or GAIN, ogg/opus and webm/opus FILES?

you can do that with aac and mp3 with MP3GAIN. how about opus?

also interested in normalizing ogg/vorbis

of course I'm talking about LOSSLESS normalization


 No.996909>>996932

If you want sample accuracy, use FLAC.


 No.996932>>1000675

>>996729

transcoding isn't a solution, obviously, because of generation loss.

>>996734

the closest thing there is is https://www.opus-codec.org/docs/opus_api-1.2/groupopusrepacketizer.html which doesn't do that (but probably can be useful as a low level primitive)

>>996760

the page doesn't even load with TLS

>>996763

true; if I could/had enough time to deal with a huge C codebase

>>996879

ReplayGain tagging is how you do it, and then player uses that information on playback time to do what you want. foobar2000 can do that, and also there's a Python package that can do that too.

>>996909

you don't understand what that means probably.

FLAC is fine and good for archive but too big size for portable shit.


 No.996978>>997022

>>996723 (OP)

Is that even possible? If you want sample accuracy you would have to decode each frame, as you can't interact with it on a per-sample basis. I think to do this sample-accurately you would have to decode, then re-encode each packet.


 No.997022>>997314

>>996978

It's possible because you can use special side-channel data to instruct decoder to drop specific number of samples at the beginning and at the end of stream.

See these parts of the specification:

> 4.2. Pre-skip

> ...

> The 'pre-skip' field MAY also be used to perform sample-accurate

> cropping of already encoded streams. In this case, a value of at

> least 3840 samples (80 ms) provides sufficient history to the decoder

> that it will have converged before the stream's output begins.

and

> 4.4. End Trimming

>

> The page with the 'end of stream' flag set MAY have a granule

> position that indicates the page contains less audio data than would

> normally be returned by decoding up through the final packet. This

> is used to end the stream somewhere other than an even frame

> boundary. The granule position of the most recent audio data page

> with completed packets is used to make this determination, or '0' is

> used if there were no previous audio data pages with a completed

> packet. The difference between these granule positions indicates how

> many samples to keep after decoding the packets that completed on the

> final page. The remaining samples are discarded. The number of

> discarded samples SHOULD be no larger than the number decoded from

> the last packet.


 No.997314>>997468

>>997022

Oh that's pretty neat. Looking through the opus library docs they don't even have a method to interact with that. The smallest slice of data it deals with is a frame.

Looking through the docs though, the section you pointed out is from the ogg spec, so you probably want to be thinking about libogg. This shit is over my head, but https://xiph.org/ogg/doc/framing.html is probably worth a read through.

Under

>absolute granule position

>The position specified is the total samples encoded after including all packets finished on this page

I don't see anything for offset so you can ignore samples at the start but, that seems to be where you would look. Also https://xiph.org/ogg/doc/libogg/ogg_packet.html is the object where you specify granulepos


 No.997468>>997481 >>1000675

>>997314

.opus files are actually an ogg container

and opus audio is hardly ever stored in any other container except this and mkv (and mkv also supports something similar AFAIK)


 No.997481>>997822

>>997468

I know. I'm just saying you would be working with the container's api, rather than dealing with the codec


 No.997822

>>997481

this is true but one needs to take into account some properties of Opus, it's written in the spec (you need to leave at least 80ms pre-skip to let it converge, and if I got this right it also measures positions in samples as the sample rate is always 48000)

if it could work simply with any codec if it's in Ogg container then vcut could work with Opus-encoded files but afaik it doesn't


 No.999525>>999602

>>996879

I didn't feel like jumping through hoops to get gain working with questionable playback support and went with ogg/vobis instead.


 No.999602

>>999525

>questionable playback support

it works everywhere basically

or are you still using fixed-function portable players or something


 No.1000675>>1000679

>>997468

>.opus files are actually an ogg container

>and opus audio is hardly ever stored in any other container except this and mkv (and mkv also supports something similar AFAIK)

when you download opus audio from youtube with youtube-dl it is stored in .webm container

how to convert it to ogg opus?

>>996932

>ReplayGain tagging is how you do it, and then player uses that information on playback time to do what you want. foobar2000 can do that, and also there's a Python package that can do that too.

replaygain is piece of shit. player might use it or not.


 No.1000679>>1000955

>>1000675

>when you download opus audio from youtube with youtube-dl it is stored in .webm container

webm is a mkv subset

> how to convert it to ogg opus?

ffmpeg, for example, can do that

>replaygain is piece of shit

extraordinary claims require extraordinary evidence.


 No.1000872>>1000947

Off-topic, but I don't want to start another opus thread:

Does anyone know of a library that can be used to mix together opus streams? I'm writing a small webconferencing webapp using webrtc, but I want to have a way to record the call with all participants mixed together in the same stream.

Looking at the opus C library docs, it doesn't look too hard to decode the stream, check for voice activity, add the pcm values together, then re-encode it. However; I'd rather not have to write any C, or do any low level shit myself. I looked around, but there doesn't seem to be any higher-level libraries for dealing with opus like this


 No.1000947>>1000962

>>1000872

re-encoding is the only way if you want to have 1 track in the output

(thus generational loss and all that)

you can instead just store them separately into a multi track file, this can be done losslessly

if you really want to mix them, there's nothing specific to Opus as this will be the same with any other codec.


 No.1000955>>1001706

>>1000679

I'm not him but I think he's saying the whole idea of replaygain is shit because the music players may or may not be compatible to replaygain. If this is his argument, then this is a shit argument.


 No.1000962>>1000964 >>1001706

>>1000947

I know I'd have to re-encode, just wondering if there are any tools that could handle that whole process for me. It seems like a fairly common use-case given opus' common use in radio/videoconferencing. The Multistream API in the C library seems like it hints at this use, but for filesize and simplicity reasons I'd rather mix everything into the same channel than have one or two dozen channels for each call participant.

I don't think such a library exists though, and I'm kind of glad. It'll be a fun little project, I don't usually work with things at a low level, and I haven't touched C since college. I'll probably release it as free software once I'm done, and maybe add a few more high-level features that people would want when interacting with opus streams.


 No.1000964

>>1000962

>one or two dozen channels for each call participant

*one or two dozen channels, one for for each call participant


 No.1001706>>1001722 >>1002007

>>1000955

just use the music players which are compatible. others are going to disappear or change anyway.

yeah this was a shit argument.

>>1000962

I didn't do this but I may guess that gstreamer can do it. Also Mumble uses Opus and IIRC it had record function, and it's open source.


 No.1001722>>1001739

>>1001706

I remember how my replaygain tags don't seem to work with opus, while every other music container format worked nicely. Apparently it was due to how foobar tagged opus files, in a manner that poweramp didn't seem to get. Looked it up on the hydrogenaud.io forums and IIRC the opus format does not specify a tag for replaygain due to some intentional braindead design decisions by xiph or someone


 No.1001739

>>1001722

Just use ogg opus, m8. Working good here.


 No.1002007

>>1001706

Gstreamer looks like exactly what I want, there's a plugin called liveadder that looks exactly like what I'm trying to do. Thank you very much. And if I can't make that work, your mumble suggestion is also very helpful, I could just port mumble's record function to a webrtc client




[Return][Go to top][Catalog][Screencap][Nerve Center][Cancer][Update] ( Scroll to new posts) ( Auto) 5
26 replies | 0 images | Page ???
[Post a Reply]
[ / / / / / / / / / / / / / ] [ dir / animu / feel9k / general / had / komica / mde / vg / voros ][ watchlist ]