Thursday 29 August 2019

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


The command below executed without error.


ffmpeg -i thevideo.mkv outvideo.avi

Subsequent attempts to play outvideo.avi in Windows Media player threw this error


You may need an additional video decoder to play this file.

This file contains a track in an unknown format (code "ARGB") format. You may need to
install a DirectShow decoder for this video format in order to play this file.

Error detail provided by Windows Media player indicates the mpg2 codec is required to play the video. How do I tell ffmpeg to transcode to a video codec supported by Windows Media player?



Answer



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.


No comments:

Post a Comment

How can I VLOOKUP in multiple Excel documents?

I am trying to VLOOKUP reference data with around 400 seperate Excel files. Is it possible to do this in a quick way rather than doing it m...