Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Gapless encoding to Ogg Vorbis - anything I have to be aware of? (Read 14357 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #25
Yep, I know that I could also use foobar2000 for transcoding, but as I am a programmer, I like to have the full control with scripts anyway, so I prefer having my own batch file that fires the encoding processes.

I'd like to know and understand any detail that is involved, as much as possible. That's also why I asked that question in that thread here. I know, with the correct players my music already worked gapless before, but I wanted to look behind and understand what's going on, and if I can even improve.

Well I guess, foobar2000 will do nothing more than also just the default command line settings of the encoders, right? Is there any way to prove that, like some log file where I can see the commands used to encode the files?

Nevertheless, I prefer having my batch file, that I can adjust completely free and just double click to let transcoding begin :)

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #26
Okay, I found out, if I select an encoder from the foobar2000 convert-dialog, and then select "Custom", the fields are filled with the command line switches obviously used for the encoder selected before. So I could see that foobar just uses the Lame Default settings with the selected quality setting plus the --noreplaygain switch. Which is actually just fine for me, because I don't use replaygain at all, and if I would, I would not use it based on the single track gain, because normally I listen to complete albums.

Well, I encoded two albums at once to MP3 using foobar.

After that I wrote a batch file where I encoded track by track with single calls of Lame, same quality setting (V0) as used in foobar2000 and of course also the --noreplaygain switch.

I wanted to see, if there are any differences in the results, maybe foobar2000 could feed the encoder with one big stream of the whole album, to improve gapless playback. If this would have been the case, the resulting files would be different from those encoded individually from cmd.

But there are not any differences. I used WinMerge to compare the encoded files of foobar2000 with those from cmd, and it tells me that all files are binary identical.

I see this as a proof, that foobar2000 actually does the same like when I encode each file individually via command line.

I still find it sort of cool, running my batch file and let it encode all files in the console, but I think in this case, foobar2000 is the winner of the match, because it can automatically transfer the metadata to the encoded files when finished encoding.

So I think, I'm gonna use foobar2000 for my transcoding, in contrast to what I said first, that I would prefer having my batch file running.

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #27
Wanted to test the same thing with Ogg Vorbis. There is that -s command line switch in oggenc2, that seems to be fed with a random number by foobar2000. The internet says, this switch forces including a serial number into the output stream, and this is primary used for testing. I don't have a clue why foobar2000 uses that switch.

Any idea? I think this switch is the reason why I can't get binary identical output files when encoding vorbis from cmd. Because of the random number. What's the exact point of that -s switch?

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #28
Ogg chaining requires each chained file to have unique serial number.

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #29
So, the other way around, what would be the problem if to consecutive Ogg Vorbis files had the same serial number? I don't really understand what that serial number is used for.

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #30
A program opening the file would not know about its special nature without fully decoding it. It depends on programming what would happen but it could show wrong file duration and playback could end at the end of the first stream.

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #31
So this is actually more than just a feature for testing, like i read somewhere else?

Next question: What is a Vorbis stream? Or would the word "Ogg-Stream" be correct here? I don't really have any deeper knowledge about ogg and vorbis. Does an ogg Vorbis file consist of many streams that are played after each other? Or is a stream just the actual audio data of the file (so, without metadata and so on).

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #32
I think lack of a unique serial number would mean that you couldn't later append the ogg files into a single file without editing the number.

In practice I don't know if it matters. Chaining files is rarely used and a lot of software doesn't support it anyway.

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #33
An Ogg file can optionally consist of multiple streams literally just concatenated together.  Streams may also be multiplexed so, for example, a video and an audio stream can have pages interlaced.  The serial number is obviously important in those cases.  Concatenated streams in a single file are referred to as chained.  You're most likely to see this in an internet stream where they just throw one track after another at you in a continuous flow of bytes.

oggenc should generate unique serial numbers all on its own, whether for different running instances or for multiple streams chained within the same file.  Perhaps it didn't do this at some point, or perhaps foobar is just being paranoid.  Maybe it is something specific to the way foobar encodes?

Having the same serial number for multiple streams within the same file can cause problems for decoders in some circumstances.  You may see things like incorrect stream lengths reported, or seeking may get borked.  It isn't common, but then it shouldn't happen because the serial number is supposed to be unique.   I've run into it by creating test chained files using streams with the same serial number, but I can't remember exactly the things that broke.

 

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #34
So what an encoder for gapless "should" do (not that I claim failing to do so will produce annoying artifacts), is
- know what track selection constitutes an "album"
- encode each album as single track
- split into individual files
?

The next question is: what piece of software will do so?
If none do in one operation: is it possible to encode to image-with-cuesheet using one application, and automatically split by cuesheet using another, bringing it down to two batch operations?

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #35
So what an encoder for gapless "should" do (not that I claim failing to do so will produce annoying artifacts), is
- know what track selection constitutes an "album"
- encode each album as single track
- split into individual files
?

The next question is: what piece of software will do so?
If none do in one operation: is it possible to encode to image-with-cuesheet using one application, and automatically split by cuesheet using another, bringing it down to two batch operations?
I think you're overthinking this :)  A lossless codec knows exactly where the start and end of each track is, down to the exact sample (implicitly, it doesn't require any special mechanism).  Transcoding to a lossy format simply requires a mechanism to identify the exact starting and ending sample, or time, so that a decoder can play the first sample of one track seamlessly following from the last sample of the previous track.  If you have a single lossless file plus cuesheet, nothing has really changed so long as the lossless decoder understands where the track boundaries are.

Ogg Vorbis has that built in, you don't need to do anything special, you don't need to encode in any special order or known anything about albums.  MP3 doesn't have that built into the codec definition, but Lame has come up with a mechanism that is widely supported.  AAC also doesn't include such information, and more than one method of storing track boundaries in metedata is in use, which leads to difficulties when the encoder and decoder don't use the same scheme.

The old MP3 -nogap option did something different because it (or at least decoders) didn't have the means to identify the track boundaries properly.  It actually overlapped the track starts and ends, which obviously required tracks to be transcoded in order and could cause artefacts if the tracks were played individually.  Your three steps of what a gapless encode "should" do describes this, but it isn't the way any "modern" encoder works. So, to answer your last question, the only encoder I know of that will do these things is Lame with -nogap, but since it is an obsolete approach the point is perhaps moot.

Re: Gapless encoding to Ogg Vorbis - anything I have to be aware of?

Reply #36
I think expecting 100% transparent gapless from MP3 overlooks the fact that MP3 is a lossy format that cannot 100% ensure transparency.  All LAME can do is make sure that your input file has the correct number of samples, not that the quantization error at the track transition will be masked.

This isn't a problem with gapless though, its just how lossy audio works.
This.

Now to meander a little beyond...
A little research should provide a massive amount of information (this has been discussed heavily, in fact it is the topic that brought me to this forum some 15 years ago).  Anyway, here are a couple topics I pulled more or less at random to get people thinking:
https://hydrogenaud.io/index.php/topic,18211.msg179288.html
https://hydrogenaud.io/index.php/topic,35654.0.html