View Full Version : DTS-HD & PGS Subtitle Cutting Help
thecoreyburton
2nd May 2016, 19:43
I'm currently in the (very lengthy) process of ripping a lot of my blu-ray disks to my hard drives as mkv files and I've done lots of tests regarding audio and video quality to find the best values suited for my experience. My process (when filtering isn't required) is often simply to rip the titles with MakeMKV and then encode them. I've found that in regards to audio, the original uncompressed DTS-MA is the only option I don't perceive flaws in (it could be a placebo effect type situation, but lets assume it isn't). Additionally, the videos I'm about to talk about have non-english sections and I like using Handbrake's "Foreign Audio Scan" option for a default subtitle track along with the full English subtitles as a secondary option just in case.
The problem is that several of the movies and shows I'm ripping have unnecessary logos or advertisements at the start of the video stream. Normally I'd just load up the clips into avisynth with ffvideosource and add a quick trim(x,y) to solve the problem and then use AVFS to mount and then encode to x264 with Handbrake. The audio can't be passed through as DTS-MA anymore because of the processing; so it'd have to be re-encoded. The subtitles aren't present.
What's the best way to go about applying the same trim I used for the video track in avisynth to the original tracks so I don't have to re-encode them?
At the moment, my options are:
A) Re-encode the audio (I'm content most of the time though during action scenes I really notice the audio quality decrease and it does irk me a little) and forgo the subtitles.
B) Mux the original audio and subtitles into the output file with a delay of something like -45000ms (based on the frames I trimmed).
Neither is really ideal, are there any other options in regards to either trimming the audio and subtitles to match the avisynth script without re-encoding them OR trimming the video, audio and subtitles all at once to a specific frame without avisynth?
asarian
2nd May 2016, 23:33
A bit of a nitpick, perhaps, but there's actually no such thing as 'uncompressed DTS-MA.' DTS (any kind) is by definition always compressed audio.
You can, however, just use eac3to, for instance, to convert your DTS-MA track to lossless LPCM (which will be far more easier to cut into).
thecoreyburton
3rd May 2016, 05:08
Thank you for your reply! It's alright to be picky, especially when I used a term incorrectly! It was late when I was writing that and in my head I was thinking uncompressed from the source (not re-encoded and re-compressed) as opposed to uncompressed audio itself, so it was my mistake. I've never really worked with surround formats until now.
What about transcoding back? Would it be practical to convert the streams back to the DTS-MA at a similar bitrate (I know there'll be some quality loss due to the transcoding process, but I'm not actually familiar with the format itself other than the fact it's the highest quality available on the disk). I'm considering 16-bit FLAC for the output if all else fails, some of my devices don't seem to like LPCM.
Ideally I'd like to leave it untouched but the cutting process doesn't help!
asarian
3rd May 2016, 05:42
Thank you for your reply! It's alright to be picky, especially when I used a term incorrectly! It was late when I was writing that and in my head I was thinking uncompressed from the source (not re-encoded and re-compressed) as opposed to uncompressed audio itself, so it was my mistake. I've never really worked with surround formats until now.
What about transcoding back? Would it be practical to convert the streams back to the DTS-MA at a similar bitrate (I know there'll be some quality loss due to the transcoding process, but I'm not actually familiar with the format itself other than the fact it's the highest quality available on the disk). I'm considering 16-bit FLAC for the output if all else fails, some of my devices don't seem to like LPCM.
Ideally I'd like to leave it untouched but the cutting process doesn't help!
Transcoding back?! Good luck finding a non-commercial DTS-MA encoder! :) (And the ones you can buy cost like $1500 dollars). Also, it's not necessary: the LPCM track will be lossless, and you can easily 'cut' in it. And FLAC, while I believe it can do 8 channel HD audio, can't be parsed over HDMI; so that would be problematic.
As for devices not liking LPCM, HDMI will always support LPCM (up to 8 channels). FLAC, however, not so much.
thecoreyburton
3rd May 2016, 08:00
I was afraid of that! Well, either way, that certainly deals with the audio portion of things! Thank you!
Now I've just got to work out how to trim PGS subtitles so I can have the foreign bits subtitled in English!
sneaker_ger
3rd May 2016, 10:31
I don't understand why he'd want to use eac3to. Adding even more steps to the work flow won't make anything simpler than his option "B)" (using delay option of e.g. mkvmerge to mux in original audio and subtitles).
Music Fan
3rd May 2016, 12:32
You can cut the original videos with TSMuxer, it does not re-encode.
If yo have to re-encode some parts, you can append them to the not re-encoded parts, but for this they need of course the same characteristics.
thecoreyburton
3rd May 2016, 13:30
Grabbing it now and will do a few test runs to see if it covers everything. Is it frame-accurate? MKVToolNix, for instance, has a similar function but from experience it's not always spot on and sometimes there are negative effects.
Edit: It does what I want for the most part. The video, audio and subtitles are cut evenly. The cutting feature requires a timestamp (unless there's another feature I missed), but that's not the issue - the problem is that It appears to do what MKVToolNix does and snap to a specific frame. Say I had a logo or advertisement at the start of my clip that went for 250 frames / 10.427 seconds, after which the actual video I wish to keep fades in. If I enter any number between 10 seconds and 11 seconds it seems to automatically snap to frame "267", for example (which is the first non-black frame in that range). If I repeatedly drop the number by increments of 0.001, I get no change in the resulting video until I pass a certain threshold and two seconds or so of the end of the logo/ad appears at the start of my video.
Music Fan
3rd May 2016, 17:13
As it does not re-encode, it means the cut is done on a keyframe (probably the closest to the specified time-code).
I don't understand if you want to remove parts with logos (and thus shorten the video) or re-encode these parts to erase the logo (with a mask or blurring it). If you don't want to remove any part but only re-encode some parts to erase a logo, you can ;
-demux audio and subtitles
-cut video in several parts
-re-encode the (short) parts you want to modify
-gather all video parts (click on open for the first, append for the others)
-remux video with audio and subtitles (all steps with TSMuxer).
thecoreyburton
3rd May 2016, 18:06
Ah, that does explain it.
When I say remove a logo or advertisement, I'm not talking about a watermark. I'm talking about a full-frame video section that states the name of the network the show originally aired on and then shows a few seconds of clips from other shows on that network. At the end of this, the screen fades to black and then fades back in with the show's title sequence. Sometimes the logos vary and are shorter or do not contain the advertisements for other shows, but they're usually at the start of the episodes. My goal is to encode the episode from the fade in, to the end of the file. Trim(100,0) would work fine in regular circumstances (with 100 being an example value) but because avisynth doesn't load in the subtitles they'd remain untrimmed. In most cases these sections are short and un-intrusive, but in some cases they go for over a minute long and should be removed.
The audio portion of the problem has been solved via lossless re-encode from the script's output.
From all the help I've gotten so far, I think currently my best option is to:
-load the video into avisynth, apply the trim and encode both audio (lossless) and video (h264)
-use either MKVToolNix or TSMuxer to remux the original video with an appropriate cut - my goal here is to get as close to the avisynth cut as possible without going past it, so if necessary, go to the previous keyframe rather than the next.
-demux the subtitles from the resulting file and remux them into the encoded video.
-compensate for the delay between both cuts.
I think that's as precise as I can get at the moment.
sneaker_ger
3rd May 2016, 18:18
You are over-thinking this. Mkvmerge only needs to cut at video keyframes if you are actually cutting a video which you are not.
1.) write AviSynth script for video only with Trim() and encode through e.g. HandBrake
2.) Open resulting file from 1) and original file in mkvtoolxnix (gui). Deactivate video track of original file. Set (negative) delay for audio and subtitle track that equals the trim(). Mux. Done.
DTS-HD is preserved. Cut was frame-accurate. Everything is in sync.
thecoreyburton
3rd May 2016, 18:28
So my original plan B's the best bet? No adverse effects from having a negative delay almost a minute long?
If, consider this problem solved and thank you all!
sneaker_ger
3rd May 2016, 18:29
So my original plan B's the best bet? No adverse effects from having a negative delay almost a minute long?
Correct.
Music Fan
4th May 2016, 09:54
You don't have to re-encode the whole video just to cut a minute.
Use TSMuxer or MKVmerge to cut where you want.
And if there is no keyframe in the fade you are talking about, cut on the closest keyframe before this fade and make the process I explained above. It will be fast and only a few seconds of video will be re-encoded.
But in my opinion, that's a loss of time, you can simply fast forward the video to avoid the short part you don't want to see, or simply add a chapter in the fade, I believe it works even when it's not located on a keyframe (you can do this with TSMuxer when exporting as AVCHD or Blu-ray or with MKVmerge).
If the GOPs are not very long, the closest keyframe to the fade won't be far, a few seconds away and maybe less than one second.
I mean you can cut the debut anyway (if it is one minute long) but don't lose your time to re-encode the first GOP just to cut a few seconds before the fade that you want to become the debut.
sneaker_ger
4th May 2016, 09:58
Maybe he wants to re-encode anyways?
Music Fan
4th May 2016, 11:37
Maybe but I understood he only wanted to remove unwanted short parts.
thecoreyburton
4th May 2016, 12:58
I do want to re-encode the video because whilst space it isn't a large factor of my concerns, is still something I'm wary of. I quite quickly filled up a bunch of 4tb drives with only half of my blu-ray collection backed up to my disks. In regards to the video, I mentioned in my first post I'd done quite a lot of tests regarding quality. I'm happy with CRF values ranging from 15-19 at 1080p, depending on the content (usually 18 will do the trick nicely). I only chose to omit this information originally because I didn't feel it overly relevant to the question. Because of this, I also want to remove the unnecessary advertisements and network logos that come before the episodes of some shows. I figured avisynth was my best bet and was unaware on how incorporate a trim for the audio and subtitles without re-encoding them, originally, but better solutions have since been presented.
If you'd like any more information you're welcome to ask!
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.