Archive for the ‘mplayer/mencoder’ Category

Video Tearing Fixed - Xubuntu 9.10 - Nvidia ION

Sunday, February 14th, 2010

I use mplayer as my default video player, and have always had video tearing of some sort on my main PC. Having recently updated my PC to an Asus EB1012 net-top with the Nvidia ION graphics chip I found that enabling the vdpau options with mplayer gave me tear free playback. So I set out to resolve it for other file types (e.g. mp4 / avi)

I run Xubuntu by preference and normally use the Compositor to add transparency and shadows, and the default output plugin for mplayer is xv.

1. Turn off the compositor

2. This should produce tear free playback in totem and vlc

3. Open up nvidia-settings and ensure Sync to Vblank is ticked in  X Server XVideo Settings, and Sync to VBlank and Allow Flipping is ticked in Open GL Settings

4. edit the ~/.mplayer/config file

I grabbed the config file from GeexBox, as this served as a useful template to set up profiles for various file types.

For h264 / vdpau files (mkv) that use the GPU to process

[extension.mkv]
profile-desc=”Profile for Matroska files”
profile=lang
vo=vdpau
vc=ffh264vdpau

For HD Files (mp4)

[extension.mp4]
profile-desc=”Profile for HD mp4 files”
vo=gl
vfm=ffmpeg
lavdopts=lowres=0:fast=1:skiploopfilter=all
autosync=30
cache=32768

For “normal” (avi) files

[extension.avi]
profile-desc=”Profile for deinterlacing avi files”
vo=gl
vf=pp=lb/hb/vb/dr

The default section looks like this:

[default]
vo=vdpau,xv,gl
ontop=yes
double=yes
dr=yes
framedrop=yes
cache=8192
lirc=no
alang=en
slang=en

I have to make sure I check encoded options and rename the extension accordingly, but 95% of the time, this configuration works fine for me

Here is the entire ~/.mplayer/config file:

[deinterlace]
profile-desc=”Profile for picture de-interlacing”
vf-add=pp=fd

[dvd]
profile-desc=”Profile for DVD playback”
profile=deinterlace
dvd-speed=4
cache=8192

[lang]
profile-desc=”Profile for language”
alang=en

[protocol.dvd]
profile-desc=”Profile for dvd:// streams”
profile=dvd
profile=lang

[protocol.dvdnav]
profile-desc=”Profile for dvdnav:// streams”
profile=dvd
profile=lang
nocache=yes

[protocol.cdda]
profile-desc=”Profile for cdda:// streams”
cdda=speed=2

[protocol.tv]
profile-desc=”Profile for tv:// streams”
profile=deinterlace

[extension.mkv]
profile-desc=”Profile for Matroska files”
profile=lang
vo=vdpau
vc=ffh264vdpau

[extension.mp4]
profile-desc=”Profile for HD mp4 files”
vo=gl
vfm=ffmpeg
lavdopts=lowres=0:fast=1:skiploopfilter=all
autosync=30
cache=32768

[extension.avi]
profile-desc=”Profile for deinterlacing avi files”
vo=gl
vf=pp=lb/hb/vb/dr

[default]
vo=vdpau,xv,gl
ontop=yes
double=yes
dr=yes
framedrop=yes
cache=8192
lirc=no
alang=en
slang=en

Mplayer - neat and tidy on the CLI

Wednesday, November 18th, 2009

How long have I been using mplayer? Years. Why has it never bothered me to sort this out before? Don’t know. Ageism, autism, or general grumpiness sent me off in search of a solution, and how easy was it.

Every time I have run mplayer from the cli I got three lines written out before the “action”:

mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

The very simple fix to this is to add an entry to your ~/.mplayer/config file

lirc=no

That’s it, no more extra lines. Remember to comment out “lirc=no” if you want to use a remote control, though :)

GeeXBoX playback at fullscreen on LCD TV

Sunday, August 30th, 2009

This has been an issue for me for quite a while, but I have simply overcome it by using the menu to change the aspect ratio.

It all stems from the perplexing confusion of recording dvb tv for later playback. Watching live TV on the TV, the picture fills the screen. It’s a 16:9 42″ TV (720p). When I record dvb tv using my main pc in its raw .ts state it is 720×576 (16:9). If I play this back using the GeexBox, mplayer squeezes the picture to a display of something like Cinemascope, so a change of aspect ratio to 4:3 usually sorts this out. But it got me thinking, if the original video is 16:9 why doesn’t play as such? The Pc in use to run GeexBox has an nvidia 6200 and is connected to the TV using VGA (DVI/HDMI went “pop” a while ago on the TV!).

First off, I tried all sorts of encoding options, changing the aspect ratio and resolution using mencoder. I got some success if I encoded with aspect=4/3 as an option. but this still didn’t make sense; if I had a 16:9 aspect ratio TV, why the original video didn’t fit.

This is what I did to sort things out. I have a HDD install of GeexBox so can ftp in to edit files. If you use a live cd, then you will need to edit the files before you generate a custom iso.

Boot up the GeexBox

FTP in, and make doubly sure you get into the right place

/mnt/GeexBox-partition/GEEXBOX/etc

Open up tvout in that directory and change the Aspect Ratio line to this:

TVOUT_ASPECT=”16:9″

and save.
By just making this change alone, it squeezed my display horizontally to make a 4:3 image, so more to do

Browse to /mnt/Geexbox-partition/GEEXBOX/etc/mplayer and open up mplayer.conf
In the [default] section, add the following two lines:

monitoraspect=”16:9″

aspect=”16:9″

and save. It may be worth noting that I have vo=vidix,vesa in the default section of mplayer.conf

Log out of the ftp and reboot the GeexBox. The Main Menu and background.avi should be filling the screen.

Now try playing any recorded dvb tv or video that was previously letterboxed, even though it was 16:9 ratio or 720×576 resolution. You should see it playback in full screen.

Caveats: This may not work in your setup, and you may not need to make all the adjustments to get this to work, this is what worked for me.

ts to avi using projectx and mencoder + ffmpeg

Wednesday, July 8th, 2009

I am feeling pretty pleased with myself tonight, having resolved another issue with my encoding of dvb-t streams to avi.

Having sorted out the crashing problem, I was now having a/v sync issues. This is easy enough to deal with by using the +/- keys to adjust a/v sync with mplayer, but annoying for other users.

I have solved the problem by demuxing the stream to its component video and audio parts, using Projectx, Mencoder and ffmpeg.

Projectx is a great java tool that allows you to crop and cut a dvb or mpeg stream and then output either to a ts/ps/m2p a/v stream or to demux the stream. By demuxing you end up with a video m2v file and an audio mp2 file.

It is easy enough to then encode the video using mencoder, then to use ffmpeg to encode the audio, and finally to use mencoder again to mux the video and audio encodes back together, which gives a perfect a/v sync. I put together a script that will encode all m2v/mp2 collections in a directory, so I can leave it running overnight if I have more than one encode to do. Here it is: Mencoder Batch Mux Script

I am using default mencoder libraries and encoders with a two pass approach, but will give h264 a crack later to see if I get better quality for the time and cpu cycles taken. The current script produces eminently watchable video on my 42″ LCD using GeeXBoX so I’m a happy bunny :)

If you get stuck or need help, give me a shout….

[Solved] - Mencoder Freezing Computer (my computer!) or Segmentation Faulting

Sunday, June 14th, 2009

This has been an annoyance for sometime, when encoding anything with mencoder, but specifically ts files from recorded TV. Mencoder would start off fine and then freeze the PC completely or Seg Fault, not necessarily in the same place. Other PCs I have would encode fine using the same settings.

I found the solution today on the mplayerusers email list. About 18 months ago I had overclocked my machine, up from 1.7 to 1.9 mhz and increased the FSB. Apparently mencoder doesn’t like overclocked PCs, even though the writer with the solution said it wasn’t mencoder’s fault! So I put my settings back to “Optimal” / “Auto”, and everything is now rosy in the garden, just a tad slower than before :) I can live with that!

How to remux an avi with the right audio language track using MPlayer/Mencoder

Sunday, April 26th, 2009

MPlayer and Mencoder to the rescue again!

I downloaded a movie the other night which was advertised as having both Spanish and English soundtracks. I had found films like this before, but English had always been the first audio track, so had never been a problem. On this occasion, Spanish was the first audio track. I didn’t want to have to fiddle around with Geexbox getting the right language playing, so needed to sort this out, so that English was the audio track that played. I wasn’t too bothered about dropping the Spanish soundtrack.

Four “simple” steps.

  1. Confirm the aid number of the English language track. Running the video with mplayer in verbose mode produced enough information to find this easily, as track 2
    • mplayer -v inputvideo.avi
  2. Extract the english audio track from the avifile
    • mplayer -aid 2 -dumpaudio -dumpfile englishaudio.mp3  inputvideo.avi
  3. Copy the video track out without any sound
    • mencoder -ovc copy -nosound -o soundlessvideo.avi  inputvideo.avi
  4. Stick the soundless video and the English audio track back together
    • mencoder -ovc copy soundlessvideo.avi -oac copy -audiofile englishaudio.mp3  -o newvideo.avi

No encoding or transcoding going on, just demuxing and remuxing of the right parts. Apparently the use of -nosound can cause a/v sync issues, but in this case a/v sync was fine all the way through.

Found another way too, as doing the above with ac3 sound doesn’t sync well at all. Simply re-encode the audio and output to a new file:

mencoder -ovc copy  -oac mp3lame aid 2 inputfile.avi -o outputfile.avi

or to simply grab the second audio stream without encoding

mencoder -ovc copy -oac copy aid 2 inputfile.avi -o outputfile.avi

Mplayer / Mencoder Tips

Saturday, February 14th, 2009

I love mplayer and mencoder, they just do everything I want to be able to do with video / audio. (more…)