[FFmpeg-user] How can I convert mpeg2 5.1 audio to ac3?

bluesky at caramail.com bluesky at caramail.com
Tue Nov 4 10:09:51 CET 2014


I have some .ts (transport stream) files that contain video and 5.1 audio but XBMC will only play them in stereo. It appears that the only type of file that XBMC will play in full 5.1 is an ac3 file, so my thought was to try converting the files using ffmpeg.

My original approach was to use:

ffmpeg -i "originalfile.ts" -c:v copy -c:a ac3 "new.ts"

This did create an ac3 file but with only two channels. After reading a bit more, I tried adding the -ac 6 switch, so it became:

ffmpeg -i "originalfile.ts" -c:v copy -c:a ac3 -ac 6 "new.ts"

This created a file that XBMC thinks is a Dolby 5.1 file (according to the on-screen display) but in fact the only audio present is on the stereo channels.

The source is definitely in MPEG-TS and it contains 5.1 information, although I'm confused as to how. One of the files is actually a speaker test video and if played in a different program (such as MythTV) it plays the "Left", "Right" and "Center" channels from those speakers, but the "Left Surround" and "Right Surround" audio comes from both the front and rear speakers of the specified channel, with a bit more emphasis on the rear. If played in XBMC it plays from the front speakers only. Yet if I attempt to display the properties in a program like iMediaHUD it only shows two stereo tracks that look like this:

Audio #1
Count						: 222
Count of stream of this kind			: 2
Kind of stream					: Audio
Stream identifier				: 1
StreamOrder					: 0-1
ID						: 64 (0x40)
Menu ID						: 137 (0x89)
Format						: MPEG Audio
Commercial name					: MPEG Audio
Format version					: Version 1
Format profile					: Layer 2
Internet media type				: audio/mpeg
Codec ID					: 3
Codec						: MPEG-1 Audio layer 2
Duration					: 00:01:06.624
Bit rate mode					: Constant
Bit rate					: 256 Kbps
Channel(s)					: 2 channels
Sampling rate					: 48.0 KHz
Samples count					: 3197952
Frame count					: 2776
Compression mode				: Lossy
Delay						: 00:00:00.268
Delay, origin					: Container
Delay relative to video				: -15
Video0 delay					: -15
Stream size					: 2.03 MiB (1%)
Proportion of this stream			: 0.00603
Language					: en

Audio #2
Count						: 222
Count of stream of this kind			: 2
Kind of stream					: Audio
Stream identifier				: 2
StreamOrder					: 0-2
ID						: 65 (0x41)
Menu ID						: 137 (0x89)
Format						: MPEG Audio
Commercial name					: MPEG Audio
Format version					: Version 1
Format profile					: Layer 2
Format settings					: Intensity Stereo + MS Stereo
Mode extension					: Intensity Stereo + MS Stereo
Internet media type				: audio/mpeg
Codec ID					: 3
Codec						: MPEG-1 Audio layer 2
Duration					: 00:01:06.648
Bit rate mode					: Constant
Bit rate					: 256 Kbps
Channel(s)					: 2 channels
Sampling rate					: 48.0 KHz
Samples count					: 3199104
Frame count					: 2777
Compression mode				: Lossy
Delay						: 00:00:00.255
Delay, origin					: Container
Delay relative to video				: -28
Video0 delay					: -28
Stream size					: 2.03 MiB (1%)
Proportion of this stream			: 0.00603
Language					: en

I have no idea how they are encoding the 5.1 but I can assure you it's there, and all I want to do is use ffmpeg to convert it and similar files to ac3 so XBMC will play them in 5.1.  Can anyone tell me what I am doing wrong?


More information about the ffmpeg-user mailing list