issues for time-lapse video encoding
Hi Folks, I'm creating and processing time-lapse movies of outdoor scenes using mencoder (or ffmpeg) to do the capture from a webcam, and then mencoder to process into a playable video. I'm using an Ubuntu server setup, and the initial video comes in from a USB webcam in video4linux2 format. I'm capturing 1280x1024 frames at 0.1 frame per second, i.e. 6 frames per minute. The intended playback is 30 fps. I have two questions: 1) Since I want to use two-pass processing of the captured video, I need to do the initial capture with as little degredation as possible. I'd like e.g. 3000 frames to go into about 1gB in the oringial captured video. Is there a recommended codec/setting for this? I've tried rawvideo and ffv1, but these generate too much data. So I need some compression. Given that the size of the compressed video at this point isn't a big issue, which codec will degrade the images the least or have the simplest behavior/results? BTW, I'm currently using the mjpeg codec, but there's no control that I can see (ffmpeg) for the compression that it's doing.... 2) I want to do some filtering of the resulting video. In particular, it would be nice to remove all the objects, e.g. birds, that appear in only a single frame. I can imagine that some sort of median filter would do the job (e.g. median for each pixel across 7 frames). What should I be looking at for this kind of filtering? It's a kind of denoising, but the extent of the noisy object can be quite large, but always only for a single frame. Relatedly, is there a codec that would be best suited to the time-lapse material? I've toyed with wmv2, mpeg4, and x264 -- but experimenting with just the set of controls that I've seen mentioned in FAQs is daunting, and I haven't yet seen anything that specifically addresses the nature of time-lapse video of outdoor scenes. So, I'd also appreciate any pointers to information about the encoding issues for time-lapse video. Thanks in advance, -Hugh
On Mon, 18 May 2009 18:12:51 -0400 Hugh Secker-Walker <hsw@hodain.net> wrote:
which codec will degrade the images the least or have the simplest behavior/results?
Whatever one you're going to be using later. Honestly though, I don't see why you don't fully compress the video on the fly. With such low frame-rates, you should have ample CPU power.
BTW, I'm currently using the mjpeg codec, but there's no control that I can see (ffmpeg) for the compression that it's doing....
vqscale
it would be nice to remove all the objects, e.g. birds, that appear in only a single frame.
hqdn3d with a very, very high temporal value might work for you. Or perhaps tinterlace + pp=lb + tfields. Probably not good enough though. You probably need to find a more specialized tool for the job.
Relatedly, is there a codec that would be best suited to the time-lapse material?
Nope. The longer the interval between frames, the less effeciently it's possible to temporally compress the video, and the closer you come to getting no better compression than seperate images. Physics is against you... With some very strong denoising, or very high quantitizer (low bitrate/low quality), you might get be able to get some decent compression, but don't count on it. -- Don't trust me! I'm wrong!
Thanks for the quick feedback.
which codec will degrade the images the least or have the simplest behavior/results?
Whatever one you're going to be using later.
So far, x264 gives the highest quality for a given final bitrate.
Honestly though, I don't see why you don't fully compress the video on the fly. With such low frame-rates, you should have ample CPU power.
Yes, CPU usage is almost nil during the initial capture. My newbie understanding is that the encoder can do a better job of allocating bits to frames if it gets to see the stats from the first pass before it does its heavy-duty compression work on the second pass. So, I don't see how to "fully compress" on the fly with a single pass. Is there some trick to this?
BTW, I'm currently using the mjpeg codec, but there's no control that I can see (ffmpeg) for the compression that it's doing....
vqscale
Ah, that's from mencoder. So far I've not been able to get mencoder to tell the USB camera to run in 1280x1024, so I've been using ffmpeg for the initial capture. Nonetheless, I think you are suggesting to run the first pass with a constant quality, conservatively high bitrate. Then let the second pass compress more agressively while being more adaptive.
it would be nice to remove all the objects, e.g. birds, that appear in only a single frame.
hqdn3d with a very, very high temporal value might work for you. Or perhaps tinterlace + pp=lb + tfields. Probably not good enough though. You probably need to find a more specialized tool for the job.
Thanks for the starting pointers. -Hugh
On Tue, 19 May 2009 09:24:25 -0400 Hugh Secker-Walker <hsw@hodain.net> wrote:
Yes, CPU usage is almost nil during the initial capture. My newbie understanding is that the encoder can do a better job of allocating bits to frames if it gets to see the stats from the first pass before it does its heavy-duty compression work on the second pass.
You'll probably lose more in the two-step process than you'll gain by doing two-pass encoding. With x264, CRF will work nearly as well. With lavc codecs, single-pass works pretty well with vratetol or vqcomp/vqblur set appropriately. vqscale doesn't do too badly, either.
vqscale
Ah, that's from mencoder.
-qscale then. -- Don't trust me! I'm wrong!
On Monday 18 May 2009, Hugh Secker-Walker wrote:
2) I want to do some filtering of the resulting video. In particular, it would be nice to remove all the objects, e.g. birds, that appear in only a single frame. I can imagine that some sort of median filter would do the job (e.g. median for each pixel across 7 frames). What should I be looking at for this kind of filtering? It's a kind of denoising, but the extent of the noisy object can be quite large, but always only for a single frame.
Some years ago, I saw a program which could do exactly that. Unfortunately I can't remember what it was called or where on the interwebs I saw it. IIRC it was some sort of acedemic project, the software being free. I honestly can't even remeber if it was *nix or Windows based but suspect it was *nix based. The object of the project was to take multiple substantively identical images and remove the diferences, particularly for photographers wanting to take photos and remove the people, eg take half a dozen trpid mounted shots of a building, run them through the programme and the moving people would "magically" disappear as they are not in all of the images. Another example given was photos taken from a bridge over a road. He took multiple shots, processed them through his program and ended up with a photo of an empty road. I would dearly love to find this program again, especially if it is *nix based, not Windows based. -- Dave
DaveG wrote:
On Monday 18 May 2009, Hugh Secker-Walker wrote:
2) I want to do some filtering of the resulting video. In particular, it would be nice to remove all the objects, e.g. birds, that appear in only a single frame. I can imagine that some sort of median filter would do the job (e.g. median for each pixel across 7 frames). What should I be looking at for this kind of filtering? It's a kind of denoising, but the extent of the noisy object can be quite large, but always only for a single frame.
Some years ago, I saw a program which could do exactly that. Unfortunately I can't remember what it was called or where on the interwebs I saw it.
IIRC it was some sort of acedemic project, the software being free. I honestly can't even remeber if it was *nix or Windows based but suspect it was *nix based.
The object of the project was to take multiple substantively identical images and remove the diferences, particularly for photographers wanting to take photos and remove the people, eg take half a dozen trpid mounted shots of a building, run them through the programme and the moving people would "magically" disappear as they are not in all of the images.
Another example given was photos taken from a bridge over a road. He took multiple shots, processed them through his program and ended up with a photo of an empty road.
I would dearly love to find this program again, especially if it is *nix based, not Windows based.
dvbcut has a feature of showing the difference between 2 frames, maybe for a coder there is something to learn/use from.
DaveG wrote:
On Monday 18 May 2009, Hugh Secker-Walker wrote:
2) I want to do some filtering of the resulting video. In particular, it would be nice to remove all the objects, e.g. birds, that appear in only a single frame. I can imagine that some sort of median filter would do the job (e.g. median for each pixel across 7 frames). What should I be looking at for this kind of filtering? It's a kind of denoising, but the extent of the noisy object can be quite large, but always only for a single frame.
Some years ago, I saw a program which could do exactly that. Unfortunately I can't remember what it was called or where on the interwebs I saw it.
IIRC it was some sort of acedemic project, the software being free. I honestly can't even remeber if it was *nix or Windows based but suspect it was *nix based.
The object of the project was to take multiple substantively identical images and remove the diferences, particularly for photographers wanting to take photos and remove the people, eg take half a dozen trpid mounted shots of a building, run them through the programme and the moving people would "magically" disappear as they are not in all of the images.
Another example given was photos taken from a bridge over a road. He took multiple shots, processed them through his program and ended up with a photo of an empty road.
I would dearly love to find this program again, especially if it is *nix based, not Windows based.
dvbcut has a feature of showing the difference between 2 frames, maybe for a coder there is something to learn/use from.
participants (4)
-
belcampo -
DaveG -
Hugh Secker-Walker -
RC