mdhiggins / sickbeard_mp4_automator

Automatically convert video files to a standardized format with metadata tagging to create a beautiful and uniform media library
MIT License
1.51k stars 201 forks source link

Bug/Feature Request: Remux to MKV, leaving embedded subs and etc. #1084

Closed RandomNinjaAtk closed 4 years ago

RandomNinjaAtk commented 4 years ago

So there is currently an option to output files with mkv format. However, its currently not actually outputting a remuxed mkv. The file is still just a MP4 formatted file with an mkv extension

Also the script will adjust the embedded subs to mov_text because it says they are incompatible when all formats are compatible with mkv containers.

The reason for wanting the option to remux into mkv would be to allow one to remove unwanted audio/subtitle streams by language preference and re-convert video/audio to desired formats if desired

Here is an example file output when using the "mkv" for extension as specified:

image

kmr2319 commented 4 years ago

You can remove unwanted audio/subtitles and still use the MP4 container:

audio-language = eng
audio-default-language = eng
subtitle-language = eng
subtitle-default-language = eng

This works 99.9% of the time. The only time it's an issue is when I have a foreign (to me)/non-English item without a dubbed audio track - then may strip the native language and leave the subtitles only.

The mkv extension is not supported since it's encoding to an MP4 container only (as you can see in your screen shot):

output_extension = mp4/m4v (must be one of these 2)

Check out the readme which contains these details.

Outside of preference (since it's a more open container format), the MP4 container has very wide support for most, if not all of the same options that an mkv container does (multiple tracks, multiple video/audio codecs, subtitles, etc). The only thing mp4 is missing vs mkv is ssa,ass support: https://en.wikipedia.org/wiki/Comparison_of_video_container_formats#Subtitle/caption_formats_support

RandomNinjaAtk commented 4 years ago

You can see here where outputting to mkv was added:

https://github.com/mdhiggins/sickbeard_mp4_automator/commit/9403600c983243736a8a5351d7fa61086da96a66

Maybe it was later removed or never worked

mdhiggins commented 4 years ago

Yeah looks like I needed to also add mkv to valid_formats and the output_format option needs to be set to mkv as well (in addition to the extension)

See if that makes a difference

mdhiggins commented 4 years ago

If that's working feel free to close

kevindd992002 commented 4 years ago

This is interesting. I thought your script was never designed to be used to output an mkv file. Since I bought a new LG C9, I'm into TrueHD now so mp4's are a no-no. I wanted to use your script to accomplish what I was doing before but I didn't think it was possible.

So can your script do mkv to mkv file conversion/remuxing with all the options available in the ini file?

mdhiggins commented 4 years ago

It wasn't but since its essentially an FFMPEG wrapper most of the functionality works. The tagging features are MP4 specific so that won't work but the remuxing and stream analysis / conversion should be ok. It hasn't been as heavily tested with MKV so feel free to report issues

Just make sure your format and output extension are set to mkv

kevindd992002 commented 4 years ago

When you say "tagging", you're talking about artwork and subs stuff, right? I don't do those so I think I'm good. I just need the script to standardize all my media based on the video/audio quality settings I have in the ini file. How do I convert from mkv to mkv though? Should I set force_convert to true?

mdhiggins commented 4 years ago

Metadata and Artwork, subtitles should still be ok for MKV

And the option is somewhat poorly named but set convert-mp4 = True, that optionally essentially allows the script to keep converting if the input and output extensions are the same, but because it was originally designed for mp4's the legacy name is less helpful

Force convert might actually be useful to leave off because if all the codecs are correct already it will just skip it this way. ForceConvert will rewrite the container whether all the streams are correct or not

RandomNinjaAtk commented 4 years ago

So I've completed some brief testing, but haven't gotten it to work yet. Seems like there is an issue handling subtitles because mkv can almost accept all subtitle formats, but the script is designed to only allow embedding mov_text type... so it will not copy over existing. And that is an issue for mkv because mov_text is not a valid type for it, its needs to be converted to srt or some other format. (MP4 -> MKV or MKV -> MKV)

Edit, after some additional testing, not embedding subs did allow it complete successfully

My goal for mkv is to be able to remux as much as possible and keep content based on language preferences (With correct forced sub marking) with the option to re-encode formats as desired.

mdhiggins commented 4 years ago

Yeah I’ll probably have to expand on the list of supported codecs at some point to be container specific. Should be doable

mdhiggins commented 4 years ago

4cb88a8602e878c9b01b719d847aa787eb8d4908 This update relaxes some of the restrictions on subtitle codecs see if that helps

RandomNinjaAtk commented 4 years ago

I'll hopefully get to try this soon, been busy working on other scripts! Thx

mdhiggins commented 4 years ago

I made some additional updates today as well to better handle setting default/forced for subtitles as well as more intelligently labeling the default audio track. The mp4 container doesn't appear to support a 'forced' flag in FFMPEG for MP4s but it does work for MKVs

RandomNinjaAtk commented 4 years ago

So for this to work, how am I supposed to set the configuration settings?

I'm in the process of testing this and a little lost on what to specify in the codec options

Thanks in advance...

Edit:

Still playing with it, but looks like setting the subtitle image codec to pgs worked in the one test and it was set as forced as it should be 👍

mdhiggins commented 4 years ago

I've been busy in the last few days and have overhauled a lot of the core systems for audio and subtitle tracks. The forced/default stuff should just work. You just need to set a preferred codec for image based subtitles and text based subtitles now (srt should be fine for mkv)

mdhiggins commented 4 years ago

Overall the updates in the last few days removed a lot of hard coded extension/format screening things in favor of more dynamic approaches. This moves away from being specifically for going from MKV to MP4 and is instead more format agnostic