View Full Version : Screen tearing with Compiz


Daravon
06-19-08, 08:47 PM
I have my everyday computer (Biostar 7050 w/5400+, 4gigs ram, Hardy Heron) hooked up via HDMI to my Sony tube TV, which I use to watch dvds and some downloaded anime movies usually in .mkv.

The video quality is excellent but for some horizontal tearing during certain scrolling shots. I've found out that it doesn't seem to exhibit the tearing if I use metacity. However, I can't live without compiz. Are there any adjustments to my Nvidia settings or anything else that could fix this up?

Or, since I have the Sony set up as a separate X screen (can post xorg if needed), is there any way I could just disable compiz on THAT display, but keep it for my normal computer?

Failing even that, is there some way I could write a 'play movie' script that will basically switch to metacity whenever I use mplayer? I don't know anything about bash scripts but like have a script so when I type playmovie <somefile> it does something like

metacity --replace
mplayer <somefile>
compiz --replace

mythmaster
06-19-08, 09:01 PM
Lol, you just wrote a shell script! Replace "<somefile>" with "$1":

#! /bin/bash
metacity --replace
mplayer $1
compiz --replace

Save it as "playmovie", "chmod +x" it and put it in /usr/bin "sudo cp playmovie /usr/bin".

I like to keep a bin folder in my home dir and add it to my path for this kind of stuff.

Daravon
06-19-08, 09:25 PM
Cool! Awesome. So the $1 means 'argument passed to the script'? If I wanted to be able to pass mplayer more options, like I usually do, I assume I can embed them in the script like so

#! /bin/bash
metacity --replace
mplayer -ac hwac3 -slang eng -af pan:2:1:.3:.3:1 $1
compiz --replace

right?

But can I make my playmovie script take arguments itself and pass them to mplayer? Because I don't always want japanese subtitles ...

playmovie -ac hwac3 -slang eng somefile.mkv

or if I wanted to have it use an arbitrary program

playmovie vlc somefile.mkv

This is getting complicated though.

MichaelZ
06-19-08, 09:37 PM
I use a script that is called from myth and I create a ".meta" file that has the same name as the file passed via the $1. The .meta file essentially has the line switches I want to use for that file. So, if my $1 is "somemovie.ts" it looks for a "somemovie.meta" and appends the contents to the mplayer command. This way I can control the way ALL my movies or played as well as format, subs, etc. Works fraking great. If I don't have a .meta file I have a default string that is called.
Also, I found tearing is controlled by the "vblank sync" that you can checkbox on/off with nvidia-settings. I think I posted sometime back which one it is in the nvidia-settings panel.

Daravon
06-19-08, 09:53 PM
Found out I need some &'s

#! /bin/bash
metacity --replace&
mplayer $1
compiz --replace&


Works pretty well! I need to figure out a satisfactory way to complicify it though. I would like to be able to pass options to mplayer and not have to hard-code the options in the script. With this simple script there's no way to do anything cool like, have sound.

mythmaster
06-19-08, 10:06 PM
I use a script that is called from myth and I create a ".meta" file that has the same name as the file passed via the $1. The .meta file essentially has the line switches I want to use for that file. So, if my $1 is "somemovie.ts" it looks for a "somemovie.meta" and appends the contents to the mplayer command. This way I can control the way ALL my movies or played as well as format, subs, etc. Works fraking great. If I don't have a .meta file I have a default string that is called.

This is a good idea. Also, you can set your mplayer config file (~/.mplayer/config) with default settings for different file formats, I believe.

mythmaster
06-19-08, 10:16 PM
Cool! Awesome. So the $1 means 'argument passed to the script'? If I wanted to be able to pass mplayer more options, like I usually do, I assume I can embed them in the script like so

#! /bin/bash
metacity --replace
mplayer -ac hwac3 -slang eng -af pan:2:1:.3:.3:1 $1
compiz --replace

right?

But can I make my playmovie script take arguments itself and pass them to mplayer? Because I don't always want japanese subtitles ...

playmovie -ac hwac3 -slang eng somefile.mkv

or if I wanted to have it use an arbitrary program

playmovie vlc somefile.mkv

This is getting complicated though.

Yeah, it gets complicated; but, for reference, $1 is the first command line parameter, $2 is the second, $3 the third, etc. For example, you could test $2 to be "en" or "ja" and execute the proper command.

MichaelZ
06-20-08, 08:45 AM
This is a good idea. Also, you can set your mplayer config file (~/.mplayer/config) with default settings for different file formats, I believe.

I tried that at first but then I realized with the different containers, mkv, m2ts, etc. I was not sure what video or audio codecs were in the container not to mention subtitles on, off etc. I decided to use a meta file and put the options there. I use .mplayer/config for global setting, i.e., cache, screen size, etc. Also, I believe the options on the command line override the config file if need be.

andy987s
08-29-08, 06:23 AM
Cool! Awesome. So the $1 means 'argument passed to the script'? If I wanted to be able to pass mplayer more options, like I usually do, I assume I can embed them in the script like so

#! /bin/bash
metacity --replace
mplayer -ac hwac3 -slang eng -af pan:2:1:.3:.3:1 $1
compiz --replace

right?

But can I make my playmovie script take arguments itself and pass them to mplayer? Because I don't always want japanese subtitles ...

playmovie -ac hwac3 -slang eng somefile.mkv

or if I wanted to have it use an arbitrary program

playmovie vlc somefile.mkv

This is getting complicated though.

Davron,
If you want to pass multiple parameters to your script, you can do it like so:
#! /bin/bash
metacity --replace&
mplayer $*
compiz --replace
Which, as you might guess, substitutes all parameters.
:>

SeijiSensei
08-29-08, 08:26 AM
You can also pass lists by enclosing them inside single quotes so that the bash shell treats them as a single positional parameter. For instance, if the script is:

#! /bin/bash
# script playmovie
metacity --replace &
mplayer $1 $2
compiz --replace

Then you can invoke it with:

playmovie '-slang en -alang jpn -vf screenshot etc.' filename

Everything inside the quotes is passed as $1.

Another simple solution is to stash options in the environment before running the script. For instance:

#! /bin/bash
# script playmovie with environment variable

if [ "$OPTIONS" = "" ]
then
OPTIONS='-alang jpn -slang en -lavdopts skiploopfillter=all'
fi

metacity --replace &
mplayer $OPTIONS $1
compiz --replace

Then you can invoke the script with

export OPTIONS='some other list of options'
playmovie filename

and it will override the default options set in the script with the ones set in the export command.

Enclosing something in single quotes tells the shell to treat the string literally; using double quotes tells the shell to substitute any $name parameters with their corresponding values. So,

'$OPTIONS' is interpreted as $OPTIONS
"$OPTIONS" is interpreted as the contents of $OPTIONS

Hope these tips help!

mym6
08-29-08, 04:28 PM
Yeah, it gets complicated; but, for reference, $1 is the first command line parameter, $2 is the second, $3 the third, etc. For example, you could test $2 to be "en" or "ja" and execute the proper command.

$0 is the name of the app being run