You are not logged in.

#1 2010-11-13 13:24:20

vpoinot
Member
Registered: 2009-04-09
Posts: 19

Video encoding: file size & quality (Kdenlive)

I have a 30-minute long 1Gb video (shot with a HD camcorder). If I run ffmpeg -i on my file, here is the output:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'MAH00018.MP4':
Metadata:
major_brand : MSNV
minor_version : 20054119
compatible_brands: MSNVmp42isom
Duration: 00:29:50.82, start: 0.000000, bitrate: 4328 kb/s
Stream #0.0(und): Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 4193 kb/s, 59.94 fps, 59.94 tbr, 60k tbn, 119.88 tbc
Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 127 kb/s

From this video, I want to keep about 8 minutes, with a couple transition effects (I am using Kdenlive). Now I have no idea what rendering profile to use. Since I need to keep approximately 1/4 of the original video, I naively assume that the output video should be about 250 Mb without any loss in quality/video size. However when I chose a lossless HQ profile, I got a 2Gb video... for 8 minutes !

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'result.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2mp41
encoder : Lavf52.78.3
Duration: 00:08:04.39, start: 0.000000, bitrate: 32795 kb/s
Stream #0.0(und): Video: mpeg4, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 32476 kb/s, 60 fps, 60 tbr, 60 tbn, 60 tbc
Stream #0.1(und): Audio: mp3, 48000 Hz, 2 channels, s16, 320 kb/s

I must be doing something wrong. It has probably something to do with the bitrate figures (the original has a lower bitrate than the output...).

I then tried an other profile and got a 250 Mb video, but the quality is terrible (large pixel blocks, etc.). Here are its properties:

Seems stream 0 codec frame rate differs from container frame rate: 120.00 (120/1) -> 59.94 (60000/1001)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'result2.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf52.78.3
Duration: 00:08:04.30, start: 0.000000, bitrate: 4169 kb/s
Stream #0.0(und): Video: h264, yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 4034 kb/s, 60 fps, 59.94 tbr, 60 tbn, 120 tbc
Stream #0.1(und): Audio: aac, 48000 Hz, stereo, s16, 127 kb/s

Clearly neither result is satisfactory, which brings me to my questions:
- how do I select a rendering profile based on the characteristics of the original video? Assuming I don't want to resize it, nor loose quality, that is.
- if I am ready to favor file size over picture quality, what would you recommend: lower bitrate? lossy codec? which one?
- what is the number pass good for? quality? E.g. for a given codec/bitrate, etc. if I select 2 passes, will I have a better result that if I had selected only one? How does this impact file size?

Any help much appreciated.

Offline

#2 2010-11-14 01:02:00

ChoK
Member
From: France
Registered: 2008-10-01
Posts: 346

Re: Video encoding: file size & quality (Kdenlive)

From this video, I want to keep about 8 minutes, with a couple transition effects (I am using Kdenlive). Now I have no idea what rendering profile to use. Since I need to keep approximately 1/4 of the original video, I naively assume that the output video should be about 250 Mb without any loss in quality/video size. However when I chose a lossless HQ profile, I got a 2Gb video... for 8 minutes !

The original video is already compressed, that's why when you choose lossless the output is bigger.


Clearly neither result is satisfactory, which brings me to my questions:
- how do I select a rendering profile based on the characteristics of the original video? Assuming I don't want to resize it, nor loose quality, that is.
- if I am ready to favor file size over picture quality, what would you recommend: lower bitrate? lossy codec? which one?
- what is the number pass good for? quality? E.g. for a given codec/bitrate, etc. if I select 2 passes, will I have a better result that if I had selected only one? How does this impact file size?
Any help much appreciated.

The best way to encode is by having kdenlive produce an uncompressed video (huffyuv for example since you already work in yuv colorspace)
Then use a dedicated tool to encode it i.e. avidemux or handbrake.
You have to use a lossy codec anyway, (unless you want a video of 50 times the size). The best codec to use is h264 (compatible with just about everything, offers hardware acceleration, and clearly best picture quality for the size)

When encoding to h264, easiest way is to specify a crf (constant rate factor) and adjust it if the resulting size is too big. It means you target a quality and the codec will do it's best to reduce the filesize given the quality constraint.
I know there is a target bitrate option but, depending on the clip you will need more or less and without experience you won't know if your bitrate is enough or too much. Also you need 2-pass with target bitrate if you don't want garbage. (well I have a critical eye regarding quality so ...)

Usually 2-pass is better than 1 if you specify a target bitrate/filesize, on the first pass the codec will gather information like which scenes need more data (because of fast movements for example) and which needs less. And with this knowledge it will optimize the second pass.
If you target a quality (with crf) you don't set a space requirement, you will only need 1 pass. Targeting a quantizer is possible but it's better to use crf.

Some infos
http://doom10.org/index.php?topic=267.0 difference between crf and 2-pass
http://mulder.dummwiedeutsch.de/pub/x264/ Avidemux options guide
http://mewiki.project357.com/wiki/X264_Settings x264 settings

There are so much options that things can seem daunting so use a base preset and modify it according to your fancy (after reading the doc)

Last edited by ChoK (2010-11-14 01:03:58)


Ah, good taste! What a dreadful thing! Taste is the enemy of creativeness.
Picasso
Perfection is reached, not when there is no longer anything to add, but when there is no longer anything to take away.
Saint Exupéry

Offline

Board footer

Powered by FluxBB