View Single Post
Old 2010-04-18, 02:12   Link #156
JEEB
Bishoujo fanatic
*Fansubber
 
 
Join Date: May 2007
Location: Finland / Japan
After seeing that someone had problems with FLAC in Matroska with ordered chapters (segment linking) on CCCP's support channel, and that I happened to meet this problem myself as well when creating such files -- I'll just tell you this small General Public Announcement (since people still seem to be producing files that have problems in certain cases):

Please, pretty please -- do make sure your audio stream has IDR'ish audio frames' borders set on the chapter points. This doesn't actually limit itself to FLAC, but lossless audio formats overall seem to have longer frame lengths, which makes the end results be quite audible.

You will not lose quality or any audio if you do this right. You might lose some compression because of the possible 'extra' audio frame made, but this shouldn't concern you that much as the loss is very, very small. Also, making files that play correctly on most players without using any hacks or workflow that might worsen quality is IMHO the easier way to go here -- even if this might feel like a problem that's either related to FLAC-in-Matroska or the Haali's splitter (I will have to question the latter person on this some day).

Otherwise, if you do not heed this warning, you will have the probability of actually creating a file that not only might have:
  • A/V desynch after the first 'comeback' from a linked segment on certain decoders (ffdshow's FLAC decoder sure has this -- granted, this can be fixed with just switching to the MPC-HC's internal decoder, but that one definitely has its own problems which make it impossible to recommend as a solution).
  • Audio and video coming out of the wrong side of the segment link for as much as the audio frame. A Haali splitter's "feature", you will get the video and audio played from the other side of the segment link as the audio frames go. This might go unnoticed depending on the content, but it surely is there.

How to not fail:
  1. Encode your video with IDR frames on the chapter points frame-wise, Matroska output recommended.
  2. mkvinfo -s encode.mkv | grep I > IDRframes.txt (Outputs filtered mkvinfo's output of all IDR frames in the Matroska file; get grep for windows from, say, Nicholi's Msys/Mingw package if you don't have it in your path already)
  3. AvsP's time output on the frames might be flaky, so get your frames' real timecodes in the Matroska file from the IDRframes.txt file.
  4. Use the timecodes in the chapter xml file.
  5. Encode the audio either per-trim from Avisynth and cat with mkvmerge -- or insert audio frames' borders on those spots, if possible, from the FLAC command line encoder. You can mux the audio stream into matroska to check it for sure by using the same technique as used with getting the video stream's IDR frames.
  6. Mux video, audio and chapters
  7. ???
  8. Profit!
Personally I was lazy and encoded audio in parts and then stitched it up. Worked in mplayer and the usual DirectShow suspects, but might theoretically break, as the mkvmerge's output will tell you. Also fixes the a/v desynch in ffdshow as well as the other problem mentioned.
__________________
I'm human, no debug | Unofficial x264 builds
JEEB is offline