Showing posts with label video. Show all posts
Showing posts with label video. Show all posts

Sunday, January 9, 2011

XBMC and NVidia's TwinView

I was looking for a decent media center - mostly to watch movies with an overhead projector connected to a PC. The PC is running Linux and I would like to be able to select a movie, change the volume, pause etc with my Medion (read: cheap, RF, USB connected) remote. One day I stumbled upon XBMC. It turned out to be a decent piece of software. Configuring the remote was easy. But...

I must mention here that my display setup uses the NVidia's TwinView, which serves me well. My main LCD monitor is connected through a D-Sub while the beamer via HDMI. They form a dual-screen setup with the beamer on the right of the LCD.

But there is always a catch... Actually two of them.
  1. XBMC's fullscreen ignores TwinView, so it spans both displays, or the other display is turned off. 
  2. There is video tearing visible while XBMC is running on the beamber, there is no tearing if it runs on the LCD.
The first issue can be fixed by making XBMC use so-called windowed mode. It appears as a window then. Having a window and using wmctrl it is possible to make it look like fullscreen.
The second issue regard configuring the NVdia in a proper way which makes OpenGL sync to the specified display instead of the first one. It can be achieved by exporting two environment variables __GL_SYNC_TO_VBLANK=1 and __GL_SYNC_DISPLAY=name_of_the_display_to_sync_to.

So here comes my magical bash script which launches the XBMC with a proper syncing enabled and shifts it to the beamer making the window fullscreen (mind that the beamer is on the right of the LCD, and the LCD is 1280x1024).

Enjoy.
#!/bin/bash

move_and_fullscreen(){
  NAME='XBMC Media Center'

  while [ -z "`wmctrl -l | grep \"$NAME\"`" ]
  do
      sleep 1
  done

  wmctrl -r "$NAME" -e '0,1280,-1,-1,-1'
  wmctrl -r "$NAME" -b toggle,fullscreen
}

move_and_fullscreen &
__GL_SYNC_TO_VBLANK=1 __GL_SYNC_DISPLAY_DEVICE=DFP-0 SDL_VIDEO_ALLOW_SCREENSAVER=0 exec xbmc

Update: As of XBMC 10.1 I had to add SDL_VIDEO_ALLOW_SCREENSAVER=0 to disable screensaver while running XBMC. The above approach uses the windowed mode of XBMC which enables system screensaver now - it kicks in while watching movies :( (the screensaver is disabled in the fullscreen mode only).

Monday, August 30, 2010

Home DVD, non interlaced

This nice tiny DVD camera of mine captures footage which turns to be interlaced... While it is nice while watching on a TV, it turns to be at least annoying to watch on a computer. There are some so called comb (or mouse teeth) artifacts which annoy a lot. Of course many video players can deinterlace video on-the-fly however it turns that they do that with very different results especially concerning overall video quality.

So I poked around and it seems that one of the nicest deintralcers available is compiled into MPlayer. It is called yadif. So it's really easy to use. I fidlled with some settings for a while and ended up with a command as follows:

mencoder source.mpg -of mpeg -mpegopts tsaf:format=mpeg2:muxrate=30000 -noskip -vf yadif -o dest.mpg -oac copy -ovc lavc -lavcopts vcodec=mpeg2video:mbd=1:aspect=16/9:vbitrate=9100

It turns a file called source.mpg into a nice deinterlaced dest.mpg.

Thursday, January 21, 2010

Making a nice home video DVD

Video source: a Sony handycam (DCR-SR36) which produces mpeg/2 files.

Anticipated result: a nice DVD with rich menus.

How to do it?

First, I don't want to recode the movie clips, since it would degrade their quality. So I decided to use the mpegs straight from the video camera. If there is a need to clip such a video there is a nice tool to do that: avidemux.

There is also another nice tool for DVD authoring: DVDStyler - you can create a DVD menu interactively, add/rearrange clips etc. However it seems that it takes a great deal of time to come up with nice designs.

So I stumbled upon tovid. It's a bunch of scripts which allow to author a DVD in a non-interactive way, just generating appropriate menus, thumbnails etc. And here comes a bummer.... It turned out that there the mpegs from the videocam are not 100% compatible with the DVD format, and they require ... well not recoding but remuxing (remultiplexing). In order to do that I use a buch of commands:
ffmpeg -i $1 -vcodec copy -an -f rawvideo foo.mpv
ffmpeg -i $1 -vn -acodec copy -f mp2 foo.mp2
mplex -f 8 -o $2 foo.mpv foo.mp2
rm foo.mpv foo.mp2
Actually its a script, its good to save the above contents as an executable file, let's say: mpgfix, and then run it:
mpgfix file.mpg file-fixed.mpg
So file.mpg is remuxed and saved as file-fixed.mpg. You can save the file with the same name of course, then the original one will be replaced with the remuxed one. Mind that there is no quality loss here, no recoding.

And here comes the nice part DVD authoring, I just launch one of the tovid scripts (todisc):
todisc -loop 0 -chain-videos -menu-length 2 -thumb-shape normal -aspect 16:9 -menu-title "My DVD" -pal -files *.mpg -titles *.mpg -out DVD
And after a while in the DVD directory there is a complete authored DVD :) with nice animated menus. You can generate an ISO image out of it:
mksiofs -dvd-video -o dvd.iso DVD/
And you'll get a file dvd.iso which is a complete ISO image ready to burn. Enjoy.