Page 1 of 2

[LINUX] Remove unwanted audio+subs

Posted: February 12th, 2015, 6:33 am
by synci
Hey guys,

i found some scripts that "can" do this, but nothing works really well or stable.
Most of them uses mkvmerge/mkvtoolnix what is the best way i think.
Some of them just removes track1 what is not everytime the correct language.
So the script has to search for language codes.

I can not imagine that nobody here is interested in something like that :)
I have ~600 movies using around 5,5TB space, i already removed english audio tracks by hand and saved arround 500GB space !!!

In my case it would be great to post process this:
>Only MKV files and minimum file size like 3GB
>Find audio track with language "ger", remove all others
>Remove any subs, because Kodi handles that for me
>Keep chapters
>Remove old mkv when successful processed and use the same mkv name (when possible?)

Here is an example script:
http://lime-technology.com/forum/index. ... ic=22410.0

I cant get that one running, it doesnt find any tracks ...

Thanks !!!

Re: [LINUX] Remove unwanted audio+subs

Posted: February 12th, 2015, 10:17 am
by sander
So a plain script. not a SABnzbd post processing script?

Find German audio (and subs):

Code: Select all

ffmpeg -i *.mkv 2>&1 | grep -i Stream.*ger
Does that work for you?

Code: Select all

$ ffmpeg -i *.mkv 2>&1 | grep -i Stream.*ger
    Stream #0:1(ger): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s (default)
    Stream #0:3(ger): Subtitle: dvd_subtitle (default)
    Stream #0:4(ger): Subtitle: dvd_subtitle
    Stream #0:5(ger): Subtitle: ssa

Re: [LINUX] Remove unwanted audio+subs

Posted: February 12th, 2015, 4:14 pm
by synci
Oh sorry, no i mean a Sabnzbd pp script !
Yes that works fine.

Re: [LINUX] Remove unwanted audio+subs

Posted: February 12th, 2015, 5:05 pm
by sander
synci wrote:Oh sorry, no i mean a Sabnzbd pp script !
OK. So just for new downloads.

What are you going to do with all the existing downloads? Leave them that way?

Re: [LINUX] Remove unwanted audio+subs

Posted: February 12th, 2015, 5:41 pm
by synci
You mean my already downloaded series/movies ?
They are already demuxed by hand :)

Re: [LINUX] Remove unwanted audio+subs

Posted: February 12th, 2015, 6:09 pm
by sander
You have done it manually? How?

This is what works for me:

Inspection of the Audio (and Subtitle) Streams:

Code: Select all

$ ffmpeg -i movie-Ger-Jap-Dub.mkv 2>&1 | grep -i -e Audio: -e Subtitle: 
    Stream #0:1(ger): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s (default)
    Stream #0:2(jpn): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s
    Stream #0:3(ger): Subtitle: dvd_subtitle (default)
    Stream #0:4(ger): Subtitle: dvd_subtitle
    Stream #0:5(ger): Subtitle: ssa
    Stream #0:6(eng): Subtitle: ssa
German Audio is 1, so leave that in. Remove all subs:

Code: Select all

$ mkvmerge -o new2.mkv -a 1 --nosubs movie-Ger-Jap-Dub.mkv
mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan  9 2014 18:03:17
'movie-Ger-Jap-Dub.mkv': Using the demultiplexer for the format 'Matroska'.
'movie-Ger-Jap-Dub.mkv' track 0: Using the output module for the format 'AVC/h.264'.
'movie-Ger-Jap-Dub.mkv' track 1: Using the output module for the format 'AC3'.
The file 'new2.mkv' has been opened for writing.
Progress: 100%
The cue entries (the index) are being written...
Muxing took 16 seconds.
Checking:

Code: Select all

$ ffmpeg -i new2.mkv 2>&1 | grep -i -e Audio: -e Subtitle:
    Stream #0:1(ger): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s (default)
Yes: only German audio, no subs.

Is that what you want?

What must be the name of the new MKV?

How does Kodi find the needed subtitles? (And why are Kodi's subtitles better than the ones delivered in the MKV?)

Re: [LINUX] Remove unwanted audio+subs

Posted: February 13th, 2015, 12:39 am
by synci
sander wrote:You have done it manually? How?

Is that what you want?

What must be the name of the new MKV?

How does Kodi find the needed subtitles? (And why are Kodi's subtitles better than the ones delivered in the MKV?)
I have done it manually with mkvmerge on my windows system, everytime i downloaded a movie.
The name should be the same as original downloaded, after successful demuxing other pp script should start (nzbToCouchPotato)
Maybe the name doesnt matter, but just the demuxed mkv should stay. (Demuxing movie.mkv to movie_tmp.mkv -> OK -> Rename back to movie.mkv, overwrite?)

PreProcessing > Downloading > sab unrars > sab filter extensions > only mkv and nfo left in one dir > demuxing audio > nzbToCouchPotato for renaming and moving.

You are right, subs can stay, makes no sense.

Works great:

Code: Select all

ffmpeg -i movie.mkv 2>&1 | grep -i -e Audio: -e Subtitle:
    Stream #0:1(ger): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
    Stream #0:2(eng): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s
    Stream #0:3(ger): Subtitle: subrip (default) (forced)
    Stream #0:4(eng): Subtitle: subrip
mkvmerge -o new2.mkv -a 1 --nosubs movie.mkv
mkvmerge v7.5.0 ('Glass Culture') 64bit gebaut am Jan  4 2015 17:21:29
»movie.mkv«: Der Demultiplexer für das folgende Format wird benutzt: »Matroska«.
»movie.mkv« Spur 0: Das Ausgabemodul für das folgende Format wird benutzt: »AVC/h.264«.
»movie.mkv« Spur 1: Das Ausgabemodul für das folgende Format wird benutzt: »DTS«.
Die Datei »new2.mkv« wurde zum Schreiben geöffnet.
Fortschritt: 100%
Die Cue-Einträge (der Index) werden geschrieben …
Das Muxen dauerte 1 Minute 37 Sekunden.
ffmpeg -i new2.mkv 2>&1 | grep -i -e Audio: -e Subtitle:
    Stream #0:1(ger): Audio: dts (DTS), 48000 Hz, 5.1(side), fltp, 1536 kb/s (default)
MKV with 6gb to 4,5GB, took 1min 37sec on my HP Microserver N54L 8GB ...
My i7 Desktop needs around 3min for that process :)

Re: [LINUX] Remove unwanted audio+subs

Posted: February 13th, 2015, 10:19 am
by synci
Another idea what would be really great, i dont think its a big deal.

Attach movies nfo to the mkv, mkvmerge command should be this one:
"--attachment-mime-type" "text/plain" "--attachment-name" "movie.nfo" "--attach-file" "/location/movie.nfo"

Re: [LINUX] Remove unwanted audio+subs

Posted: February 13th, 2015, 8:02 pm
by sander
OK, prototype is working. See logging below. I'll post the code tomorrow.

Code: Select all

Language ger to be kept
Searching: /home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1
/home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/blabla Zero 11 [Ger-Jap-Dub][Ger-Eng-Sub][AC3 2.0][1080p].mkv
cmd is ffmpeg -i "/home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/blabla Zero 11 [Ger-Jap-Dub][Ger-Eng-Sub][AC3 2.0][1080p].mkv" 2>&1 | grep -i -e Audio:
    Stream #0:1(ger): Audio: ac3, 48000 Hz, stereo, fltp, 224 kb/s (default)
Language found in stream 1
Go on
cleanmoviename /home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/cleanedmovie.mkv
command is mkvmerge -o "/home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/cleanedmovie.mkv" -a 1 --nosubs "/home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/blabla Zero 11 [Ger-Jap-Dub][Ger-Eng-Sub][AC3 2.0][1080p].mkv"
mkvmerge v6.7.0 ('Back to the Ground') 64bit built on Jan  9 2014 18:03:17
'/home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/blabla Zero 11 [Ger-Jap-Dub][Ger-Eng-Sub][AC3 2.0][1080p].mkv': Using the demultiplexer for the format 'Matroska'.
'/home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/blabla Zero 11 [Ger-Jap-Dub][Ger-Eng-Sub][AC3 2.0][1080p].mkv' track 0: Using the output module for the format 'AVC/h.264'.
'/home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/blabla Zero 11 [Ger-Jap-Dub][Ger-Eng-Sub][AC3 2.0][1080p].mkv' track 1: Using the output module for the format 'AC3'.
The file '/home/sander/Downloads/complete/44cfdaab-aee6-180f-338a-96a15cfa84b4.1/cleanedmovie.mkv' has been opened for writing.
Progress: 0%
Progress: 3%
Progress: 4%
Progress: 5%
Progress: 6%
Progress: 7%
Progress: 9%
Progress: 12%
Progress: 13%
Progress: 17%
Progress: 20%
Progress: 22%
Progress: 26%
Progress: 29%
Progress: 31%
Progress: 34%
Progress: 37%
Progress: 38%
Progress: 42%
Progress: 46%
Progress: 48%
Progress: 51%
Progress: 54%
Progress: 56%
Progress: 57%
Progress: 60%
Progress: 61%
Progress: 63%
Progress: 66%
Progress: 68%
Progress: 100%
The cue entries (the index) are being written...
Muxing took 16 seconds.

Re: [LINUX] Remove unwanted audio+subs

Posted: February 14th, 2015, 4:22 am
by sander

Re: [LINUX] Remove unwanted audio+subs

Posted: February 14th, 2015, 11:03 am
by synci
Wow thanks a lot !!!
I´ll try it now and maybe i can add the nfo feature, a quest for me but funny :)

Re: [LINUX] Remove unwanted audio+subs

Posted: February 14th, 2015, 11:25 am
by sander
synci wrote:Wow thanks a lot !!!
I´ll try it now and maybe i can add the nfo feature, a quest for me but funny :)
Let me know the result.

Can you give more info about the .nfo file? What does it contain? Is there always just one .nfo, in the same directory as the .mkv?

Re: [LINUX] Remove unwanted audio+subs

Posted: February 14th, 2015, 11:31 am
by synci
I will.
Yes, normaly there is the mkv and just 1 nfo, thought it would be great to attach it to the mkv for future investigastions :)

Re: [LINUX] Remove unwanted audio+subs

Posted: February 14th, 2015, 12:13 pm
by synci
So .. works great and fast, is it possible to auto delete the old mkv and just keep cleanedmovie.mkv ?
Or directly overwrite the original one and dont creating a new mkv ?
Now i have 2 mkvs in my dir, i think SickRage doesnt like that.

*EDIT* Just inspected code, i think its already on your TODO list ? :)

Re: [LINUX] Remove unwanted audio+subs

Posted: February 14th, 2015, 1:09 pm
by sander
OK, deleting added. See same link (thus: https://raw.githubusercontent.com/sande ... nd-subs.py)