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

bluesky at caramail.com bluesky at caramail.com
Tue Nov 4 11:16:32 CET 2014

"Carl Eugen Hoyos" <cehoyos at ag.or.at> wrote:

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

> Complete, uncut console output missing, I don't remember
> a question where mediainfo output was useful.

Sorry, different forums want to see different types of information, and in some they give you a hard time if you post a message that is too long.  I will post console output at the bottom of this message.

> How do you know that your input file contains surround
> information? Is it because you have a dolby certified
> receiver that allows you to play two-channel audio with
> surround effects?

First off, please don't use too much technical jargon with me, I really don't understand it.  My receiver has the Dolby digital logo (and DTS and THX logos) on it.  But the reason I know the file contains surround information is very simple:  One of the files is an audio test file where someone says "Left, Right, Center, (low hum for subwoofer), Left surround, Right surround" and if I play that file in MythTV it plays with all the sounds coming from the correct speakers.  If I play the same file in XBMC only the front speakers are used.

>In this case, do not reencode audio:
> FFmpeg has a Dolby PLII encoder (resampler) but no
> decoder, just convince xbmc to not mess with audio and
> allow your receiver to do what is necessary.
> (Analog input may be required iirc.)

Any suggestions on how to actually do that?  I have tried every setting that looks even remotely related.

Since I am new to the list I should probably state that I am not a developer or even a very technically-inclined user.  When I posted my message I was hoping maybe it was just some setting or switch I was not using in ffmpeg that I should be using, and that maybe some kind person could tell me what I am doing wrong.  But if you bury me in technical jargon I'm not going to understand what you are telling me so PLEASE try to keep it simple.

Here is what I think you mean by "console output".  And before you try to tell me there is no 5.1 in this file, this is the channel test recording I mentioned above and I can assure you that it does play in 5.1, with the channel identifications coming from the correct speakers, if played using MythTV.  So I have no idea why ffmpeg doesn't seem to notice the 5.1 any more than a mediainfo type program.  This is a mystery to me!

$ ffmpeg -i "5.1 Audio Test.ts" -c:v copy -c:a ac3 "new.ts"
ffmpeg version 2.4.2-   http://johnvansickle.com/ffmpeg/    Copyright (c) 2000-2014 the FFmpeg developers
  built on Oct  9 2014 07:24:56 with gcc 4.8 (Debian 4.8.3-11)
  configuration: --enable-gpl --enable-version3 --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --disable-ffserver --enable-libass --enable-gnutls --cc=gcc-4.8
  libavutil      54.  7.100 / 54.  7.100
  libavcodec     56.  1.100 / 56.  1.100
  libavformat    56.  4.101 / 56.  4.101
  libavdevice    56.  0.100 / 56.  0.100
  libavfilter     5.  1.100 /  5.  1.100
  libswscale      3.  0.100 /  3.  0.100
  libswresample   1.  1.100 /  1.  1.100
  libpostproc    53.  0.100 / 53.  0.100
[mpeg2video @ 0x415d560] Invalid frame dimensions 0x0.
    Last message repeated 8 times
Input #0, mpegts, from '5.1 Audio Test.ts':
  Duration: 00:01:06.83, start: 0.254678, bitrate: 42317 kb/s
  Program 137
    Stream #0:0[0x30]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 40033 kb/s, 29.97 fps, 29.97 tbr, 90k tbn, 59.94 tbc
    Stream #0:1[0x40](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 244 kb/s
    Stream #0:2[0x41](eng): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 244 kb/s
Output #0, mpegts, to 'new.ts':
    encoder         : Lavf56.4.101
    Stream #0:0: Video: mpeg2video ([2][0][0][0] / 0x0002), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 40033 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
    Stream #0:1(eng): Audio: ac3, 48000 Hz, stereo, fltp, 192 kb/s
      encoder         : Lavc56.1.100 ac3
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (mp2 (native) -> ac3 (native))
Press [q] to stop, [?] for help
[mpegts @ 0x41597c0] PES packet size mismatchme=00:00:35.38 bitrate=42685.8kbits/s
[mp2 @ 0x415fc20] incomplete frame
Error while decoding stream #0:1: Invalid data found when processing input
frame= 1993 fps=0.0 q=-1.0 Lsize=  352244kB time=00:01:06.78 bitrate=43209.0kbits/s
video:324924kB audio:1562kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 7.889561%

I should note that ffmpeg always complains about invalid frames or data at the beginning and end of these recordings, I do not know why but suspect it's because the recordings start and end based on time of day, and simply copy the transport stream to the hard drive without making any attempt to start or stop the recording on a frame boundary.  But, that is just a wild guess on my part.

More information about the ffmpeg-user mailing list