lisamelton / video_transcoding

Tools to transcode, inspect and convert videos.
MIT License
2.37k stars 159 forks source link

Don's re-muxing #259

Open vr8hub opened 5 years ago

vr8hub commented 5 years ago

Long ago in a galaxy far, far away… (It was a few days and it was here, but that doesn't have the same je ne sais quoi.)

… you showed me a sample (handbuilt) log and remux command. I have some questions about the remux command.

I'm asking because I don't know the ins and outs of any of the third-party players (VLC, Plex, Kodi, mpv, etc.), because I've always used iTunes here-to-date. I'm just trying to determine what is personal preference vs what is needed/suggested/works better with various players.

File 'MARVEL'S AVENGERS- INFINITY WAR - BLU-RAY_t00.mkv': container: Matroska
Track ID 0: video (MPEG-4p10/AVC/h.264)
Track ID 1: audio (FLAC) (English DTS-HD MA lossless conversion)
Track ID 2: audio (DTS) (English DTS core of DTS-HD MA)
Track ID 3: audio (AC-3) (English) AD
Track ID 4: audio (AC-3)
Track ID 5: audio (AC-3)
Track ID 6: audio (AC-3)
Track ID 7: audio (AC-3) (English) Commentary
Track ID 8: subtitles (HDMV PGS) (English) SDH
Track ID 9: subtitles (HDMV PGS)
Track ID 10: subtitles (HDMV PGS)
Track ID 11: subtitles (HDMV PGS)
Track ID 12: subtitles (HDMV PGS) (English) Commentary SDH
Track ID 13: subtitles (HDMV PGS) (French) Commentary
Track ID 14: subtitles (HDMV PGS) (Spanish) Commentary
Track ID 15: subtitles (HDMV PGS) (Portuguese) Commentary
Track ID 16: subtitles (HDMV PGS) (English) Forced
Track ID 17: subtitles (HDMV PGS) (French) Forced
Track ID 18: subtitles (HDMV PGS) (Spanish) Forced
Track ID 19: subtitles (HDMV PGS) (Portuguese) Forced
Chapters: 20 entries

mkvmerge --output 'Avengers_ Infinity War (2018).mkv'
         --track-order 0:0,0:1,0:2,0:3,0:4,0:5,0:6,0:7,0:16,0:8,0:9… (and so on)
         --compression -1:none
         --title ''
         --default-track 0
         --default-track 16
         --forced-track 16
         --track-name 3:AD
         --track-name 7:Commentary
         --subtitle-tracks 16,8,9,10,11,12,13,14,15,17,18,19
         --track-name 16:Forced
         --track-name 8:SDH
         --track-name 12:'Commentary SDH'
         --track-name 13:Commentary
         --track-name 14:Commentary 
         --track-name 15:Commentary 
         --track-name 17:Forced 
         --track-name 18:Forced 
         --track-name 19:Forced 
         --no-chapters "MARVEL'S AVENGERS- INFINITY WAR - BLU-RAY_t00.mkv" 
         --chapters "MARVEL'S AVENGERS- INFINITY WAR - BLU-RAY_t00.mkv.chapters.xml"
  1. Why no title?
  2. Was there a reason you didn't specify the language as part of --track-name on the tracks (both audio and video) where it was non-English?
  3. You don't use the chapters in the original MKV and specify it externally here. Was there a reason you didn't specify them in MakeMKV when building the gen1 .mkv? And I'm curious why you're specifying them at all, since you told me in the next message that messing with chapter names led to madness and not the good kind.
  4. You move the forced (lang) track to the front of the subtitle track line, in addition to specifying it as a default track and a forced track. Does moving it matter when you do the other two, or do some players need it to be physically first as well?

Thanks for the education. I'm dumping some of the space my high school calculus takes up in my brain to make room for all this. So far the calculus was easier.

lisamelton commented 5 years ago

@vr8hub Great questions! Here we go...

  1. There's no media title embedded as metadata (which I assume is what you're asking) because it's not needed since both Plex and Kodi will look up the metadata based on the filename. In fact, having an embedded media title, especially the one provided by MakeMKV, can screw up both Plex and Kodi because they'll sometime prefer that over the filename.

  2. I didn't specify the language because it's already in the ripped file from MakeMKV so there's no reason to repeat that. In fact, doing so is a good way to make a mistake because that mkvmerge command line of mine is already a mile long.

  3. MakeMKV is annoying about how it handles auto-generated chapter names, prepending a "0" to single-digit numbers. So I have a script which extracts the chapters (deceptively titled "extract-chapters.sh" (which I can include here if you want)) and reformats the names to match the auto-generated chapter name behavior of HandBrake (because, you know, anal retentive here). This also saves a shitload of time editing them by hand in the always delightful (sarcasm alert!) MakeMKV UI.

  4. Ding! Ding! Ding! You guessed it! There are some players (or at least there were) who need the forced subtitle first or they just ignore it like the second two "Matrix" films which... uhhh... were never actually made.

Lucky for me I never took calculus then! :)

Any other questions?

samhutchins commented 5 years ago

In fact, having an embedded media title, especially the one provided by MakeMKV, can screw up both Plex and Kodi because they'll sometime prefer that over the filename.

They'll often prefer it in my experience, and it took me a long time to figure out what the hell was going on.

lisamelton commented 5 years ago

@samhutchins Ouch! Yeah, I feel your pain. I must have wasted a day banging my head against my desk when that first happened to me.

vr8hub commented 5 years ago
  1. I meant the title '' portion of the command. Sooooooo, are you saying Plex/Kodi are using the name of the file as the movie title instead of the metadata in the file? But in this case, for example, "Marvel's Avengers: Infinity Wars" is the name, but the colon isn't in the filename because the file system(s) won't handle it. What does that do? And your and Sam's messages came in while I was typing this — I guess I still don't understand what problem y'all encountered. It doesn't make sense to me not to have the name of the movie in the movie file.

  2. So, for example, VLC instead of showing "Track 13 - [French]" in the gen1 .mkv would show "Commentary - [French]" in the gen2 .mkv? (The "Commentary" specified in the --track-name taking the place of the "Track 13" in the default.) So making "Commentary (French)" the --track-name would be redundant because it would then show up as "Commentary (French) - [French]". That makes sense.

  3. So you extract the chapters and create another chapters .xml file not to give the chapters names, but to strip the leading 0 from the non-chapter names "chapters 0-9"? Uh, ok, don't mind those men in the white coats coming up behind you.

Nothing to do with anything—what does the AD stand for in track 3? I tried to do some searching to figure it out, but "AD" makes for a lousy search term.

samhutchins commented 5 years ago

And your and Sam's messages came in while I was typing this — I guess I still don't undertand what problem y'all encountered.

The problem I have was that MakeMKV would often set the title in the metadata to "MARVEL'S THE AVENGERS" or "Seinfeld DISC ONE" or something, and when HandBrake transcodes that MKV it copies the title over. When Plex indexes it it finds the correct metadata online, but it uses the title in the file sometimes (but not always). This means that it would show up with the embedded name in my otherwise nicely formatted list of films

samhutchins commented 5 years ago

For complete clarity, I want the title to be "The Avengers", not "MARVEL'S THE AVENGERS"

vr8hub commented 5 years ago

@samhutchins My question isn't whether to leave what MakeMKV sets it to (which I agree, is wrong in many but not all cases), my question is why would I set it to nothing? Why wouldn't I set it to what I want it to be (which I've been doing)? IOW, if I set the title, then the title is "correct." I don't understand what problems would be caused by doing that.

(I used Don's example on purpose. The title is "Marvel's Avengers: Infinity Wars". It has a colon. That colon doesn't make it to the file system. Therefore the filename doesn't actually represent the real movie name. Or what I want the real movie name to be.)

samhutchins commented 5 years ago

@vr8hub I make it empty so that Plex will always show whatever it finds when it looks it up on tmdb, but I think setting it to the correct title is equally valid (and probably better, I'm just lazy)

samhutchins commented 5 years ago

@vr8hub Something that might cause issues, for me at least on Windows, is if any of the metadata has non-English characters. For some titles with non-english track names transcode-video fails with some encoding error I've never been able to get to the bottom of. Not often a problem with film names, but something I've come across with audio tracks

vr8hub commented 5 years ago

@samhutchins Ah, OK, thanks. To be clear, I'm not arguing what should be done, just trying to figure out what matters, i.e. impacts media players, etc. If having the "correct" title in title is OK, I'm going to do that. (Having a blank title bothers me as much as having leading zeroes on chapter names seems to bother @donmelton.)

lisamelton commented 5 years ago

@vr8hub ...

  1. What @samhutchins said. And to expand on that, Plex and Kodi ignore punctuation when they use the filename to look up the actual title and all that juicy metadata like the cover art. My filename has an underscore there (which, again, they'll ignore) just to remind me that it use to be colon. TL;DR: embedding media titles is fraught with dangers. Use https://www.themoviedb.org/ and https://www.thetvdb.com/ to make sure your filenames are correct instead. And don't forget to include the year for movie titles!

  2. Yes and yes. Avoid redundancy and repeating yourself. :)

  3. Those white coat bastards haven't caught me yet! Mwahahahaha! :)

Nothing to do with anything—what does the AD stand for in track 3? I tried to do some searching to figure it out, but "AD" makes for a lousy search term.

See: https://en.wikipedia.org/wiki/Audio_description

That's the audio track with someone talking over everything to describe it to blind listeners. It's commonly referred to as the "AD" track.

vr8hub commented 5 years ago

Grrrr. I can tell I'm going to have issues with this. \<rant>I don't want years in my movie titles. I shouldn't have to have years in my movie titles. The only reason I should have to have years is when there are two movies of the same name, which happens seldom in my catalog. And I shouldn't have to have it then: in the absence of the year, they should be defaulting to the first one. Because remakes are a lazy and lousy way to make a living, with the notable (single) exception of the Judy Garland "A Star is Born".\<\rant>

Nevertheless, thanks to both of you for all the info and insight. If I ignore it and cause problems, it will be on my head, not yours.

vr8hub commented 5 years ago

This doesn't directly have anything to do with the remux…

I choose all of the subtitle tracks in MakeMKV when creating gen1 .mkv. IOW, both regular subtitles and forced subtitles. But in the ensuing gen1 .mkv, none of the tracks are identified as forced. (mediainfo and mkvmerge --identify both show forced=No on every track.) Why is that? I know I can specify forced in the remux, but why weren't they noted as forced in the original file? What am I missing? (Right, that would fill the Pacific; what am I missing about this particular issue?)

I have ignoreForcedSubtitlesFlag="false" in my MakeMKV profile, in case it matters.

lisamelton commented 5 years ago

@vr8hub I didn't like the year thing at first either but after awhile you learn to embrace the inconvenience and annoyance. :)

Where is the MakeMKV profile located again? I forget. I haven't looked at mine in years.

OK, MakeMKV can only sometimes correctly identify and set the flag for forced subtitles. Why is this? This is actually not the fault of MakeMKV. It's the fault of the dumbasses who master discs. And apparently they seem to be in the majority out there.

This is why you need to examine every subtitle to find out which ones are forced for which language. Sometimes extracting them and examining them with utilities like SUBtools. (See: http://www.emmgunn.com/subtools-home/ )

It's just that easy! :)

Seriously and fortunately, the author of MakeMKV started sometime last year to embed "Count of elements" metadata for each subtitle. You can find this easily using mediainfo. And if you ever see a subtitle with a low number of elements, that's a good indicator (although not a guarantee!) that it's a forced subtitle.

lisamelton commented 5 years ago

@vr8hub BTW, I hope this dissuades you from thinking you can ever fully automate the ripping process. It's just not possible.

That's why my process for each disc is:

  1. Figure out which title(s) to rip. (Harder than you might imagine sometimes.)

  2. Rip every freakin' track on each title.

  3. Try to fix everything during the remux. Keeping a ball-peen hammer close by with which to pound myself in the head as necessary when I examine the rip.

  4. Take a drink. (Actually, that's a pretty good first step.)

vr8hub commented 5 years ago

@donmelton No, I didn't think I could fully automate it. At this point I'm not even sure I can fully understand it.

E.g., I'm looking at a rip I did this week of LOTR. Subtitle track 1 is the full English subtitles. Subtitle track 2 looks like it's the forced track. BUT, at certain points, people's names associated with the movie (Jackson, Boyer, Walsh, etc.) appear on the top portion of the window (subtitles are obviously on the bottom portion). What's up with that? Further, each of the other three English tracks all appear to be forced as well, but different names appear at different places. WHAT??

It appears that each of those forced tracks go along with the four commentary tracks; the names are who's talking at that point. But why isn't there a forced only track? IOW, there is one main audio track and four commentary tracks (five total); that means there should be one full subtitle track, one forced only track, and one forced only track for each of the commentary tracks, or six English subtitle tracks total. But there are only five. So there's no forced track without names on it. That's … weird. (Yes, I chose ALL of the tracks, video, audio, and subtitle.)

Enough of this nonsense. Go enjoy your anniversary, if you haven't already.

vr8hub commented 5 years ago

Oh, good grief. The forced ones are burned in to the video. Which means there's no option to not display them. (I don't know why you would want to not display them, but still.) The four other tracks are only showing the names, not the subtitles. (Interesting that they didn't do subtitles for the commentaries.)

Yeah, clearly I'm never going to understand all of this. I should go learn something simple like molecular biology.

lisamelton commented 5 years ago

@vr8hub Thank you, sir! I will be dining with my wife of 29 years in a few minutes, but before that...

The only forced subtitles in any of the six main titles of the Extended Edition are the last subtitle of each of those, which is in Portuguese. At least on my copy. And, as you discovered, all the Elvish and such are burned into the video.

khaosx commented 5 years ago

This is why you need to examine every subtitle to find out which ones are forced for which language. Sometimes extracting them and examining them with utilities like SUBtools.

@donmelton Happy anniversary, Sir. Give our respects to your wife.

Subtitles, and the forcing thereof - I cannot recommend this resource highly enough, and please, if you don't find a movie that you're looking for, pay it forward and add the correct info in when you do your research.

khaosx commented 5 years ago

@vr8hub I make it empty so that Plex will always show whatever it finds when it looks it up on tmdb, but I think setting it to the correct title is equally valid (and probably better, I'm just lazy)

@samhutchins

Part of my pre-flight code pulls the title as a property from mediainfo (as $strMIName) and then does this:

if [ "$strFilename" != "$strMIName" ]; then
    mkvpropedit "$strTheFile" --edit info --set "title=$strFilename"
fi

mkvpropedit will also take it as an empty value. So, it can be done as part of your checks without you having to be bothered by it.

khaosx commented 5 years ago

@samhutchins

I should add that by the time that check is run, the file name is 100% in line with Plex's naming convention, so the title field will always be exactly correct.

lisamelton commented 5 years ago

@khaosx Thank you, sir! I will. :)