4

I'd like to use FFmpeg on the Mac Terminal command line to convert a .WMV file. I'm familiar with the syntax:

ffmpeg -i /path/OriginalMovieFile.wmv /path/NewMovieFile.???

However, my recent attempt to convert a 38 MB .WMV file to .MP4 resulted in an 800 MB file that wouldn't play. Perhaps there is a mistake in my syntax above. Or maybe I need to install a special package for handling .WMV.

How can I convert .WMV files using FFmpeg from the Mac Terminal command line?

  • 1
    Please include the complete console output from your command. You can add the -t option if encoding a short duration will suffice to help explain the issue. – llogan Apr 20 '15 at 17:00
1

wmv is often detected as 90k FPS by ffmpeg. (That's a placeholder value since the demuxer doesn't look into the stream right away, to see the intervals between the first few frames).

ffmpeg's default for mp4 output is CFR mode, hard-duplicating frames to bring the framerate up (to 90000FPS in this case). Even the most efficient codecs take a few bytes to code a frame that's an exact duplicate of the one before.

-vsync vfr (same as -vsync 2) on the command line should fix the problem (by letting ffmpeg not drop or duplicate any frames, but instead just use the input timestamps for the output frames). It goes after the input file but before the output file, as it's an output option.

Other than that, see https://trac.ffmpeg.org/wiki/Encode/H.264 for example for how to choose settings appropriate for what you're doing. (e.g. -preset veryslow to spend lots of CPU time for an encode-once task where the quality-per-filesize gain will benefit lots of times.)

| improve this answer | |
  • This explanation is unlikely as 1) even at level 5.2 H264 supports a max of 530M luma samples per second, so a 90K fps output will be limited to a resolution of under 102x58 and 2) I have encoded many WMVs which report a tbn and tbc of 1K (and even some 90Ks), and I have never gotten a bloated output like the OP - I don't specify a framerate as an output flag or filter. – Gyan Oct 27 '15 at 9:10
  • @Mulvya: I didn't test this for myself with ffmpeg recently, but mplayer did used to show the fps of wmv files as 90k. Actually, I think I did see something like this with mp4 output and an actual VFR mp4 input. When you encode from a wmv source, what output format do you use? ffmpeg's default for most muxers is -vsync vfr, but it was changed to -vsync cfr for mp4 as a workaround for some bug that can happen in a corner case. re: 1): This output file is probably nowhere near level 5.2, if my theory is correct. If ffmpeg / x264 tag it as such, that's a bug. – Peter Cordes Oct 27 '15 at 9:27
  • My output was typically H264 in MP4 or MOV. My point re: level was it was very unlikely that ffmpeg was trying to use a fps of 90K as output if only for the simple reason that even at the highest level of 5.2, that framerate would only allow a very low resolution, and the encode should fail at the outset, rather than dump a bloated file. – Gyan Oct 27 '15 at 11:52
  • @Mulvya: insane-framerate h.264 is still valid h.264, there just isn't a level do describe it. I think I now remember at least one other questions on here where ffmpeg used a way-too-high frame rate and made a giant file. That question had full ffmpeg output, so we could see that was actually what happened. I agree, in an ideal world, ffmpeg would be able to tell when this happened by accident and abort, without failing to do what's asked if you really did ask it to make a 90k fps CFR output file. – Peter Cordes Oct 27 '15 at 13:47
0

Both avconv and ffmpeg suffer from the poorly chosen defaults for each container and codec. Therefore you should not simply give the command in the format as you have presented, but also tell it what to do.

I use avconv, but if you are still using ffmpeg then the format is rather similar, so you should be able to follow.

You will need to specify the audio settings. In many cases you will want to copy your audio without actually reencoding. This is done via -c:a copy. For example:

avconv -i video.wmv -c:a copy (...) video.mkv

This wasn't a complete line, so don't yet try it.

You can also chose to reencode your audio, in that case rather than copy you should use the name of the codec (or for some reason often the library that does the encoding). For example, you can write:

avconv -i video.wmv -c:a libvorbis (...) video.mkv

But this will not produce good results, because we didn't give any parameters for the audio conversion. Let's just give it a quality setting, and then we will be all set with audio:

avconv -i video.wmv -c:a libvorbis -q:a 3 (...) video.mkv

Now the video. We can often just copy that one as well, but this is rarely what we want. If you want to just remux the file (meaning you want to change the format, but not codecs), then you can do:

avconv -i video.wmv -c:a copy -c:v copy video.mkv

As you see we have copied both video and audio, and we put them in the new file that is of Matroska format. This command line already will work, and you can give it a try.

You should keep in mind that not each format can take every possible codec, some of them are more picky than others.

Let's say you now want to reencode the video into something. Personally i prefer libtheora, due to the fact that it is a free codec, but you can have different preferences. I will let you decide for yourself which one you use.

So we can have something like this:

avconv -i video.wmv -c:a copy -c:v libtheora -q:v 8 video.mkv

In there i have asked avconv to copy the audio, but to reencode the video with the library libtheora and video quality of 8. The entire thing will be saved inside video.mkv, which means it's a Matroska file.

You can play around with settings, but you should very rarely use default presets. And keep in mind, that even if the file format is the same for output as for the input, avconv will reencode it by default. If you want to copy streams, you should specify it manually.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.