Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I'm creating audio tracks from movies that can be played on Apple TV and iOS devices. Handbrake could downmix 5.1 audio to stereo with Pro Logic II matrix encoding. How can I do that with ffmpeg?

I found this link on ffmpeg Trac mentioning that I could do matrix encoding with libswresample, but further searching doesn't show how to actually use this in command line.

I tried

ffmpeg -i test.mkv -map 0:1 -c libfdk_aac -ac 2 -af aresample  -matrix_encoding dplii  out.aac

where the only audio track in the source file test.mkv is a 5.1ch DTS HD MA, but the generated AAC audio does not seem to be matrix encoded.

share|improve this question
    
wouldn't you rather convert the DTS-MA to AC3 rather than AAC? –  James May 12 '13 at 21:08
    
@James AppleTV and iOS devices don't support AC-3. (See developer.apple.com/library/ios/#documentation/AudioVideo/…) –  slhck May 12 '13 at 21:25
    
ah. misread question. thought we were converting movies for playback rather than just extracting the audio –  James May 12 '13 at 21:30
    
Well, actually Apple TV can do AC-3 passthrough to TV via HDMI if the TV supports AC-3 decoding (most LCD TVs do), or via the optical link. However if I want to view the movie on iOS devices, AAC is the only choice. I've already make ffmpeg to create an AC-3 track correctly, but the AAC DPLII is puzzling me as nothing can be found so far. –  Riobard May 13 '13 at 3:04
    
Out of interest, what do you mean 'AAC is the only choice'? What devices are you trying to watch the movies on which don't support AC3? AFAIK the iPad supports AC3 audio in MP4 movies / tv shows. –  James May 13 '13 at 7:18

2 Answers 2

up vote 5 down vote accepted

According to the manual entry on aresample, you have to supply the resampler options in a different format:

The filter accepts the syntax [sample_rate:]resampler_options, where sample_rate expresses a sample rate and resampler_options is a list of key=value pairs, separated by ":".

That means you'd need to call it like this:

-af "aresample=matrix_encoding=dplii"
share|improve this answer
3  
Thanks very much! Well, actually I still have to supply -ac 2 otherwise the generated AAC audio will be 5.1 channel. –  Riobard May 13 '13 at 3:48

My preferred method is to use ffmpeg to downmix the DTS to stereo and then pipe that output to Quicktime AAC command-line encoder (Quicktime is best AAC encoder in listening tests).

ffmpeg.exe -report -loglevel verbose -i "videofile.mkv" -map 0:a:0 -f wav -acodec pcm_f32le -ac 2 - | qaac.exe --tvbr 127 --quality 2 --rate keep --ignorelength --no-delay - -o "audioonly.m4a"

Requires ffmpeg.exe and qaac.exe

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.