Menu
Text Links
Search
Calendar
Solution: Creating an mpeg with mencoder that plays on Windows Media Player
rechosen | 24 May, 2007 15:27
This has been tested with Windows Media Player 6.4 and 10. If you can confirm that it also works on other versions (or if it doesn't work), please leave a comment.
A simple example
Let's have a look at a rather simple mencoder command that should create a WMP-compatible MPEG file:
[rechosen@localhost ~]$ mencoder <input> -oac lavc -ovc lavc -lavcopts acodec=mp2:vcodec=mpeg2video:mbd=1:vbitrate=1800 -of mpeg -o <outputfile>
Replace "<input>" with the video source (for example a file or a DVD scene) and "<outputfile>" with the file you want the output to be written to (e.g. "samplemovie.mpg" or "dvdbackup.mpeg"). You can also replace the value after "vbitrate=" with a higher or lower bitrate, depending on the desired quality of the outputfile (you could also leave it away entirely, but it will then default to 800, which is quite low and therefore pretty much only suitable for very low resolution movies).
Note that the above example will try to encode the movie at the same resolution and fps as the source. However, this does not always work correctly and also isn't always what you want. Furthermore, the above example doesn't use two-pass encoding. Two-pass encoding is useful because it results in a higher quality outputfile with about the same size (it needs to read the source twice, though).
A more feature-rich example
The next example features rescaling (adapting the resolution), specifies a framerate for the outputfile and encodes in two passes.
[rechosen@localhost ~]$ for i in {1,2}; do mencoder <input> -oac lavc -ovc lavc -lavcopts acodec=mp2:vcodec=mpeg2video:mbd=1:vpass=$i:vbitrate=1800 -of mpeg -ofps 25 -vf scale=640:480 -o <outputfile>; done
Replace "<input>" with any source that can be read twice (a file or a DVD scene) and "<outputfile>" with the file you want the encoded data to be written to. You can alter the values after "-ofps=" and "-vf scale=" to change the framerate and the resolution of the outputfile, respectively (and of course you can alter the vbitrate again, too).
One more handy trick: you can set only the width of the encoded video and let mencoder determine the height, keeping the right aspect ratio:
[rechosen@localhost ~]$ for i in {1,2}; do mencoder <input> -oac lavc -ovc lavc -lavcopts acodec=mp2:vcodec=mpeg2video:mbd=1:vpass=$i:vbitrate=1800 -of mpeg -ofps 25 -vf scale -zoom -xy 640 -o <outputfile>; done
Again, replace "<input>" with any source that can be read twice (a file or a DVD scene) and "<outputfile>" with the file you want the encoded data to be written to. You can alter the value after "-ofps=" again to change the framerate of the outputted data, and after "-zoom -xy " is the value to change if you want a different width (note that values less than or equal to 8 will be interpreted as scaling factors, not as the width of the outputted video).
Disclaimer:
I do not guarantee that this works as told. All information in this article is provided as-is, without any warranty.
That was the legal stuff =). If it didn't work for you, or if I'm doing something that's considered bad practice, please leave a comment! I'll be glad to try to help you or to correct what I did wrong.
Comments
Add comment
Recently...
- Solution: Converting flac to mp3 advanced (supports drag 'n drop)
- Tutorial: Conditions in bash scripting (if statements)
- Linux Tutorial Blog is no longer frozen!
- Solution: Getting a Gravis GamePad Pro to work on Linux
- Linuxtutorialblog.com is now officially frozen!
- Solution: Preventing damage after a system lockup
- Solution: Creating an mpeg with mencoder that plays on Windows Media Player
- Cropping multiple images the same way (short tutorial)
- Solution: Converting flac to mp3
- Tutorial: Disabling unused daemons to speed up your boot sequence
Trackbacks (0)