View Full Version : [FFmpeg] Encode to wmv
Klagar
9th February 2011, 17:37
Hi !
I've been trying to encode a movie from .mov to .wmv using FFmpeg. But I keep hitting a wall, as the output file will always yield a video of mediocre quality, unless I throw in soem absurd bitrate, and even then it's not excellent.
The starting MOV file is very-high definition (and at 12Mbps), and I want to encode it to size 1920x1080 and keep most of the quality. Here is the line I'm currently using :
-r 29.97 -vcodec wmv2 -s 1920x1080 -aspect 16:9 -b 14000k -cmp +chroma -g 15 -me_range 32 -qcomp 0 -qdiff 4 -qmin 1 -subcmp 2 -subq 8 -trellis 0 (+audio settings)
What bugs me is that, first, I encode at a full 2Mbps higher than the original, and pixels and artefacts appear that weren't there before. However, I can encode the exact same video in libx264 mp4, at no more than 4000 or 6000 kbps, and I come with some very good results. Now, I know (or think I do) that FFmpeg has come to be more and more performant in h264 encoding, and maybe less focused with other codecs. But that much ??? Furthermore, I don't have that problem when I encode to Xvid.
So is the wmv codec that much of a crap, or am I doing something wrong ?
Note : if your solution would imply using another software or forsaking wmv's altogether, I can unfortunately not consider these as viable options, or at least not at the moment. Such advices might be useful in years to come, but then again, who knows if I'll still be there in a few years ! ;-)
Thanks in advance for your advice !
Regards.
Selur
9th February 2011, 18:12
So is the wmv codec that much of a crap, or am I doing something wrong ?
it's wmv2, so yes compared to VC-1 and H.264 it isn't really good,..
Midzuki
9th February 2011, 18:18
WMV2 compresses worse than MPEG-4 ASP, WMV3, and H264.
According to my "rough" calculations, 1080p w/ WMV2 requires 12Mbps for average bitrate, and 24Mbps for maximum bitrate :-/
Klagar
9th February 2011, 18:20
Would there be another codec that could give WMV files which would be readable in all major players without having to add external codecs ? Or am I doomed to produce WMV's with ridiculously high bitrates ? :-S
The thing is, with earlier versions of FFmpeg, we were quite capable to produce average WMV's with similar quality (compared to Xvid, at the very least) for similar file sizes... I don't understand why with the later versions that would be any different...
I wouldn't care if I had to encode at 2-3 thousands Kbps more than the usual mp4/avi, but a full 6,000 and even there I feel I will have to climb yet a little more ? That seems exagerated...
nm
9th February 2011, 19:24
The thing is, with earlier versions of FFmpeg, we were quite capable to produce average WMV's with similar quality (compared to Xvid, at the very least) for similar file sizes... I don't understand why with the later versions that would be any different...
Regressions are always possible. Bisect a version that still works and then make a bug report. I could also help finding the change that ruined it if you can point me to a good version.
Reimar
10th February 2011, 10:57
Hi !
-r 29.97 -vcodec wmv2 -s 1920x1080 -aspect 16:9 -b 14000k -cmp +chroma -g 15 -me_range 32 -qcomp 0 -qdiff 4 -qmin 1 -subcmp 2 -subq 8 -trellis 0 (+audio settings)
Do you actually know what your settings do? You force a I-frame every 15 frames (i.e. every 0.5 seconds), that will hurt compression _massively_.
I don't know what most of the other options do, but since they are not default there's a good chance they break encoding almost as badly.
Also, ffmpeg rate-control isn't so great, so you should either run two-pass or use -vqscale instead of -b.
Klagar
10th February 2011, 15:30
Do you actually know what your settings do?
Pretty much.
I put a low -g because otherwise the video becomes un-scrollable (or un-seekable, whatever)... I played with the parameter some, but I seem to remember it didn't change quality nor filesize that much... Though if you point it out, I'll run one or two more tests, just to make sure.
As for the other parameters, I of course tried the most simplest line, something like -r 29.97 -vcodec wmv2 -s 1920x1080 -aspect 16:9 -b 14000k (+audio settings). Result was awful. So far I think there's not a parameter I could remove without impairing quality or compression. Well then again, I might be wrong, otherwise I wouldn't be here ! ;-)
qscale is something to consider. Do you have any advice on the value you think I could give it for the video size I need ? Is it dependent on another parameter/setting to run correctly ?
Thanks for your advice, I'll keep you posted for my results. Might help someone else out there !
Regressions are always possible.
You know, maybe the difference isn't so big after all. I still find it significant when dealing with very hi-resolution videos (which FFmpeg obviously does better with libx264), but for standard ones (960x544 and under), wmv shows pretty much the same capabilities as before. So mea culpa, I guess I was comparing green apples with red apples : not so different, but not the same either. Probably no earlier version was that better at dealing with such high settings.
However, something funny... When I encode in wmv, and then MediaInfo the output file, it tells me it was encoded with wmv2 codec. Nothing there. But some files I found were actually encoded (or so it seems) in wmv3. Thoughts on this ? 'Cause FFmpeg looks like it has wmv3 implemented only as a decoder. Do I have a bad build of it ? Is there another codec that would give that result ? Or is it my decoder analyzing the file wrong ? I would guess that wmv3 is arguably better than wmv2, no ? So maybe part of my solution would be finding how to encode in wmv3 ?
Thanks as always !!!
Klagar
10th February 2011, 15:39
So I tried qscale. Very interesting, I didn't suspect such a hard switch existed.
However, I had to discard it, since the line should serve to encode a wide variety of videos... Though it did inspire me to use a very low qmax instead. Coupled with a high enough bitrate, it ensured a better quality for a fairly comparable bitrate.
And putting -g to 30 did make me win a little filesize at a pretty small seekability cost. It's worth the deal.
I guess I could consider the issue as resolved. Results are pretty satisfying, although they don't match the expectations I had at the start. Maybe in the future some new feature will help a little bit. Or in the worst case, maybe someday I'll become badass enough of a programmer to help develop a thing or two... ;-)
So thanks, if anyone has another sudden flash of insight, I gladly take it... But otherwise I now have acceptable results.
Have a good one !
nm
10th February 2011, 15:47
qscale is something to consider. Do you have any advice on the value you think I could give it for the video size I need ?
Try -qscale 4.
You know, maybe the difference isn't so big after all. I still find it significant when dealing with very hi-resolution videos (which FFmpeg obviously does better with libx264)
x264 is faster at same quality if you have a multi-core CPU.
However, something funny... When I encode in wmv, and then MediaInfo the output file, it tells me it was encoded with wmv2 codec. Nothing there. But some files I found were actually encoded (or so it seems) in wmv3. Thoughts on this ?
Most likely they weren't encoded with FFmpeg then.
I would guess that wmv3 is arguably better than wmv2, no ? So maybe part of my solution would be finding how to encode in wmv3 ?
Yes, with Microsoft's or MainConcept's encoder.
But how many players are there that support WMV2/3 and don't support MPEG-4 ASP or H.264?
benwaggoner
11th February 2011, 19:55
You really should be using WMV3 (aka "WMV 9" and VC-1). VC-1 Main Profile will play on everything from XPSP2 on up, and is massively more efficient than WMV2 (aka "WMV 8"), which is more than a decade old now. And Windows systems have had GPU accelerated playback since 2004 IIRC. Lots of supports in other kinds of devices, which likely don't support WMV2 as it wasn't standardized by SMPTE like VC-1 was.
Lots of tools can make good VC-1. Expression Encoder 4 has a free version that supports the high quality VC-1 Encoder SDK. That would give you a lot faster and higher quality encoding, and faster decoding most of the time as well.
There's also Flip4Mac and Episode for Mac users.
Blue_MiSfit
14th February 2011, 06:54
Another vote for using Expression Encoder 4. Great tool!!!
Derek
vBulletin® v3.8.11, Copyright ©2000-2025, vBulletin Solutions Inc.