How do I tell ffmpeg to transcode to a video codec supported by Windows Media player?

You can't, since ffmpeg on its own does not know which codecs are installed on your system and accessible for Windows Media Player. This is because ffmpeg uses its own libavcodec and libavformat libraries to encode and decode. So a video generated by ffmpeg must not necessarily play in Windows Media Player..


Solution 1: Install additional codecs

You may need to install a DirectShow decoder for this video format in order to play this file.

This is what you eventually have to do since Windows does not ship with every possible codec. In fact, Windows versions up until 7 ship with almost no additional codecs at all, requiring the user to install a codec pack like K-Lite or CCCP. However, you can't assume that every PC has those installed, and you might want to ship your videos with a media player like VLC, which provides its own codecs and does not depend on Windows

Installing additional multimedia codecs is something you should probably do on every fresh Windows machine though.


Solution 2: Convert to a codec WMP plays

According to the Information about the Multimedia file types that Windows Media Player supports, there are some formats natively supported, but they aren't too specific about that. If you want to be on the safe side, you should probably convert into Windows Media Video (wmv). For everything else, well, here's what Microsoft says:

Audio content or video content that is compressed with a wide variety of codecs can be stored in an .avi file and played in Windows Media Player, if the appropriate codecs are installed on the computer. Video codecs that are frequently used in .avi files include the following codecs [...]

ffmpeg's FAQ is a bit more specific. They say:

Which codecs are supported by Windows?

The following list of video codecs should work on most Windows systems:

  • msmpeg4v2, .avi/.asf
  • msmpeg4, .asf only
  • wmv1, .asf only
  • wmv2 .asf only
  • mpeg4, Only if you have some MPEG-4 codec like ffdshow or Xvid installed.
  • mpeg1video, .mpg only

Note, ASF files often have .wmv or .wma extensions in Windows. It should also be mentioned that Microsoft claims a patent on the ASF format, and may sue or threaten users who create ASF files with non-Microsoft software. It is strongly advised to avoid ASF where possible.

The following list of audio codecs should work on most Windows systems:

  • adpcm_ima_wav
  • adpcm_ms
  • pcm_s16le, always
  • libmp3lame, If some MP3 codec like LAME is installed.

So when you convert, you can specify the codec you want to use by using the -vcodec and -acodec options for video and audio respectively.

For example:

ffmpeg -i input.mp4 -vcodec msmpeg4v2 -acodec pcm_s16le output.avi

Note that this is using uncompressed audio, since you can't be sure about which audio codec will be supported by Windows. If you're lucky, you can try MP3 (and it should work with most new machines), and use the libmp3lame option.


Try this

C:\>ffmpeg -i yourvideofile.xyz -acodec mp2 -vcodec mpeg1video h.mpg

then play the output file, h.mpg in WMP, hopefully will work!

That's converting it to an MPEG container format, with audio codec of MP2, and video codec of MPEG1.

That combination should be supported by WMP.

No reason to mix up those 3 things. And you can download mediainfo to find out that kind of info from any video file. The CLI version of mediainfo is very clear
http://mediainfo.sourceforge.net/en/Download/Windows