[FFmpeg-devel] Scaling of flashsv stream
Benjamin Larsson
banan
Sat Nov 7 12:20:34 CET 2009
Brian Candler wrote:
> I have been using ffmpeg to process screencasts created by vnc2flv using the
> flashsv codec, and I've found a tweak that allows them to compress much
> better after scaling.
>
> My test 9.5 minute screencast has a frame size of 992x608. After a null pass
> through ffmpeg, the video portion is 10543K:
>
> ./ffmpeg -i in.flv -vcodec flashsv -acodec copy -r 12 -g 120 out.flv
>
> If I scale this down by a factor of 2:1, the video still accounts for 9048K,
> which is hardly any smaller at all.
>
> ./ffmpeg -i in.flv -vcodec flashsv -acodec copy -r 12 -g 120 -s 496x304 out.flv
>
> Poking around the codec, I discover that the scaled blocks don't zlib
> compress as well, presumably because ffmpeg is doing such a good job of
> anti-aliasing that a much wider colour palette is being used.
>
> So I tried quantising the palette to 16x16x16 with the following patch, and
> after this the video is only 4086K.
>
> --- libavcodec/flashsvenc.c.orig 2009-11-06 22:13:00.000000000 +0000
> +++ libavcodec/flashsvenc.c 2009-11-06 22:23:27.000000000 +0000
> @@ -88,7 +88,7 @@
> npfptr = pfptr+(i*stride)+dy*3;
> for (j=0 ; j<w*3 ; j++) {
> diff |=npfptr[j]^nsptr[j];
> - dptr[j] = nsptr[j];
> + dptr[j] = ((nsptr[j] + 8)/ 17) * 17;
> }
> dptr += w*3;
> }
>
> The screen quality is hardly any different - if anything, the text is
> subjectively a little sharper.
>
> Is there an existing colour quantisation facility in ffmpeg that I could
> have used to do this? If so please accept my apologies, and I will move over
> to ffmpeg-user :-)
>
> Otherwise, do you think this would be worth adding? How would it be enabled?
> Does it belong in the flashsv encoder, or is there somewhere more
> appropriate to plug it in earlier in the chain?
>
> Thanks,
>
> Brian.
We have the upcoming avfilter framework. I think this feature would suit
there. As the flashsv format is lossless I think the only job the
encoder should perform is to compress as well as it can. Thus any patch
like this would be rejected. But a colorquant filter would be nice to have.
MvH
Benjamin Larsson
More information about the ffmpeg-devel
mailing list