Jump to content


Photo

SABNZBD, Google TV, and Plex - Convert MKV DTS Audio to AC3


  • Please log in to reply
76 replies to this topic

#1 TRaymond

TRaymond

    Member

  • Members
  • PipPip
  • 60 posts

Posted 13 December 2011 - 04:18 AM

Okay, so before anyone starts slamming me for starting a thread that has been discussed to no end, I wanted to start out by telling you what I'm looking for in this thread that's different.

1.) All the other threads talk about having video and no audio.
2.) All the other threads say you need to convert the DTS Audio to AC3 and all will be fine.
3.) That's where the other threads end.

I have spent untold number of hours digging through the internet looking for information on how to convert the MKV files using DTS Audio streams to AC3. I've found several references, however, all of them are over a year old and most of them are either incomplete, or reference files that no longer exist. I think that knowing the limitations of GTV, we should have a simple workaround for this. I'm not sure how everyone else here gets their content, but for me, it comes through SABNZBD and SickBeard. Now before you say I should be posting over there....believe me...I will. What I'm looking for from this group is a script of some sort that will take the existing MKV, leave the video in place, and swap out the DTS Audio for AC3.

Threads all over the internet from at least a year ago supposedly had a way to do this. It was convoluted (not to mention that most of the instructions either don't pan out or are missing portions of them). They required about 4-5 pieces of software to be installed on your machine.

Now we find ourselves (GTV Plex Users) in a situation where we need this solution. I understand that if Google allows HLS in a future update that Plex will be able to transcode the audio stream for us. While I can't wait for that to happen, I also kind of think that having direct streaming working for our GTV devices is a good idea (less resources to direct stream rather than transcode).

To that end....

Is there anyone here who knows how to do what I'm asking....on a mac? I'd prefer a scripting solution of some sort...it could even be an automator script that runs once we drop a mkv file in a directory that would scan the mkv for the dts audio and replace it with another mkv with AC3 audio (this method is preferred). To make it easier on myself (and every one of the other GTV users that are running into this), it would be nice if someone who knows how to do this could put an installer package together that would install all the necessary components with nice easy to understand step by step instructions.

If we could have a solution like this, it would solve all Plex/GTV users problems out there. To be honest, if I had a solution for this right now, I'd be going out and buying several more Logitech Revue's to put around the house (replace my Apple TV's) and also hand out several as gifts to family members.

If the developers are listening to this thread.....You guys have changed the way my family (and extended family) watches TV. I've converted several Windows folks over to Mac simply after showing them Plex. I love your product and look forward to each new release so that I can see how you guys have transformed my tv watching experience. If at all possible, please take some time to address this issue. I know it's not a Plex Issue...but it does affect all Plex/GTV Users.

Thanks in advance!

TRaymond

#2 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 13 December 2011 - 04:41 AM

I believe I have the script you are looking for. I ran into this same problem using SabNZBD and Couchpotato as all the MKVs had DTS audio in them. I wrote a little script that would pass the parameters provided by the SabNZBD post processing system into a bash script written by Jake Wharton. The script would convert DTS to AC3 and remux it into the MKV leaving the video untouched, once it is completed it moves it into a directory for Couchpotato to process (moving to correct folder and adding metadata).

My media server is running Ubuntu 11.10, so I am pretty sure the same script will work for a Mac (not a mac user myself). Jake Wharton mkvdts2ac3.sh really does all the heavy lifting and is located here: https://github.com/J...rton/mkvdts2ac3

I'm at work right now, but I will post my script when I get home but it is super simple. It creates a working directory and passes the file names into mkvdts2ac3, copies the remuxed mkv to correct directory and then removes the working directory.

Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#3 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 13 December 2011 - 10:46 AM

Okay here is the code I used. Like I said it is very simple, but it works (kiss philosophy).

The mkvdts2ac3 has the following prerequisites

Make sure the executables for the following libraries are accessible.

mkvtoolnix - Matroska tools
libdca - DTS to WAV decoder
aften - WAV to AC3 encoder
rsync - File transfer and synchronization
Note: If you are a Mac OS X user you may need to compile these libraries.

#!/bin/bash

## export path to ensure we can access mkvdts2ac3
export PATH="/usr/local/bin:/usr/local/sbin:/home/htpc/Scripts:$PATH"

file_path=$1
file_name=$3
final_path="/home/htpc/Downloads/processing/couchpotato/$3"

#echo $file_path
#echo $file_name
#echo $final_path


# $1 is download directory.
cd "$1"

#remove samples
rm -rf *sample*

# Rip out DTS and replace it with ac3
## Change /path/to/mkvdts2ac3.sh to correspond with your own path.

mv *.mkv input.mkv

bash /home/htpc/mkvdts2ac3/mkvdts2ac3.sh -d -n --wd /home/htpc/temp input.mkv

mv input.mkv "$3.mkv"

       ## Options:
       ##    -d, --default      Mark AC3 track as default.
       ##    -n, remove dts track
       ##    --wd Alternate tmp working directory.

## remove the tmp directory
rm -rf /home/htpc/temp/*

#move file so couchpotato can process it
mkdir "$final_path"

mv -f "$file_path" /home/htpc/Downloads/processing/couchpotato

#update plex media server
curl http://192.168.10.60:32400/library/sections/1/refresh



Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#4 MaxiP

MaxiP

    Member

  • Members
  • PipPip
  • 87 posts

Posted 13 December 2011 - 12:11 PM

I'm not familiar with Apple scripts but you should be able to do this using Handbrake CLI. Something like "handbrakecli movie.mkv -E AAC" should encode just the audio to AAC leaving the video untouched. You should end up with movie-1.mkv with embedded AAC audio

#5 dcplaya

dcplaya

    Member

  • Members
  • PipPip
  • 68 posts

Posted 13 December 2011 - 02:58 PM

Okay here is the code I used. Like I said it is very simple, but it works (kiss philosophy).

The mkvdts2ac3 has the following prerequisites

Make sure the executables for the following libraries are accessible.

mkvtoolnix - Matroska tools
libdca - DTS to WAV decoder
aften - WAV to AC3 encoder
rsync - File transfer and synchronization
Note: If you are a Mac OS X user you may need to compile these libraries.

#!/bin/bash

## export path to ensure we can access mkvdts2ac3
export PATH="/usr/local/bin:/usr/local/sbin:/home/htpc/Scripts:$PATH"

file_path=$1
file_name=$3
final_path="/home/htpc/Downloads/processing/couchpotato/$3"

#echo $file_path
#echo $file_name
#echo $final_path


# $1 is download directory.
cd "$1"

#remove samples
rm -rf *sample*

# Rip out DTS and replace it with ac3
## Change /path/to/mkvdts2ac3.sh to correspond with your own path.

mv *.mkv input.mkv

bash /home/htpc/mkvdts2ac3/mkvdts2ac3.sh -d -n --wd /home/htpc/temp input.mkv

mv input.mkv "$3.mkv"

       ## Options:
       ##    -d, --default      Mark AC3 track as default.
       ##    -n, remove dts track
       ##    --wd Alternate tmp working directory.

## remove the tmp directory
rm -rf /home/htpc/temp/*

#move file so couchpotato can process it
mkdir "$final_path"

mv -f "$file_path" /home/htpc/Downloads/processing/couchpotato

#update plex media server
curl http://192.168.10.60:32400/library/sections/1/refresh



I am using the same script but on Ubuntu. My script is as follows but I still have some errors. Havent had a chance to fix them so if anyone sees one let me know. Will the code above work on Ubuntu? I would love to use one that works every time

#!/bin/bash
#mkvdts2ac3.sh
#converts .mkv files with DTS sound and adds a AC3 soundtrack
set +v
set -e

echo 
echo 

cd "$1"

#if [ "*sample*.mkv" ]; then
#  cd "$1"
#  rm *sample*.mkv
#else
# echo "No sample file found!"
#fi

#Looks for a .mkv and then converts it
if [ "*.mkv" ]; then
  cd "$1"
  echo
  echo
  mv *.mkv input.mkv
  ls
  /home/drew/mkvdts2ac3/mkvdts2ac3.sh -i -d  input.mkv
  cd "$1"
  rm *.dts
else
  echo "No .mkv File Found"
  exit 0
fi

#Names the file back to original name
if [[  "input.mkv" ]]; then
  mv input.mkv "$3.mkv"
  mv "$3.mkv" "/media/TBDrive2/ConvertedMovies/$3/$3.mkv"
  echo "Conversion Complete"
else
  echo "I've made a very big mistake"
  exit 1
fi
exit 0


#6 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 13 December 2011 - 08:09 PM

I am using the same script but on Ubuntu. My script is as follows but I still have some errors. Havent had a chance to fix them so if anyone sees one let me know. Will the code above work on Ubuntu? I would love to use one that works every time



The script I use runs on a Ubuntu 11.10 box. I have not had any errors with it automatically converting the dts tracks to ac3 with sabnzbd. If it encounters a file that is not a mkv, then
mv *.mkv input.mkv
will not work. Or if the mkv file already has ac3 audio in it, mkvdts2ac3 will just kick it out saying it has nothing to encode.

My next step is to modify the script to work for both couchpotato and sickbeard. If sickbeard downloads something with dts in it, I have to ssh into the folder and run mkvdts2ac3 manually.

Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#7 dcplaya

dcplaya

    Member

  • Members
  • PipPip
  • 68 posts

Posted 13 December 2011 - 09:25 PM

The script I use runs on a Ubuntu 11.10 box. I have not had any errors with it automatically converting the dts tracks to ac3 with sabnzbd. If it encounters a file that is not a mkv, then

mv *.mkv input.mkv
will not work. Or if the mkv file already has ac3 audio in it, mkvdts2ac3 will just kick it out saying it has nothing to encode.

My next step is to modify the script to work for both couchpotato and sickbeard. If sickbeard downloads something with dts in it, I have to ssh into the folder and run mkvdts2ac3 manually.


You mind if I take your script then? Your's seems much better than mine.

#8 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 13 December 2011 - 10:19 PM

You mind if I take your script then? Your's seems much better than mine.


Yes of course, I posted it for anyone to use. Once I get a chance to make a combined sickbeard/couchpotato script I will post that for use.

Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#9 TRaymond

TRaymond

    Member

  • Members
  • PipPip
  • 60 posts

Posted 14 December 2011 - 04:04 AM

Any chance I can get some instructions on how to install these properly on my mac?

mkvtoolnix - Matroska tools
libdca - DTS to WAV decoder
aften - WAV to AC3 encoder
rsync - File transfer and synchronization
Note: If you are a Mac OS X user you may need to compile these libraries.

#10 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 14 December 2011 - 04:47 AM

Any chance I can get some instructions on how to install these properly on my mac?

mkvtoolnix - Matroska tools
libdca - DTS to WAV decoder
aften - WAV to AC3 encoder
rsync - File transfer and synchronization
Note: If you are a Mac OS X user you may need to compile these libraries.


I don't own a mac, so take everything with a giant shaker of salt. I would just follow this post here:
http://forums.macrum...ad.php?t=836043, follow post #8 and the first post. If that doesn't work, everything except aften is located in something called macports. (here:http://www.macports.org/ports.php)

Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#11 TRaymond

TRaymond

    Member

  • Members
  • PipPip
  • 60 posts

Posted 14 December 2011 - 07:01 PM

I don't own a mac, so take everything with a giant shaker of salt. I would just follow this post here:
http://forums.macrum...ad.php?t=836043, follow post #8 and the first post. If that doesn't work, everything except aften is located in something called macports. (here:http://www.macports.org/ports.php)



Can you give me some help on your SABNZBD Script? What are the various paths that you've hardcoded into the script...what should they be?

Thanks for the help!

#12 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 15 December 2011 - 03:33 AM

Can you give me some help on your SABNZBD Script? What are the various paths that you've hardcoded into the script...what should they be?

Thanks for the help!


I'm going to try and break down each piece the best I can. I do not use mac, so I don't know what your exact path would be for each of these.

All my Scripts are located in the folder /home/htpc/Scripts. I don't know if you as a mac user will need this line or not.

## export path to ensure we can access mkvdts2ac3 
export PATH="/usr/local/bin:/usr/local/sbin:/home/htpc/Scripts:$PATH" 

These are just variabled $1 and $3 are passed into the script when sabnzbd calls it automatically. $1 is the file path that sabnzbd downloaded to, and $3 is the file name without the file type.

file_path=$1 
file_name=$3 
final_path="/home/htpc/Downloads/processing/couchpotato/$3" 

For debugging, ignore these.
#echo $file_path 
#echo $file_name 
#echo $final_path 


Change to the directory we will be working in and remove anything that says sample
# $1 is download directory. 
cd "$1" 
 
#remove samples 
rm -rf *sample* 
 

This will rename the downloaded mkv to input.mkv in order to pass it to mkvdts2ac3. Once mkvdts2ac3 finishes it renames it back to the proper file name.
The first path is the locating of mkvdts2ac3, so you should change that to where ever you downloaded mkvdts2ac3 to. The second directory is just a temporary working directory. mkvdts2ac3 defaults its working directory to /temp, but I don't have a lot of room on that directory so I pass the --wd parameter to mkvdts2ac3 to change the working directory.
# Rip out DTS and replace it with ac3 
## Change /path/to/mkvdts2ac3.sh to correspond with your own path. 
 
mv *.mkv input.mkv 
 
bash /home/htpc/mkvdts2ac3/mkvdts2ac3.sh -d -n --wd /home/htpc/temp input.mkv 
 
mv input.mkv "$3.mkv" 
 
       ## Options: 
       ##    -d, --default      Mark AC3 track as default. 
       ##    -n, remove dts track 
       ##    --wd Alternate tmp working directory. 



This removes the working directory, and then moves the movie to the directory I instructed couchpotato to look for downloads in. This needs to be different than were sabnzbd downloads to otherwise couchpotato will try to move the movie while the script is running which is a bad thing.
## remove the tmp directory 
rm -rf /home/htpc/temp/* 
 
#move file so couchpotato can process it 
mkdir "$final_path" 
 
mv -f "$file_path" /home/htpc/Downloads/processing/couchpotato 
 
#update plex media server 
curl http://192.168.10.60:32400/library/sections/1/refresh

I hope that helps.

Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#13 5stringdeath

5stringdeath

    Ninja

  • Plex Ninja
  • PipPipPipPipPipPip
  • 1293 posts
  • Location: Boston, MA

Posted 15 December 2011 - 04:30 AM

Maybe I'm overthinking things but .. couldn't you just add "DTS" into Couchpotato's "ignore words" preference? Most mkv's arrive as 5.1 rips too - eventually

Not to hijack this thread, but it may be a simpler solution for some.

-------------------

 

Running PMS on a MacMini and Synology 412+

 

Clients include: PHT MacMini, PHT MacBook Pro, iPad 2, iPad Retina, iPhone 4s, iPhone 5, Sony GS7, Nexus 7, Roku3, Chromecast, Plex Web in Chrome

 

Fav Plex Feature: SYNC!


#14 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 15 December 2011 - 05:50 AM

Maybe I'm overthinking things but .. couldn't you just add "DTS" into Couchpotato's "ignore words" preference? Most mkv's arrive as 5.1 rips too - eventually

Not to hijack this thread, but it may be a simpler solution for some.


Yes, but then you are depended on the individual to identify the MKV as having a DTS audio track. Which is not always the case.

Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#15 TRaymond

TRaymond

    Member

  • Members
  • PipPip
  • 60 posts

Posted 15 December 2011 - 06:28 PM

Yes, but then you are depended on the individual to identify the MKV as having a DTS audio track. Which is not always the case.



Getting closer...Now I am getting the following error on the SABNZBD Script:

Error: Could not open the timecode file '/ConverterTemp/input.tc' for writing (Permission denied).

I assume there is something I need to do to allow this script to create files and and such. What am I missing? The permissions on the SABNZBD Script are (CHMOD 775)

#16 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 15 December 2011 - 08:42 PM

I believe sabnzbd runs the script with your normal user permissions so it would not have access to /convetertemp. I would change the temporary working directory to something in your home folder. On a Linux box that would be /home/username/convertertemp should be similar on a Mac I assume.

Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#17 TRaymond

TRaymond

    Member

  • Members
  • PipPip
  • 60 posts

Posted 16 December 2011 - 06:43 AM

I believe sabnzbd runs the script with your normal user permissions so it would not have access to /convetertemp. I would change the temporary working directory to something in your home folder. On a Linux box that would be /home/username/convertertemp should be similar on a Mac I assume.



THANK YOU SO MUCH!!!!

I somehow managed to piece it all together...again...most of the applications are hard to find because the primary place that everyone linked to is no longer availiable....I have to set this up on my fathers computer next, so I'll try to take notes so that anyone else on Mac who needs to follow it should be able to easily.

Guy2545: THANK YOU THANK YOU THANK YOU. I purchased two more Logitech Revue's tonight and sold all my Apple TV's....I now have a GREAT whole house solution that just Works!! No Jailbreak, No Skipping, No Pausing, No rebooting.......Just great HD Video in every room!

Plex for Google TV Developers: Keep up the good work. I hope you don't drop the product as I'm sure there is so much more you can do with it....(ability to Delete items on server please!!).

All: I'll update the thread once I have Solid Mac Instructions with updated links to the software required.

#18 dcplaya

dcplaya

    Member

  • Members
  • PipPip
  • 68 posts

Posted 02 January 2012 - 09:44 PM

This removes the working directory, and then moves the movie to the directory I instructed couchpotato to look for downloads in. This needs to be different than were sabnzbd downloads to otherwise couchpotato will try to move the movie while the script is running which is a bad thing.

## remove the tmp directory 
rm -rf /home/htpc/temp/* 
 
#move file so couchpotato can process it 
mkdir "$final_path" 
 
mv -f "$file_path" /home/htpc/Downloads/processing/couchpotato 
 
#update plex media server 
curl http://192.168.10.60:32400/library/sections/1/refresh

I hope that helps.


The "Update plex media server" is redundant correct since CouchPotato also does this as long as you have the option enabled?

#19 guy2545

guy2545

    Dedicated Member

  • Members
  • PipPipPip
  • 135 posts
  • Location: Texas

Posted 03 January 2012 - 04:20 AM

The "Update plex media server" is redundant correct since CouchPotato also does this as long as you have the option enabled?


Yeah that is no longer vaild, I was having trouble with Couchpotato trigging a plex update so I added that line in.

Plex Media Clients:
Logitech Revue
Sony NSZ-GS7
Samsung Tab2
Nexus 7

Nexus 5
Plex Media Server:
Toshiba i3 Windows 8.1 Laptop

Windows Server 2012 R2 with 3TB

 


#20 ucola

ucola

    Newbie

  • Members
  • Pip
  • 1 posts

Posted 07 January 2012 - 07:45 AM

Hi all

sorry i'm not sure that this is the right post...
but on the settings of plex media manager they have a setting to convert DTS to Stereo... did anybody know if they works?

I think the converting of DTS or other type, must be done from PLEX and not mannualy :)

thx for answer




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users