How to archive Digital Camera Videos as MP4 (H264 + AAC)

Share with other users your experience in using MediaCoder.
Post Reply

Is this guide helpful to you?

No - I think it was misleading.
1
33%
No - it didn't tell me anything new.
0
No votes
Yes - a little helpful.
0
No votes
Yes - quite helpful.
1
33%
Yes - very helpful.
1
33%
 
Total votes: 3

nosignal
Amateur
Amateur
Posts: 21
Joined: Sun Feb 17, 2008 6:24 pm

How to archive Digital Camera Videos as MP4 (H264 + AAC)

Post by nosignal » Wed Jul 22, 2009 11:33 am

If you are anything like me, your digital camera records videos as motion jpg and uncompressed audio, which is huge, and does not play on many computers (without installing VLC etc). My solution was to convert to MP4 (H264 + AAC) which plays in Windows Media Player 11 on the PC and Quicktime on the Mac - both installed by default. Whats more, it can give me 4x to 8x smaller files for little quality loss (the result will have less noise and loose very fine pixel detail, but any compression will do that or worse), and you can even throw some noise reduction in to make it look better. Importantly, you can still edit the clips in modern video editors, like premiere - the new clips have exactly the same length and no audio sync issues (which can easily happen with other setups). And as a kicker - uploading the result to YouTube will produce very good results for numerous reasons I won't get into here.

But there are a few gotchas, so I thought it was worth detailing it below.

In essence, you want:
Video:
  • Format: H.264
  • Mode: Quality based (This is important: gives consistently good quality and can more than halve bitrates for less complex videos!)
  • Quality: 60 (Gives best practical quality. Very slight improvement at 70 for much bigger files, no perceptible improvement above that).
Audio: (Based on my source being 8bit, 16khz, mono)
  • Encoder: FAAC
  • Resample: 32000Hz
  • FAAC: Average Bitrate: 48kbps, MPEG4, Container MP4.
Container: MP4
Picture
  • Many of these settings can be useful to improve your material before output.
  • Rotation: Allows you to film in portrait and rotate it to look right on screen.
  • Effects: Definitely use 3D noise reduction. Others might help too, but can be tricky (the original video codec fails to preview for me)
Text (Optional): Output name formatting to "$(SourceFileName)_H264_Q60" (without the quotes)

Notes:
This assumes VGA video at 25-30fps. However, because it uses a Quality Based option, it should be quite universal.
If you are willing to sacrifice some more detail, Quality can go down to 55 for up to half the filesize (but I wouldn't recommend it).
Your audio settings may vary, depending on what your camera produces. But as a general rule:
  • FAAC is the only AAC codec (therefore the only MP4 codec) that has perfect audio-video sync (others lag audio up to 3 frames!)
  • FAAC is also the only legally free codec I am aware of. In theory FFmpeg should work, but failed for me.
  • Resampling to 32khz is optional, but I found it made the result sound better.
  • 48kbps sounds much better than 24kbps (for both 16khz and 32khz). Other codecs can sound good at 24kbps, but have lag or other issues.
I've done considerable research on these settings, which I will detail in the following post.
Last edited by nosignal on Wed Jul 22, 2009 11:46 am, edited 1 time in total.

nosignal
Amateur
Amateur
Posts: 21
Joined: Sun Feb 17, 2008 6:24 pm

Re: How to archive Digital Camera Videos as MP4 - Research Notes

Post by nosignal » Wed Jul 22, 2009 11:41 am

=====================

Audio Details on the different Cameras:

OptioS4:8khz, 8bit, mono 16kbps
FZ3: 8khz, 8bit, mono 16kbps
a720: 11khz, 8bit, mono 20kbps
Ixus80: 44khz, 16bit, mono 64kbps
f30: 16khz, 8bit, mono 24kbps
- NOTE 32khz, ?bit, mono 48kbps - works better for some encoders (and is equivalent bitrate to "44khz, 16bit, mono, 64kbps").

NOTE: In VirtualDub, LAME needs 16-bit audio in order to be able to encode it.

=====================

Comparing Video Codecs:

For VGA video, Use H264, Q60:
- not much bigger than Q55, and a little extra detail.
- not as blocky as MPEG2, which can be noticable.
- looses fine texture/detail compared to original and mpeg, but is acceptable.
--- this can also mean less noise - a good thing.
- Quality vs VBR: better all the time. Simple scenes are smaller too (4mb vs 10mb!).
- No XViD can compare in quality or usability (in Adobe products). Don't bother.
--- Besides, 2x 31% videos would defeat the purpose of re-encoding!

For qVGA video, probably also Use H264, Q60:
- untested.

=====================

Comparing Audio Codecs (AAC for MP4):

All tests are H264, Q55 where possible.

Original
.avi avi 90,215 KB 16khz Quality: 50

Handbrake
aac 16b32Khz, 48k.mp4 mp4 10,276 KB audio lag: 0 frames at 0:06. 0 frames at 0:56 32khz Quality: 60? crisper, but more tinny and noise more irritating. Too much high tone? But turn down volume and its quite good.
- used vd to convert audio to 16-bit 32khz, then used this in handbrake
aac 32Khz, 48k.mp4 mp4 6,930 KB audio lag: -1 frames at 0:06. -1 frames at 0:56 32khz Quality: 35. a litte bit muffled. mutes first bit of audio. not too bad
- videos are 1 frame short
- appears to use FAAC for AAC - no better than MediaCoder
- 0.9.3 needs 16-bit (maybe even 32khz) audio or it corrupts
- 0.9.3 snapshot-svn2592-Win_GUI_CLI (fixed Audio, BUT BUGGY)

SUPER
4000kbps, AAC-LC 24k DS.MP4 mp4 39,058 KB audio lag: 0 frames at 0:06. 0 frames at 0:56 16khz Quality: 25. definitely more muffled
4000kbps, AAC-LC 24k.MP4 mp4 39,048 KB audio lag: 0 frames at 0:06. 0 frames at 0:56 16khz Quality: 25. definitely more muffled
- AAC with ffmpeg?
- no Quality option. So not worth it.

MediaCoder
FAAC 24k.mp4 mp4 7,637 KB audio lag: 0 frames at 0:06. 0 frames at 0:56 16khz Quality: 25. definitely more muffled
FAAC 48k.mp4 mp4 7,901 KB audio lag: 0 frames at 0:06. 0 frames at 0:56 16khz Quality: 45. almost identical to original
FAAC 32khz, 24k.mp4 mp4 7,861 KB audio lag: 0 frames at 0:06. 0 frames at 0:56 32khz Quality: 20. very muffled. not enough kbps
FAAC 32khz, 48k.mp4 mp4 8,093 KB audio lag: 0 frames at 0:06. 0 frames at 0:56 32khz Quality: 65? crisper, NOT tinny. noise bit more irritating. Too much high tone? But turn down volume and its quite good.
- perfect sync
- BUT audio quality is bad. Development has stopped on this codec.
Nero HE-AAC 24k.mp4 mp4 7,854 KB audio lag: 3 frames at 0:06. 3 frames at 0:56 8khz Quality: 38. a bit worse/duller
Nero LC-AAC 24k.mp4 mp4 7,857 KB audio lag: 3 frames at 0:06. 3 frames at 0:56 16khz Quality: 45. almost identical to original
Nero Auto 24k.mp4 mp4 7,856 KB audio lag: 3 frames at 0:06. 3 frames at 0:56 8khz = HE-AAC
CT aacPlus, 32khz noUS, 24k.mp4 mp4 7,853 KB audio lag: 1 frames at 0:06. 1 frames at 0:56 16khz Quality: same as with US (below).
CT aacPlus, 32khz, 24k.mp4 mp4 7,854 KB audio lag: 1 frames at 0:06. 1 frames at 0:56 16khz Quality: 60? crisper, but more tinny and noise more irritating. Too much high tone? But turn down volume and its quite good.
- This is a contender. 1 frame lag is not too bad.
- aacPlus needs 32khz or greater, and viable bitrate. If not, can get errors like:
--- "audio and video cannot be muxed"
--- "needs the WinAmp dll" (even if it already has it!)
CT aacPlus, 32khz, 48k.mp4 mp4 8,090 KB audio lag: 1 frames at 0:06. 1 frames at 0:56 16khz Quality: 61? maybe very slightly better than 24k. Maybe more noticable with better source audio.
CT LC-AAC, 32khz, 24k.mp4 mp4 7,850 KB audio lag: 0.5 frames at 0:06. 0.5 frames at 0:56 24khz Quality: 38. a bit worse/duller
CT LC-AAC, 32khz, 48k.mp4 mp4 8,085 KB audio lag: 0.5 frames at 0:06. 0.5 frames at 0:56 32khz Quality: 62? sounds like better hz than 24k?! I guess it needs 48k to go up to higher hz.
- This is a contender. 0.5 frame lag pretty good

Conclusion:
Bad:
- Handbrake. A hassle. Not great quality, maybe FAAC.
- SUPER. No Quality based. Audio sounds muffled.
- FAAC 24k. Keeps KHz and sync well. But at 24k sounds bad.
- Nero HE-AAC. Bad lag. Not great quality. down to 8khz!
- Nero LC-AAC. Bad lag. Quality is good - closest to original.
Good:
- FAAC 16khz, 48k. 0 frame lag. same as original. But some squelshing of background sound when foreground sound peaks. Legally free.
- FAAC 32khz, 48k. 0 frame lag. crisp. Not tinny. I deem it worth 48k for less lag and extra quality capacity. Legally free.
- CT aacPlus, 32khz, 24k. 1 frame lag. crisp.
- CT LC-AAC, 32khz, 48k. 0.5 frame lag. crisp at 48k. I deem it worth 48k for less lag and extra quality capacity.

Conclusion: Use FAAC 32khz, 48k:
- Legally Free
- no lag
- same quality as runner up (CT LC-AAC).
- 48k worth it - negligible compared to video (1600k to 4000k).

=====================

Comparing Encoders:

Ideally, I would use just MediaCoder. It can
- Batch
- Rotate
- Colour Correct
- Encode with 'original' settings. E.g. fps, resolution, audio khz etc. Very Handy.
- Encode H264 MP4 correctly
--- Audio is now fine if encoded with FAAC.
----- See "MediaCoder MP4 Audio Sync Issue" below.
--- Audio drifts out of sync if using Nero.
--- I did not used to have a solution, so I though MediaCoder was unusable.
- Encode H264 MP4 with Quality-Based encoding - Q60 retains detail AND can be 4mb vs 10mb (c.f. 4000k CBR).
- Encode XViD correctly (Adobe products corrupt XViD export).
SO MediaCoder is now usable by itself.

Adobe Media Encoder CS4 (AME) can:
- Batch
- Export H264 MP4 correctly
- Keep audio sync.
BUT can't
- Rotate
- Colour Correct
- Encode with 'original' settings. E.g. fps, resolution, audio khz etc. Very Handy.
--- Can't encode at 14fps at all!
- Encode H264 MP4 with Quality-Based encoding - Q60 retains detail AND can be 4mb vs 10mb (c.f. 4000k CBR).
- Export XViD correctly (Adobe products corrupt XViD export).

AME Has a filters tab, but there does not seems to be any way to add filters too it.
- no filters online
- adding other adobe aex filters etc does nothing.

Apparently, can use Nikon Picture Project to rotate MOVs without re-encoding!
- maybe only Nikon MOVs?
- software hard to find - discontinued.
- apparently PP can cause problems.

Quicktime Pro can rotate MOVs easily.
- Info - Video - ...
- What about levels and color correction and NR?

=====================

MediaCoder MP4 Audio Sync Issue:

"has lag" = audio 3 frames lagging, 20 seconds into the clip.

Start with AVI - mjpeg
Encode Original to H264 using MediaCoder - has lag
- changing source from auto to MPlayer or MEncoder makes no difference.
- Changing Nero profile settings to Auto, LC-AAC, HE-AAC makes no difference.
- Changing Encoder from NEro to FAAC fixes the sync problem!
--- BUT FAAC is not great audio quality.
Encode huffy to H264 using MediaCoder - has lag
Encode huffy to XViD using MediaCoder - has lag, and 5 frames shorter than original! Using XViD and Lame, just like VD (which works?!)
Encode Original to huffy using AME - no lag
Encode huffy to H264 using AME - no lag, BUT AME can't do quality based (can be 10mb vs 4mb!)
Encode huffy to huffy using VD (DS aud)- no lag
Encode original to XViD using VD (mp3) - no lag, BUT can't do H264, MP4
Encode huffy to XViD using VD (mp3) - no lag

Conclusion:
- In MediaCoder, it was the Nero audio encoder causing grief. Replaced with FAAC it is fine.
- Now has no audio sync issues.
- NOTE: XViD gets encoded to a different length, creating different sync issues.

=====================

slobjones
Beginner
Beginner
Posts: 2
Joined: Mon Aug 31, 2009 11:38 am

Re: How to archive Digital Camera Videos as MP4 (H264 + AAC)

Post by slobjones » Mon Aug 31, 2009 11:54 am

Thanks for this guide. A few questions:
FAAC: Average Bitrate: 48kbps, MPEG4, Container MP4.
Where do I input 48kbps? Under the Average Bitrate selection, I see "Lowest-Highest" with a window in the middle that defaults to "128". Do I replace this number with "48"?

My Canon a570IS produces M-JPEG with 8-bit PCM audio, bit rate 88kbps. Is 48 still an appropriate selection?
Rotation: Allows you to film in portrait and rotate it to look right on screen.
I don't see an option in Picture to rotate the output. Where do I find that option?

nosignal
Amateur
Amateur
Posts: 21
Joined: Sun Feb 17, 2008 6:24 pm

Re: How to archive Digital Camera Videos as MP4 (H264 + AAC)

Post by nosignal » Mon Sep 07, 2009 2:03 pm

Hi Slobjones,
Where do I input 48kbps? Under the Average Bitrate selection, I see "Lowest-Highest" with a window in the middle that defaults to "128". Do I replace this number with "48"?
In the FAAC settings, if you use "Average Bitrate", then the number in the lowest-highest box = XXkbs. So yes, you replace 128.
My Canon a570IS produces M-JPEG with 8-bit PCM audio, bit rate 88kbps. Is 48 still an appropriate selection?
The most important info is what frequency the audio is (Frequence to audio is like resolution to images - the higher, the crisper the sound. Audio CDs are 44kHz). At a guess, your camera is 11kHz mono. My settings were 32kHz mono at 48kbps, so you could probably go lower - maybe 24kbps, but to be honest it is such a small fraction compared to the video, you should probably keep it at 48kbps.

Finally, I would suggest if you are unsure - give it a go a couple of different ways on a short clip, then play them back and compare them - you learn a lot this way, and get a 'real' answer (as opposed to an friendly guess).

nosignal
Amateur
Amateur
Posts: 21
Joined: Sun Feb 17, 2008 6:24 pm

Re: How to archive Digital Camera Videos as MP4 (H264 + AAC)

Post by nosignal » Mon Sep 07, 2009 2:06 pm

Hi again slobjones,
I don't see an option in Picture to rotate the output. Where do I find that option?
Yes, after version 0.7.0.4399 they hid this feature, but it is still there. To be honest, I still use the olde version for this reason, but apparently it's in the "Settings" or Advanced Settings (Video Filters/Rotate....) (according to viewtopic.php?f=17&t=6991&start=0 ).

vrpatilisl
Beginner
Beginner
Posts: 2
Joined: Sat Jul 27, 2013 6:07 pm

Re: How to archive Digital Camera Videos as MP4 (H264 + AAC)

Post by vrpatilisl » Sat Jul 27, 2013 6:29 pm

Nice and helpfull post,
I have few questions, i also have some videos from canon, may times i read that CRF 18 in vidcoder/handbrake do very nice job for converting to MP4 and MKV. what you say regarding this. What would be CRF 18 in terms of quality in MEDIA CODER.
any Advantage of MKV over MP4.
thax

Ludwighysly
Beginner
Beginner
Posts: 1
Joined: Thu Aug 29, 2013 5:47 pm

Re: How to archive Digital Camera Videos as MP4 (H264 + AAC)

Post by Ludwighysly » Thu Sep 05, 2013 8:37 pm

This will install the wine sources for you
next in the command line prompt you need to use these commands

deena
Beginner
Beginner
Posts: 1
Joined: Wed Oct 29, 2014 10:46 pm

Re: How to archive Digital Camera Videos as MP4 (H264 + AAC)

Post by deena » Wed Oct 29, 2014 10:50 pm

Hello
I like this answer
This will install the wine sources for you
next in the command line prompt you need to use these commands
roma

Post Reply