View Full Version : Lossless re-encoding of H.264?
TazmanianD
8th April 2009, 03:02
I'm wondering if there are any applications that can do a lossless re-encoding of H.264 video. I have some MP4 files I acquired from a digital camera and I was wondering if I could reduce the file sizes by re-encoding them with some parameters more optimized for smaller files. For example, the file has an I-frame every 15 frames. If I could find an encoder that could replace, say, half of those I-frames with a P-frame, that would reduce the file size (obviously at the expense of render complexity or seek times). I think there are other parameters that affect file size, but not quality that could be tweaked, but I'm not an H.264 expert.
I've been using avidemux to cut out bits of the video I don't need, but it only does a direct stream copy beginning at an I-frame without the ability to change the encoding parameters.
LoRd_MuldeR
8th April 2009, 03:07
Re-encoding is inherently lossy, unless you convert to a lossless format. But converting from a lossy format to a lossless one will result in a bigger file...
(BTW: Direct Stream Copy needs to start at an I-Frame for obvious reasons. And of course it cannot change any encoding parameters, as it doesn't encode)
Chengbin
8th April 2009, 03:34
Since the video is from a digital camera, which I'm gonna assume is not that high quality. You can use some smart avisynth tools and create a lossy H.264 encoding at 1/5 of the bitrate and will look as good, most likely better, than the original video.
LoRd_MuldeR
8th April 2009, 03:54
When re-encoding to a lossy format, which H.264 is (unless "lossless" mode is used), the quality can never become better.
The re-encoding will unavoidably cause some additional loss. The best thing you can achieve is minimizing the additional loss down to the point where it is barely visible.
Anyway, I agree that with x264 he should be able to retain an acceptable quality at a lower bitrate than the original H.264 file was. But 1/5 is a bit optimistic ;)
Chengbin
8th April 2009, 04:02
When re-encoding to a lossy format, which H.264 is (unless "lossless" mode is used), the quality can never become better.
The re-encoding will unavoidably cause some additional loss. The best thing you can achieve is minimizing the additional loss down to the point where it is barely visible.
Anyway, I agree that with x264 he should be able to retain an acceptable quality at a lower bitrate than the original H.264 file was. But 1/5 is a bit optimistic ;)
That's true that you can't increase quality. But there are many avisynth tool designed to increase preceived quality. Judging that the video's from a digital camera, it is usually pretty bad quality. With some degraining and color saturation boost, the preceived quality will increase.
1/5 is actually a very safe estimate. If you have a digital camera, you'll know they use MJPEG or something, and create ridiculously large video files with terrible quality. Once I had to videotape my GPS's problem to TomTom to explain it, and after using some MVDegrain and compressing it to 1/10 of the original size, I was truly shocked of how much better it looks, literately jaw dropping. The original video is VERY grainy, and after degraining it looks so much better.
LoRd_MuldeR
8th April 2009, 12:17
That's true that you can't increase quality. But there are many avisynth tool designed to increase preceived quality. Judging that the video's from a digital camera, it is usually pretty bad quality. With some degraining and color saturation boost, the preceived quality will increase.
Okay. But this is about post-processing of the video, not about encoding. The OP was asking about re-encoding.
Also we can only guess whether his clip would benefit from post-processing, as we didn't see it yet...
1/5 is actually a very safe estimate. If you have a digital camera, you'll know they use MJPEG or something, and create ridiculously large video files with terrible quality.
If I understand correctly, his video already is in the H.264 format, not M-JPEG or something "ridiculous".
When converting from MJPEG to H.264 you can save A LOT of bitrate indeed :)
TazmanianD
8th April 2009, 17:33
But this is about post-processing of the video, not about encoding. The OP was asking about re-encoding.
That's right. Perhaps re-encode isn't the right wording although I'm not sure what else to call it. But it seems to me that some post-processing could optimize the stream to make a smaller file without changing the bits of the image that were included or thrown out from the original encoding (like replacing some of the I-frames as I mentioned).
The video quality isn't too bad. It's full 1280x720@30fps encoded by the camera as H.264, not MJPEG and it records at a bitrate of about 22Mbps although probably not very efficiently since a camera probably is weak on processing power.
I suppose doing a full encode wouldn't hurt the quality too much and I could probably improve the quality as the other posters mentioned by running it through some filters to clean it up (which would obviously require a complete re-encoding).
akupenguin
8th April 2009, 18:30
Perhaps re-encode isn't the right wording although I'm not sure what else to call it. But it seems to me that some post-processing could optimize the stream to make a smaller file without changing the bits of the image that were included or thrown out from the original encoding (like replacing some of the I-frames as I mentioned).
There are no decisions that can be changed without affecting the decoded pixels. You can't losslessly replace an I-frame with a P-frame, because they use different prediction algorithms, and any lossy quantization is too coarse to exactly code the difference between the two predictions.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.