Firmware: A-410 [01 Apr. 2014] | A-400 [12 Mar. 2014] | C-300 [13 Feb. 2014] | A-300 [24 Feb. 2014] | C-200 [11 July 2013] | A-200/A-210 [11 July 2013] | Popbox V8 [3 Dec 2013]

Just got your NMT | WIKI has the answers | Search the forum | Forum Rules/Policy | Firmware & Official NMT News | Popcornhour manuals



User(s) browsing this thread: 1 Guest(s)
Thread Closed 
DTS->Stereo AAC Script (Linux)
11-15-2009, 05:00 PM (This post was last modified: 11-16-2009 07:28 PM by MukiEX.)
Post: #1
DTS->Stereo AAC Script (Linux)
UPDATE: Made an echo-free version. Once again, USE AT YOUR OWN RISK, but originally with the echos it wasn't completing the last step (tho it would if I separated it from the other two, so who knows what's causing this)

Once again, I'm not entirely sure if this will be terribly helpful to anyone here. I just hacked this together in a few minutes (I don't actually know bash scripting). What it does (which is pretty clear from reading the code) is: 1. Figures out which track is DTS. 2. Extracts it. 3. Converts it to stereo AAC. 4. Inserts it into a duplicate of the original filename with the word "Fixed" in front of it. I'm using it to convert 30 some odd clips that I've left on the backburner for such a conversion (that, and Heartwave over SMB doesn't work for me, sadly)

Mind you, it has a few caveats:

1. You'll need mkvmerge, mkvextract (part of the mkvtoolnix for Debian/Ubuntu users)
2. You'll need a pimped-out ffmpeg installation (rarely by default in a distro, you might need to build ffmpeg from scratch if there's no ppa's for this)
3. BIG BIG WARNING: This script doesn't work with movies that have multiple DTS tracks. That requires a lot more scripting on my part
4. BIG BIG WARNING #2: This moves the new AAC track to the FIRST track on the MKV file. While it works on the PCH, YMMV on other players.
5. YET ANOTHER STUPID WARNING: This script doesn't check for files that DON'T have DTS tracks. I just lumped all of my DTS-containing files into one folder before running this script.
6. I'm sorry this script has so many specific rules, I'd drop it in a heartbeat if someone already had/has a better script for Linux systems.

Once again, please use this at your own risk, and if someone builds a much better script, please post it, I'll replace the one I have here.

And without further ado, the script:

Code:
#!/bin/bash
for movie in *mkv
do
mkvsetup=$(mkvmerge -i "$movie" | grep -i dts | grep -i track | awk '{printf $3 "\n"}' | sed 's;\:;;')
        echo "mkvextract tracks \"$movie\" $mkvsetup:\"$movie.dts\""
        echo "ffmpeg -i \"$movie.dts\" -ab 192k -ac 2 \"$movie.m4a\" "
        echo "mkvmerge \"$movie.m4a\" \"$movie\" -o \"Fixed-$movie\" "
done

echo-free version:

Code:
#!/bin/bash
for movie in *mkv
do
mkvsetup=$(mkvmerge -i "$movie" | grep -i dts | grep -i track | awk '{printf $3 "\n"}' | sed 's;\:;;')
        mkvextract tracks "$movie" $mkvsetup:"$movie.dts"
        ffmpeg -i "$movie.dts" -ab 192k -ac 2 "$movie.m4a"
        mkvmerge "$movie.m4a" "$movie" -o "Fixed-$movie"
done


Like most of my hacky crap, it requires piping into sh, because I like to double-check what it's about to do to my files. Also note that I haven't tested on files with quotes in their filenames. Please doublecheck anything it's about to do.

Usage:
./mkv4popcorn | sh

It's pretty straightforward what this script does, hopefully someone finds it useful.
Find all posts by this user
Thread Closed 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
Star [Apps] Bierdopje 4 NMT PHP script SilverViper 4 2,435 11-26-2012 04:57 PM
Last Post: Djiest
  Need help debugging a simple script to enable NTFS write on HDD user33 10 4,409 04-05-2011 06:05 PM
Last Post: nuke12
  Help with Server Timeout Error running a script hindibuff 0 2,157 03-29-2011 06:21 AM
Last Post: hindibuff
Bug Executing a script on the server from the NMT? johnk 6 4,150 02-21-2011 10:59 PM
Last Post: johnk
  [AUDIO] lastfm script (bookmarks, auto-login, etc.) mk11 81 45,641 10-09-2010 01:45 AM
Last Post: opfeifer
  help with auto unrar script. kiranos 0 2,088 05-15-2010 10:24 AM
Last Post: kiranos
  mkvdts2ac3 (Adding AC3 track from DTS) [Linux/OSX] JakeWharton 151 97,932 04-12-2010 12:01 PM
Last Post: tonictrouble
  Launch script after playing a video antro31 4 2,317 04-03-2010 06:32 PM
Last Post: antro31
Exclamation Scheduled playback script kdavid 0 1,161 03-16-2010 10:27 AM
Last Post: kdavid
  Auto_Mount v0.1 - Script to auto mount USB drives with NAME vaidyasr 41 20,124 02-12-2010 03:22 AM
Last Post: vaidyasr

Forum Jump: