17

I need to encode a short video in a format that can be played with windows media player on windows xp without installing any additional codecs. For the recoding process I'm using ffmpeg.

I've already tried the msmpeg4v2 codec but the quality is horrible (compared to the original video you see large "blocks") so I'm looking for other codecs which work out of the box and have at least "ok" quality.

Since comments indicated that it might not be the codec but a bitrate issue, here's the command I used:

ffmpeg -i x.flv -vcodec msmpeg4v2 -acodec adpcm_ima_wav x.avi

Output:

Input #0, flv, from 'x.flv':
  Metadata:
    moovPosition    : 39337765
    avcprofile      : 100
    avclevel        : 30
    aacaot          : 2
    videoframerate  : 25
    audiochannels   : 2
  Duration: 00:06:19.52, start: 0.000000, bitrate: 836 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 702x396 [SAR 2596:3679 DAR 354:283], 25 tbr, 1k tbn, 50 tbc
    Stream #0:1: Audio: aac, 48000 Hz, stereo, s16
w:702 h:396 pixfmt:yuv420p tb:1/1000000 sar:2596/3679 sws_param:
Output #0, avi, to 'x.avi':
  Metadata:
    moovPosition    : 39337765
    avcprofile      : 100
    avclevel        : 30
    aacaot          : 2
    videoframerate  : 25
    audiochannels   : 2
    ISFT            : Lavf53.32.100
    Stream #0:0: Video: msmpeg4v2 (MP42 / 0x3234504D), yuv420p, 702x396 [SAR 2596:3679 DAR 354:283], q=2-31, 200 kb/s, 25 tbn, 25 tbc
    Stream #0:1: Audio: adpcm_ima_wav ([17][0][0][0] / 0x0011), 48000 Hz, stereo, s16, 384 kb/s
Stream mapping:
  Stream #0:0 -> #0:0 (h264 -> msmpeg4v2)
  Stream #0:1 -> #0:1 (aac -> adpcm_ima_wav)
Press [q] to stop, [?] for help
frame= 9485 fps=436 q=31.0 Lsize=   31197kB time=00:06:19.48 bitrate= 673.5kbits/s
video:12628kB audio:17913kB global headers:0kB muxing overhead 2.149820%
7
  • 3
    Maybe the problem is your bitrate, not your codec. The preferred codec for Windows systems is, most likely, some sort of WMV. Jun 12, 2012 at 19:19
  • See my answer there for a link to the official Microsoft FAQ. But essentially, you're stuck with Windows Media Video – which FFmpeg won't produce. So either that or the ones you've tried. As @Oliver already said, try a higher bit rate or quality setting. I assume it just uses the default one.
    – slhck
    Jun 12, 2012 at 19:21
  • The benefit of the MPEG codec is not size, but rather the fact that it is not a container like an AVI, and it is a stream based file that can be recorded via a hardware encoder, used on DVD media for stand-alone players, and it can be easily edited. So, to be clear, what you are asking about is a movie format you can encode using FFMPEG that will produce a size you are comfortable with, and will work with Windows Media Player without any additional downloads. Correct?
    – Bon Gart
    Jun 12, 2012 at 19:22
  • Yes. WMV is fine, too. ther I get the same quality - so maybe there is indeed something wrong with the bitrate. Jun 12, 2012 at 19:23

4 Answers 4

12

Since you don't specify anything else, your video stream is set to use q=2-31, 200 kb/s. It results in 673.5kbits average, which is not a lot, at least not for non-h.264 codecs.

Try forcing

  • a certain bitrate with -b:v 1000K for example. With older FFmpeg versions, you can only use -b.
  • a fixed quality level with -qscale 2 for example. Here the value can range from 1 to 31. Sane values for qscale are in the range from 2 to 5 or so. Just try and see what achieves the best result.

The codecs that are really supported on Windows by default are these:

There are hundreds of audio and video codecs in use today. Some have been created by Microsoft, but the vast majority of codecs have been created by other companies, organizations, or individuals. By default, the Windows operating system and the Player include a number of the most popular codecs, such as Windows Media Audio, Windows Media Video, and MP3.

Also see Multimedia file types that Windows Media Player supports for more information.

With FFmpeg, you can try mpeg1video (MPEG-1) or mpeg2video (MPEG-2), or msmpeg4 (MPEG-4 Part II), but I'm not sure if the latter is even universally supported. If you want to play it safe, you're forced to use MPEG-1 or MPEG-2.

3
  • yeah... that was quite a low bitrate for an mpeg file.
    – Bon Gart
    Jun 12, 2012 at 19:35
  • Heh. I have to say, we're really blessed with h.264 these days.
    – slhck
    Jun 12, 2012 at 19:36
  • expecially considering you are looking at 4k to 5k for 2 good hours on a DVD (You can go higher of course, but that always leaves me nice headroom on a disc for including an AVI file and images and such)
    – Bon Gart
    Jun 12, 2012 at 19:37
8

I had a similar issue with an aac/h264 .mp4 file which originally played fine in Windows Media Player (Windows 7). After I edited in VirtualDub and saved in .avi format, and then converted back to aac/h264 .mp4 using ffmpeg defaults, it would no longer play in Windows Media Player.

Using MediaInfo to compare the original and final files, I noticed a different encoding profile had been used, and different chroma subsampling settings (4:2:0, final 4:4:4). By re-encoding it with ffmpeg using the following option WMP was able to play the file correctly:

ffmpeg  -i edited.avi -pix_fmt yuv420p fixed.mp4
2
  • 1
    See trac.ffmpeg.org/wiki/Encode/H.264#Encodingfordumbplayers which mentions using -pix_fmt yuv420p and supports this idea.
    – User
    Sep 29, 2014 at 2:49
  • I just tested this on Windows 10. Just by adding -pix_fmt yuv420p I was able to open the mp4 in Microsoft applications (both the built-in player and the Movie Maker).
    – Nux
    Jan 27, 2019 at 10:53
2

The FFMPEG wiki recommends the following:

ffmpeg -r 30 -i foo.flv -codec:v mpeg4 -flags:v +qscale -global_quality:v 0 -codec:a libmp3lame foo.avi
1
0

Since both codecs are already supported by the AVI container you could just do

ffmpeg -i x.flv -vcodec copy -acodec copy x.avi

that's assuming your XP supports h.264, otherwise I'd go with a wmv file, same quantizer, and let ffmpeg fill in the codecs. This should give you almost identical quality as the original:

ffmpeg -i x.flv -sameq x.wmv
2
  • 2
    I somehow doubt plain XP supports h.264 Jun 13, 2012 at 16:08
  • 2
    -sameq should not be used to convert formats that do not share a similar quantizer scale. This option does not mean "same quality" as the documentation used to imply. Also, H.264 in AVI is not recommended (although lossless H.264 [no b-frames] should be fine).
    – llogan
    Jun 13, 2012 at 17:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .