LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Linux Answers > Applications / GUI / Multimedia
User Name
Password

Notices

By Steel_J at 2005-12-30 16:22

Some of you may have encountered a few AVI movies with DTS audio tracks.

Sometimes we don't want to keep it as DTS.

Unfortunately, to extract and convert DTS audio some creativity must be involved as this format is not accepted widely by A/V tools in LINUX.

Here is a script I created to rip a bunch of AVI files DTS tracks and convert them to Stereo AC3 tracks automagically.

Copy/paste this to a text file and save it as "avidts2ac3":

#!/bin/bash

#avidts2ac3 (extracts DTS tracks from video file and converts it to ac3)

#requirements: mplayer / ffmpeg

#variables
current_directory=$( pwd )
OUTPUT_AVI="output_avi.av" #'av' extension used to prevent filename conflict
OUTPUT_WAV="output_wav.wav"
OUTPUT_AC3="output_ac3.ac3"

#remove spaces
for i in *.avi; do mv "$i" `echo $i | tr ' ' '_'`; done > /dev/null 2>&1 &

#remove uppercase
for i in *.[Aa][Vv][Ii]; do mv "$i" `echo $i | tr '[A-Z]' '[a-z]'`; done > /dev/null 2>&1 &

#rip with Mencoder / encode with ffmpeg
for i in *.avi ; do nice -n 10 mencoder $i -oac pcm -ovc copy -o $OUTPUT_AVI && nice -n 10 ffmpeg -i $OUTPUT_AVI -acodec copy $OUTPUT_WAV && nice -n 10 ffmpeg -i $OUTPUT_WAV -ac 2 -ab 192 -ar 48000 $OUTPUT_AC3 && mv $OUTPUT_AC3 "`basename "$i"`.ac3" && rm $OUTPUT_WAV ;done

#Cleanup
rm $OUTPUT_AVI

exit;

You might want to copy this as root to your path so you can use it in any directory. (/usr/bin or /urs/local/bin)

Don't forget to give it permission: chmod +rx avidts2ac3

Then put all the AVI movies you want to convert in one folder and use the script in console from that folder.

For those who want or need to understand the mechanics of it all here it is broken down for you in a step by step guide:

DTS to AC3

1)Convert the audio in the movie in WAV PCM:

nice -n 10 mencoder input_video.avi -oac pcm -ovc copy -o output_movie.avi

2)Extract the WAV file from the new AVI:

nice -n 10 ffmpeg -i output_movie.avi -acodec copy movie_audio.wav

3)Convert the WAV to AC3 Stereo

nice -n 10 ffmpeg -i movie_audio.wav -ac 2 -ab 192 -ar 48000 audio.ac3

After that you can multiplex your mpeg2 movie with your new AC3 track

* Note that once the WAV is extracted you can convert it to whatever you prefer also.



  



All times are GMT -5. The time now is 03:11 AM.

Main Menu
Advertisement

My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration