SageTV Community  

Go Back   SageTV Community > General Discussion > General Discussion
Forum Rules FAQs Community Downloads Today's Posts Search

Notices

General Discussion General discussion about SageTV and related companies, products, and technologies.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 04-14-2009, 02:53 PM
stanger89's Avatar
stanger89 stanger89 is offline
SageTVaholic
 
Join Date: May 2003
Location: Marion, IA
Posts: 15,188
Convert H.264 Quicktime (eg HD trailers) to MKV with AC3 audio

Figure this might be of interest to the rest of the community. Apple's quicktime site is a great place to find high quality (including 1080p) trailers. But they use AAC audio which doesn't play well with S/PDIF output, and the mov format isn't quite as well supported as mkv.

Being that I've got extenders hooked up to my HT system, I wanted to convert these QT trailers to MKV with AC3 (S/PDIF friendly) audio, with minimal processing/fuss.

I found that SageTVTranscoder/ffmpeg could do it in one step, but it always screwed up the channel order. But another problem was it required a parameter for the number of channels to encode, and since the QT trailers come in both Stereo and 5.1 that posed a problem.

Being that I'm too lazy to do each trailer by hand, I spent way too much time researching and I finally came up with a single batch file that will remux a QT trailer/file into an MKV with AC3 audio, automatically handling the 2/5.1 channel thing.

The requirements:
  • SageTVTranscoder - bundled with Sage, or you can use ffmpeg probably)
  • Mencoder - grab the version most appropriate for your CPU
  • MKVmerge


Then create a batch file with the following contents:
Code:
@echo OFF
set input=%1
set output=%input:.hdmov=.mkv%

if EXIST %output% GOTO EXISTS

d:\sagetv\sagetv\sagetvtranscoder.exe -i %input% > fmt.txt 2>&1 
findstr /R "Audio.*5\.1" fmt.txt
echo. %errorlevel%
if %ERRORLEVEL% EQU 0 GOTO DD

findstr /R "Audio.*stereo" fmt.txt
echo. %errorlevel%
if %ERRORLEVEL% EQU 0 GOTO ST

goto ERR

:DD
echo. "It's 5.1!"
REM d:\sagetv\sagetv\sagetvtranscoder.exe -i %input% -vn -acodec ac3 -ab 640k -ar 48000 -ac 6 -y tmp.ac3
O:\apps\MPlayer-athlon-svn-28311\MPlayer-athlon-svn-28311\mencoder -channels 6 -oac lavc -lavcopts acodec=ac3:abitrate=640 -ovc frameno -of rawaudio -o tmp.ac3 %input%
mkvmerge -o %output% -d 1 -A S %input% -a 0 -D -S tmp.ac3 --track-order 0:1,1:0
goto OK

:ST
echo. "It's Stereo!"
REM d:\sagetv\sagetv\sagetvtranscoder.exe -i %input% -vn -acodec ac3 -ab 192k -ar 48000 -ac 2 -y tmp.ac3
O:\apps\MPlayer-athlon-svn-28311\MPlayer-athlon-svn-28311\mencoder -oac lavc -lavcopts acodec=ac3:abitrate=192 -ovc frameno -of rawaudio -o tmp.ac3 %input%
mkvmerge -o %output% -d 1 -A S %input% -a 0 -D -S tmp.ac3 --track-order 0:1,1:0
goto OK

:OK
"c:\Program Files\MKVtoolnix\mkvmerge.exe" -o %output% -d 1 -A -S %input% -a 0 -D -S tmp.ac3 --track-order 0:1,1:0
del tmp.ac3
REM del %input%
goto end

:ERR
echo. "It's Unknown!"
goto end

:EXISTS
echo. "Already exists, skipping."

:end
del fmt.txt
Some caveats:
  • You'll have to change the paths to the apps used to whatever they are on your system.
  • It won't delete the original file, if you want it to remove REM from the "REM del %input%" line.
  • I don't completely trust it so neither should you


Usage:
I called my batch file "transcode_mov_ac3_auto.bat", so you simply type "transcode_mov_ac3_auto.bat file.mov" at the command prompt.

You can also just drag a trailer on top of the batch file in windows and I think that works, or presumably you could use something like Dirmon to automatically kick it off.

Or if you're handy with the command line you could use the for command to do everything in a directory.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Conversion of MKV (h264 w/AC3) = choppy playback ldavis SageTV Software 3 10-14-2008 01:57 PM
HD-PRV and Apple Quicktime H.264/.mp4 files-final nut to crack! Shield SageTV Software 0 07-17-2008 03:04 PM
H.264 ts with AC3 Audio? Taddeusz SageTV Beta Test Software 2 07-11-2008 05:22 AM
No AC3 Filter for MKV files technazz SageTV Software 29 01-02-2008 02:56 PM
r5000hd h.264 vs Quicktime H.264 playback HawgGuy Hardware Support 0 04-30-2007 08:09 AM


All times are GMT -6. The time now is 09:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, vBulletin Solutions Inc.
Copyright 2003-2005 SageTV, LLC. All rights reserved.