Eenie meenie chili beanie, the spirits are about to speak. Full
Moose Power here at your service. High-level hoomin
gonca has elsewhere alluded to the magnitude of this incredible force.
Nobody calls me meenie!
Rocky's brain is aching this morning so I will take over while he takes cover. It is after yesterday's lunch, dontcha know? And watch out, I'm having liver for breakfast. Shut up, not Moose liver!
Here is what we did to achieve 1ms sync accuracy for MONSTERS_UNIVERSITY. Just so you know, the concept came from my awesome
Moose Mind and the coding and concept testing came from
Rocky. Silly billies, the plan is to do the cuts in the uncompressed domain, where we have cut granularity at the audio sample level and can avoid all the disgusting buffering/GOP/timestamp issues altogether. Presto!
1. Demux the THD stream without correcting the gaps but instead generate a cutlist file that specifies the cuts to be made (indexed by time). Of course the raw THD is demuxed as usual (we'll call it file.thd). The cutlist is in the form of a sox-compatible trim list. Don't forget that the cutlist is generated using our
SUPER SECRET Bresenham-like algorithm but implemented for audio instead of pixels (
https://www.cs.helsinki.fi/group/goa/ma ... esenh.html). Moving the next pixel up or not is equivalent to removing audio or not. No attempt is made to identify duplicate audio frames or other such nonsense (what if a stream has valid repeated frames?). Oops, not secret anymore. Here is an example that specifies cuts of 1 second at time 5, and 4 seconds at time 8 (in practice these are specified with submillisecond accuracy):
trim 0 =5 =6 =8 =12
You can read the sox manual to understand the syntax. OK, we now have a wonderful cutlist conceived through the incredible power of the
Moose. You can see the actual cutlist for MONSTERS in the next post.
2 (usually follows 1). Now we transcode the THD file to W64. That's an easy one (ignore warnings):
ffmpeg -i file.thd -c:a pcm_s24le -ar 48000 -rf64 never file.w64
3. Now we simply apply the cutlist to file.w64. For a while there
Sherman was going to write a utility to do that (
cough) but then in an amazing burst of brilliant
Moose Intellect I discovered that sox.exe can do this. Kinda explains why I made the cutlist in sox-compatible syntax. Got it? Hoomins can be slow but think it over.
sox file.w64 trimmed.w64 trim
cutlist
Of course
cutlist here is simply cut-and-pasted from the step 1 cutlist file. Ha! Fans of all that is good and correct, we now have a wonderful in-sync w64 file that we can use directly if we want. But most hoomins are smart enough to know that we should probably make a FLAC file, so...
4. Transcode the adjusted file to FLAC:
ffmpeg -i trimmed.w64 trimmed.flac
And
Bob's yer uncle!
It has not escaped the
Powerful Moose's attention that this process can be fully automated. We can distribute ffmpeg and sox as long as the proper incantations are included per licenses.
ffmpeg and sox.
The smartest hoomins (few and far between) are thinking: uh, if you can cut at sample level, why isn't the sync within one sample duration (0.02ms)? Good question. It all depends on the Bresenham threshold that we use. Currently, we are using 1ms. If we make it too small then the cutlist becomes too large and CMD falls over when we try to include it in a sox command line. See, y'all, the power of the
Moose?
Bow down in humble acclamation!
Finally, I am itching to exercise my new mod powers so if someone could be so kind as to misbehave I would be a really grateful
Moose. Now that I am a mod I don't have to play Mr Civil anymore.
Curly would say nyuk nyuk. And if you could really misbehave maybe we could have a stomping, only if absolutely necessary of course. Snort!