ffmpeg help required

Discussion in 'Digital Audio' started by plinden, Feb 20, 2011.

  1. plinden macrumors 68040


    Apr 8, 2004
    I have a point and shoot camera that takes decent (decent = nothing else to compare to) 720p video. It stores the video as AVDHC, ie mts files.

    Up to now, I've been keeping a copy of the mts files, and loading them as needed into iMovie when I want to create a H.264 version for uploading or sharing. The conversion process takes some time, and there is probably some loss of quality, although not visible in normal use.

    Just recently I realized that the codec of the video in the mts is already H.264, while the audio codec is ac3 (which isn't supported on Apple s/w). I had the idea that if I could pull out the H.264 as is and re-encode the audio as aac and store them in an mp4 container, I could continue using the reencoded file as backup and eg in FrontRow. (By the way, yes, I've tried and VLC plays the mts files, but I'm after ease of use here - ie spousal acceptance)

    Handbrake reencodes the mts as mp4, with two audio streams, ac3 and aac, but also reencodes the video with some loss of quality, so I turned to ffmpeg.

    I've compiled ffmpeg with aac and liblamemp3 support, and tried a few runs to get this right, but haven't succeeded in fixing the audio.

    The following was a trial run - the H.264 video and the ac3 audio was copied exactly to a new mp4 container. This plays in VLC, but of course not in QT or FrontRow.
    ffmpeg -i <file>.mts -vcodec copy -acode copy <file>.mp4
    Since I compiled with aac support, the following re-encodes the audio to aac, results in a perfect video and plays in VLC, QT and FR, but with badly distorted, echo-y, audio
    ffmpeg -i <file>.mts -vcodec copy <file>.mp4
    The following results in perfect video that plays fine in VLC, but has no sound in QT or FR:
    ffmpeg -i <file>.mts -vcodec copy -acode libmp3lame <file>.mp4
    I would like to produce something similar to HandBrake, but with the video codec copied without re-encoding, and both aac (without distortion) and ac3 audio.

    Does anyone know of a way of doing this?
  2. plinden thread starter macrumors 68040


    Apr 8, 2004
    If anyone comes here looking for an answer to something similar, I solved my issue to my satisfaction.

    Looking back over what I did, I noticed I hadn't compiled ffmpeg with libfaac enabled. After doing so, I find that the following converts the mts to mp4 with 160kb/s aac audio (the ac3 source is 192kb/s), no distortion:
    ffmpeg -i <file>.mts -vcodec copy -ab 160k <file>.mp4
    Since it's just a point-and-shoot camera, I realized I'm not missing much converting from ac3 to aac, so a single aac audio stream is good enough.

Share This Page