ffmpeg oddity: AVCHD -> MPEG4, results in *smaller* file size

Discussion in 'Amateur Video Production' started by Theo, Jan 30, 2008.

  1. Theo

    Theo Guest

    Hello, all. I have successfully set up my Ubuntu Linux 7.10 system to
    decode AVCHD into MPEG-4 AVC (with MP3 audio) in an AVI container. I
    am doing this through a series of steps through different programs
    (xporthdmv to split the audio and video from the MTS file, then ldecod
    to encode the .mpv video into .yuv, and then ffmpeg to encode the .yuv
    into mpeg4 and put everything back together in an .avi container)

    Everything seems to work, except that now the resulting .avi is of
    significantly smaller file size than the original MTS (AVCHD) file,
    which from what I understand, should be the opposite (AVCHD being
    efficiently compressed, and the uncompressed data should be about x4
    the file size). I am wondering if I am accidentally downgrading the
    quality or other data in my process. Here is my ffmpeg command:

    ffmpeg -r 29.97 -s 1440x1080 -i $videofifo -i
    $audiofile \
    -vcodec mpeg4 -aspect 16:9 -sameq
    -b 15000k \
    -acodec libmp3lame -ac 2 -
    ab 256000 \

    $outputfile

    The original file is from a Canon HG10, outputting to 1440x1080
    interlaced, supposedly 60 frames per second (1080/60i), and at 9 mb/s
    bitrate (less than the "full" 15 mb/s bitrate of HD, but still good
    quality).

    The format I am wanting it to encode into is MPEG-4 AVC at the same
    quality for everything possible, with no loss of quality. This is for
    importing into a video editing system, so I'll downgrade the quality
    for distribution later.

    The file size is resulting in about 20-25% less than original (an 80MB
    MTS file come out as a 60MB MPEG4/AVI file.)

    Some things I think that might be causing the problem, but don't know
    enough about encoding to verify:

    * Since the original is supposedly in 60 frames per second, and I'm
    currently in 30 frames per second, could that be the cause? I've tried
    encoding in 60 fps in the ffmpeg stage, but the resulting video does
    not play well: it is too fast, and out of sync with audio.
    * The video is a Blue Screen production, so most of the background is
    stationary and a solid color. Could the MPEG4 be compressing this,
    resulting in the smaller file size?

    Thanks for any help.
     
    Theo, Jan 30, 2008
    #1
    1. Advertisements

  2. Theo

    Ken Maltby Guest

    It sounds like you are saying that you intend to edit in the
    "MPEG-4 AVC" format, not the most common approach.
    By the way AVCHD is a form of "MPEG4 AVC" closely
    related to AVC/H.264 or MPEG4 Part 10.

    You might want to consider this:
    http://www.elecard.com/products/products-pc/consumer/avchd-dv-transcoder/

    There are a growing number of AVCHD capable programs
    but you will still have many more options editing in DV25 or
    uncompressed RGB. ( This is much like the earlier days when
    MPEG2 editing was just getting started. )

    Luck;
    Ken
     
    Ken Maltby, Jan 30, 2008
    #2
    1. Advertisements

  3. Theo

    Frank Guest

    ffmpeg oddity: AVCHD -> MPEG4, results in *smaller*
    file size>,

    Personally, I would use the 15 Mbps recording mode. Even at that rate,
    you get over five hours of recording time.


    Theo, the recording format is 59.94 fields per second, not 60 frames
    per second. The video is interlaced and there are two fields, an upper
    and a lower, per frame, so the frame rate is 29.97 frames per second.


    You would want to maintain, on the output side, the same 59.94 field
    per second (29.97 frame per second) rate as the source.

    The chosen datarates will determine the size of the output file. If
    your source is 9 Mbps and you re-encode to 18 Mbps, the output file
    will be about twice the size of the input file, for example, changes
    to the audio notwithstanding.
    Like Ken said.
     
    Frank, Jan 30, 2008
    #3
  4. Theo

    Theo Guest

    Yes, I certainly will be doing this in the future. The 9 MB/s was a
    bit of an accident, unfortunately.
    Ah, OK, I was thinking this might be the case, but thought it was 60
    frames because every technical spec I'd read mentioned "frames"
    instead of fields.

    Here the result seems to be opposite, though. I have 9 MB/s files, re-
    encoding to 15 MB/s (can be seen in the ffmpeg command in last post),
    and the resulting file is 25% smaller.

    Thanks both of you. I'll be playing around some more. I am also
    attempting some lossless codecs.
     
    Theo, Jan 31, 2008
    #4
  5. Theo

    Frank Guest

    ffmpeg oddity: AVCHD -> MPEG4, results in *smaller*
    file size>,
    You should see a picture quality improvement at the higher data rate,
    especially in fast-action scenes.

    Well, we do often talk about frames per second, but in NTSC SDTV, it's
    29.97 frames per second, not 60 frames per second. There are 59.94
    fields per second in NTSC SDTV, which is sometimes (inaccurately)
    referred to as 60 fields per second, just as the frame rate is
    sometimes (inaccurately) referred to as 30 frames per second instead
    of 29.97 frames per second.

    Note that in the ATSC HDTV world, depending upon frame size, both full
    (30, 60) and fractional (29.97, 59.94) rates are supported, so it's
    more important there to accurately describe frame and field rates.

    Just for the record, the so-called 24 frames per second progressive
    mode on your HG10 is actually 23.976 frames per second because it's
    embedded (with a 2:3 pulldown) within a 59.94i datastream. 23.976 is
    sometimes referred to as 23.98, but that's okay because it really does
    mean the same thing.

    Then you're changing something else, such as the audio data rate, the
    video frame rate, the video frame size, etc., to cause the decreased
    file size.

    Side note: MB means megabyte and Mb means megabit. There's a rather
    large (8-to-1 ratio) difference between the two. :)

    By the way, I think that you mentioned that you're changing the audio
    (which may not be important in your particular application) to MP3. Be
    aware that there's a drop in sound quality when transcoding from a
    lossy compressed format such as Dolby Digital AC-3 (which is what your
    HG10 records) to another lossy compressed format such as MPEG Layer
    III.
    Good lossless video codecs would include Huffyuv and Lagarith, the
    latter of which is my favorite. While not necessarily a bad thing,
    Huffyuv hasn't been updated in ages, whereas Lagarith is still
    actively supported.

    Huffyuv 2.1.1
    http://neuron2.net/www.math.berkeley.edu/benrg/huffyuv.html

    Lagarith 1.3.14 (released July 20, 2007)
    http://lags.leetcode.net/codec.html

    Good luck!
     
    Frank, Jan 31, 2008
    #5
  6. Theo

    Theo Guest

    My problem is solved. It must have been the fact I was transcoding to
    mpeg4. I have finally figured out how to transcode into HuffYUV, and
    my resulting files are now properly gigantic (a 30 MB AVCHD file now
    results in a 1 GB HuffYUV video). I will be trying out Lararith. I
    hope it works with ffmpeg, VLC, and Blender3d well.
     
    Theo, Feb 10, 2008
    #6
  7. Theo

    kaptajnen

    Joined:
    Feb 20, 2008
    Messages:
    1
    Likes Received:
    0
    Is it possible to transfer video directly from HG10 to a linux machine via USB?

    Is it possible to transfer video directly from HG10 to a linux machine via USB?
     
    kaptajnen, Feb 20, 2008
    #7
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.