PDA

View Full Version : Script for advanced playback : adjust refresh, postprocessing...


Pages : [1] 2

Deshi
12th October 2010, 08:22
Hi everyone !

I'm a newbie in HTPC and especailly in Linux HTPC, but I'm a demanding newbie :rolleyes:

I want to build a script (UltimateMplayer.sh) that will be used as the external player for video in XBMC.
The goal is :
1) to adjust the display resolution/refresh rate according to the one of the video to maximize fluidity;
2) to use the different "profile" previously set in the mplayer.config according to the resolution of the video to optimize postprocessing;
3) and finally when mplayer closes, to go back to the initial resolution/refresh rate of the Desktop.

I need all of your comments, insights, ideas... especially for the last part. As you will see in the following code I'm trying 3 different approaches.
My real problem is that my linux machine is not accessible every day so it's hard for me to test things.

Here it goes : (all of this is originaly in french I hope the translation is not too bad)

#!/bin/bash
# Script used as external player for XBMC
# v 2

# Getting video FPS
FPS_ID=$(mplayer -ao null -vo null -frames 0 -nolirc -nocache -identify "${@}" 2>/dev/null | awk 'BEGIN {FS="="} /FPS/ {print $2}')

# Applying the right display resolution and refresh, those are
# my numbers, use yours for 24,48,50 and 60 hz
case ${FPS_ID%.*} in
23 | 24 ) xrandr -s 1280x720 -r 50;;
25 ) xrandr -s 1280x720 -r 50;;
29 ) xrandr -s 1366x768 -r 60;;
30 ) xrandr -s 1366x768 -r 60;;
* ) xrandr -s 1280x720 -r 50;;
esac

# Getting video Width
WIDTH_ID=$(mplayer -ao null -vo null -frames 0 -nolirc -nocache -identify "${@}" 2>/dev/null | awk 'BEGIN {FS="="} /WIDTH/ {print $2}')

# Applying the right profile, again those are mine
# feel free to adjust in mplayer.config
if [ ${WIDTH_ID} -gt 1919 ]
then
mplayer -profile 1080p "${@}"
echo "1080p"

elif [ ${WIDTH_ID} -gt 1279 ]
then
mplayer -profile 720p "${@}"
echo "720p"

elif [ ${WIDTH_ID} -gt 719 ]
then
mplayer -profile DVD "${@}"
echo "DVD"

else
mplayer -profile AVI "${@}"
echo "AVI"
fi

# <Begin tricky part>

# When mplayer stops we want to go back to the original
# resolution, again it's mine, adjust to yours
mplayer & PROCESS_PID=${!}
while $(/bin/ps "${PROCESS_PID}" > /dev/null 2>&1)
do
sleep 1
done
xrand -s 1366x768 -r 60
echo "Back to Desktop"

# or

mplayer_PID=$!
while [ -d /proc/${PID} ]
do
sleep 1
done
xrand -s 1366x768 -r 60
echo "Back to Desktop"

# or

while [ $(pgrep "mplayer") != "" ]
do
sleep 1
done
xrand -s 1366x768 -r 60
echo "Back to Desktop"

# <End tricky part>


P.S : Does this final section is even usefull ? Will it go back to the initial resolution without it ?

nm
12th October 2010, 11:26
1) to adjust the display resolution/refresh rate according to the one of the video to maximize fluidity;

AFAIK, XBMC supports this quite well by itself, too.

2) to use the different "profile" previously set in the mplayer.config according to the resolution of the video to optimize postprocessing;

What kind of postprocessing do you intend to perform?


# <Begin tricky part>

# When mplayer stops we want to go back to the original
# resolution, again it's mine, adjust to yours
mplayer & PROCESS_PID=${!}
while $(/bin/ps "${PROCESS_PID}" > /dev/null 2>&1)
do
sleep 1
done
xrand -s 1366x768 -r 60
echo "Back to Desktop"

[...]


You are calling mplayer as a foreground process, so there's no need to loop over waiting for it to stop. The script will only progress this far after MPlayer has been closed or killed, so you can simply run xrandr in the end:



[...]

# Applying the right profile, again those are mine
# feel free to adjust in mplayer.config
if [ ${WIDTH_ID} -gt 1919 ]
then
mplayer -profile 1080p "${@}"
echo "1080p"

elif [ ${WIDTH_ID} -gt 1279 ]
then
mplayer -profile 720p "${@}"
echo "720p"

elif [ ${WIDTH_ID} -gt 719 ]
then
mplayer -profile DVD "${@}"
echo "DVD"

else
mplayer -profile AVI "${@}"
echo "AVI"
fi

echo "Back to Desktop"
xrand -s 1366x768 -r 60

Deshi
12th October 2010, 14:47
Wow !
Thanks a lot for the quick and complete response.
It's seems like I was kind of overdoing things... now I understand better how script works.

Quote:
Originally Posted by Deshi
1) to adjust the display resolution/refresh rate according to the one of the video to maximize fluidity;

AFAIK, XBMC supports this quite well by itself, too.

Yes you're right, XBMC has the options to sync video to display or display to video but there are some problems :
- this script can be usefull as a custom player,
- you can benefit from it with any mediacenter accepting an external player,
- as far as I know XBMC only adjust the refresh rate not resolution, so another set of problems :
-- according to the sync method you use (audio/video clock, resampling/drop...) you'll be loosing quality along the way,
-- my display for instance (HDTV) only accepts certain refresh rates at certain resolution : native (for my display) is 1366x768@60 so when I play 24fps without getting to the closest rate possible it's just horrible.

I totally agree that if you're using XBMC and that you have a display running your favorite resolution in 24/48hz and 50hz and also 60hz then you don't need this part of the script.
And maybe some people will find that the distortions in video and/or audio are not tiresome...


What kind of postprocessing do you intend to perform?


I've joined the config of mplayer I'm working on for you to see. The comments are in french sorry...
I've tested it with 10 different files until now and I'm quite happy with it for now...

nm
12th October 2010, 16:28
- as far as I know XBMC only adjust the refresh rate not resolution

Ok, that's a big omission. I thought this feature would be completed already since the refresh rate switching has been there for a long time.

I've joined the config of mplayer I'm working on for you to see. The comments are in french sorry...

Could you upload it somewhere else because attachments can take a long time to get approved here.

Deshi
13th October 2010, 07:57
Hi,


Could you upload it somewhere else because attachments can take a long time to get approved here.


I can even do it live ! :)


[AVI]
profile-desc="Profil pour video AVI"
# Les paramètres vdpau si possible
vo=vdpau:deint=4:chroma-deint:pullup:colorspace=0:denoise=1:sharpen=0.7,xv,x11,
# Les paramètres du deband
vf=pp=gradfun=1.2:16,

[DVD]
profile-desc="Profil pour DVD"
# Les paramètres vdpau si possible
vo=vdpau:deint=4:chroma-deint:pullup:colorspace=0:denoise=1:sharpen=0.5,xv,x11,
# Les paramètres du deband
vf=pp=gradfun=1.1:16,

[720p]
profile-desc="Profil pour video 720p"
# Les paramètres vdpau si possible
vo=vdpau:deint=4:chroma-deint:pullup:colorspace=0:denoise=0.3:sharpen=0.4,xv,x11,
# Les paramètres du deband
vf=pp=gradfun=1.03:16,

[1080p]
profile-desc="Profil pour video 1080p"
# Les paramètres vdpau si possible
vo=vdpau:deint=4:chroma-deint:pullup:colorspace=0:denoise=0.1:sharpen=0.2,xv,x11,
# Les paramètres du deband
vf=pp=gradfun=1.01:16,

[default]
# Pour être sûr que rien ne gêne la lecture
ontop=yes
# Pour être sûr d'être en plein écran
fs=1
# Les paramètres de décodage
vc=coreserve,ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,
# 2 coeurs actifs
lavdopts=threads=2
# Utilisation maximale du CPU
autoq=100
# Les sorties audio
ao=alsa,esd
# Le passthrough de l'ac3, si spdif activé dans alsamixer
ac=hwac3,
# Fixe le nombre de canaux audio en analogique
#channels=6
# Réencode tout son non-ac3 en ac3 pour sortir sur spdif
# à 640kb dès qu'on a 3 canaux en entrée, si spdif activé dans alsamixer
af=lavcac3enc=1:640:3
# Paramètres perso pour les sous-titres au format texte
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
# Piste sous-titre en français en priorité
slang=Français,français,French,french,fr,fra,
# Piste audio en anglais en priorité
alang=Anglais,anglais,English,english,en,eng,
# Pas d'écran de veille
stop-xscreensaver="yes"
# Pas de message d'erreur
really-quiet="1"
# Volume système au max
volume=100
# Boost de 10% du volume soft
softvol-max=110
# Mon skin choisi
skin=DVDPlayer-1.1
# Bande passante max
bandwidth=0
# Taille du cache en ko
cache=10000
# %age min avant le départ de la lecture
cache-min=25
# Vitesse max du CD
cdda=speed=4
# Vitesse max du DVD
dvd-speed=4
# Vitesse max du BD, à tester
bd-speed=2
# Pour les vieux AVI pourris
ni=yes

nm
13th October 2010, 10:44
# Les paramètres du deband
vf=pp=gradfun=1.2:16,

Isn't gradfun a separate filter. If I try using it in pp, my MPlayer r32396 build plays the video but also says that

Opening video filter: [pp=gradfun=1.1:16]
2 errors in postprocess string "gradfun=1.1:16"
Couldn't open video filter 'pp'.

While vf=gradfun=1.1:16 works.

Deshi
13th October 2010, 16:52
Yes, sorry, my mistake...

That's something I've corrected on my PC but not in my original txt file.

:o

Deshi
29th March 2011, 09:34
Yeah it's been a wile... :p

Here is where I'm standing about my "research" about settings for my HTPC on Linux.
I've invented nothing of course, I'm just collecting : mostly from the works of tobal, kaz, jeremy33 (http://www.homecinema-fr.com/forum), with a special thanks to twocats from the Ubuntu forum.

This is the script serving as external player using Mplayer : MonPlayerV3.sh


#!/usr/bin/env bash
# Script for using Mplayer as external player with XBMC or by itself, the point being of
# getting the framerate of the video to put the screen in the right resolution and right refresh rate.
# Then to get the width of the video to start Mplayer with the appropriate "profile" in order to use
# different postprocessing parameters. The last step puts back the resolution to that of your current desktop.
# My TV only output 720p with 50 or 60hz. I have an Nvidia GPU.
# Don't forget to make it executable ;-)
# v3, merci à Master twocats !

# VARIABLES
# Default refresh rate, in my case 50hz.
RATE_ID=${RATE_ID:-50}
# Getting video framerate.
FPS_ID=$(mplayer -ao null -vo null -frames 0 -nolirc -nocache -identify "${@}" 2>/dev/null | awk 'BEGIN {FS="="} /FPS/ {print $2}')
# Getting video width.
WIDTH_ID=$(mplayer -ao null -vo null -frames 0 -nolirc -nocache -identify "${@}" 2>/dev/null | awk 'BEGIN {FS="="} /WIDTH/ {print $2}')

# RATE_ID according to framerate.
# Depending on your TV you can have : 23.976, 24, 25, 48...
case ${FPS_ID%.*} in
23 | 24 ) RATE_ID=50 ;;
25 ) RATE_ID=50 ;;
29 | 30 ) RATE_ID=60 ;;
esac

# Depending on width and framerate we identify the correct profile of Mplayer.
# The "profiles" are defined in the Mplayer config file.
if [ ${WIDTH_ID} -gt 1919 ]
then
case ${FPS_ID%.*} in
23 | 24 ) PROFILE_ID="1080p24f" ;;
25 ) PROFILE_ID="1080p" ;;
29 | 30 ) PROFILE_ID="1080p" ;;
esac
elif [ ${WIDTH_ID} -gt 1279 ]
then
case ${FPS_ID%.*} in
23 | 24 ) PROFILE_ID="720p24f" ;;
25 ) PROFILE_ID="720p" ;;
29 | 30 ) PROFILE_ID="720p" ;;
esac
elif [ ${WIDTH_ID} -gt 719 ]
then
case ${FPS_ID%.*} in
23 | 24 ) PROFILE_ID="DVD24f" ;;
25 ) PROFILE_ID="DVD" ;;
29 | 30 ) PROFILE_ID="DVD" ;;
esac
else
case ${FPS_ID%.*} in
23 | 24 ) PROFILE_ID="AVI24f" ;;
25 ) PROFILE_ID="AVI" ;;
29 | 30 ) PROFILE_ID="AVI" ;;
esac
fi

# Here, the correct resolution is applied,
# and MPlayer is started with the "profile".
xrandr -s 1280x720 -r ${RATE_ID}
mplayer -profile ${PROFILE_ID} "${@}"
echo "${PROFILE_ID}"

# At the end of the video, back to desktop
echo "Return"
xrand -s 1280x720 -r 60


Mplayer config file :


[AVI]
profile-desc="Profile for AVI"
vc=ffodivxvdpau,ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,
sws=9
vf=dr,fspp=5,gradfun=1.2:16,hqdn3d=1:2:5:5,unsharp=l5x5:0.5:c5x5:0.5,scale=-3:720:0:0:10::0:1
ontop=yes
monitoraspect=16:9
fs=1
vo=vdpau:deint=2:ivtc:colorspace=auto:denoise=0.3:sharpen=0.6,xv,x11,
# For old nasty .avi
# ni=yes
lavdopts=threads=2
autoq=100
ao=alsa:device=iec958,esd
ac=hwac3,hwdts
af=channels=6,lavcresample=48000,lavcac3enc=1:640:1
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
stop-xscreensaver="yes"
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4

[AVI24f]
profile-desc="Profile for AVI 24fps"
# No use of this profile if your TV accepts 24 or 48 or 72...
# speed for 24fps to 25fps to fit 50hz
speed=1.0417
vc=ffodivxvdpau,ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,
sws=9
vf=dr,fspp=5,gradfun=1.2:16,hqdn3d=1:2:5:5,unsharp=l5x5:0.5:c5x5:0.5,scale=-3:720:0:0:10::0:1
ontop=yes
monitoraspect=16:9
fs=1
vo=vdpau:deint=2:ivtc:colorspace=auto:denoise=0.3:sharpen=0.6,xv,x11,
# For old nasty .avi
# ni=yes
lavdopts=threads=2
autoq=100
ao=alsa:device=iec958,esd
#ac=hwac3,hwdts
# scaletempo for "synchronising" sound with, without pitch alteration
af=channels=6,scaletempo,lavcresample=48000,lavcac3enc=1:640:1
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
stop-xscreensaver="yes"
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4

[DVD]
profile-desc="Profile for DVD"
vc=ffodivxvdpau,ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,
sws=9
vf=dr,fspp=5,gradfun=1.2:16,hqdn3d=1:2:5:5,unsharp=l5x5:0.5:c5x5:0.5,scale=-3:720:0:0:10::0:1
ontop=yes
monitoraspect=16:9
fs=1
vo=vdpau:deint=2:ivtc:colorspace=auto:denoise=0.3:sharpen=0.5,xv,x11,
lavdopts=threads=2
autoq=100
ao=alsa:device=iec958,esd
ac=hwac3,hwdts
af=channels=6,lavcresample=48000,lavcac3enc=1:640:1
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
slang=fr,fre,french,French,Français,français
alang=en,eng,English,english,Anglais,anglais,fr,fre,french,French,Français,français
stop-xscreensaver="yes"
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4

[DVD24f]
profile-desc="Profile for DVD 24fps"
# No use of this profile if your TV accepts 24 or 48 or 72...
# speed for 24fps to 25fps to fit 50hz
speed=1.0417
vc=ffodivxvdpau,ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,
sws=9
vf=dr,fspp=5,gradfun=1.2:16,hqdn3d=1:2:5:5,unsharp=l5x5:0.5:c5x5:0.5,scale=-3:720:0:0:10::0:1
ontop=yes
monitoraspect=16:9
fs=1
vo=vdpau:deint=2:ivtc:colorspace=auto:denoise=0.3:sharpen=0.5,xv,x11,
lavdopts=threads=2
autoq=100
ao=alsa:device=iec958,esd
#ac=hwac3,hwdts
# scaletempo for "synchronising" sound with, without pitch alteration
af=channels=6,scaletempo,lavcresample=48000,lavcac3enc=1:640:1
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
slang=fr,fre,french,French,Français,français
alang=en,eng,English,english,Anglais,anglais,fr,fre,french,French,Français,français
stop-xscreensaver="yes"
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4

[720p]
profile-desc="Profile for 720p"
vc=ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,ffodivxvdpau,
vf=gradfun=1.05:16
monitoraspect=16:9
ontop=yes
fs=1
vo=vdpau:studio=1:colorspace=auto:denoise=0.2:sharpen=0.3,xv,x11,
lavdopts=threads=2
autoq=100
ao=alsa:device=iec958,esd
ac=hwac3,hwdts
af=channels=6,lavcresample=48000,lavcac3enc=1:640:1
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
slang=fr,fre,french,French,Français,français
alang=en,eng,English,english,Anglais,anglais,fr,fre,french,French,Français,français
stop-xscreensaver="yes"
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4

[720p24f]
profile-desc="Profile for 720p 24fps"
# No use of this profile if your TV accepts 24 or 48 or 72...
# speed for 24fps to 25fps to fit 50hz
speed=1.0417
vc=ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,ffodivxvdpau,
vf=gradfun=1.05:16
monitoraspect=16:9
ontop=yes
fs=1
vo=vdpau:studio=1:colorspace=auto:denoise=0.2:sharpen=0.3,xv,x11,
lavdopts=threads=2
autoq=100
ao=alsa:device=iec958,esd
#ac=hwac3,hwdts
# scaletempo for "synchronising" sound with, without pitch alteration
af=channels=6,scaletempo,lavcresample=48000,lavcac3enc=1:640:1
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
slang=fr,fre,french,French,Français,français
alang=en,eng,English,english,Anglais,anglais,fr,fre,french,French,Français,français
stop-xscreensaver="yes"
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4

[1080p]
profile-desc="Profile for 1080p"
vc=ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,ffodivxvdpau,
vf=gradfun=1.02:16
monitoraspect=16:9
ontop=yes
fs=1
vo=vdpau:studio=1:colorspace=auto:sharpen=0.2,xv,x11,
lavdopts=threads=2
autoq=100
ao=alsa:device=iec958,esd
ac=hwac3,hwdts
af=channels=6,lavcresample=48000,lavcac3enc=1:640:1
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
slang=fr,fre,french,French,Français,français
alang=en,eng,English,english,Anglais,anglais,fr,fre,french,French,Français,français
stop-xscreensaver="yes"
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4

[1080p24f]
profile-desc="Profile for 1080p 24fps"
# No use of this profile if your TV accepts 24 or 48 or 72...
# speed for 24fps to 25fps to fit 50hz
speed=1.0417
vc=ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,ffodivxvdpau,
vf=gradfun=1.02:16
monitoraspect=16:9
ontop=yes
fs=1
vo=vdpau:studio=1:colorspace=auto:sharpen=0.2,xv,x11,
lavdopts=threads=2
autoq=100
ao=alsa:device=iec958,esd
#ac=hwac3,hwdts
# scaletempo for "synchronising" sound with, without pitch alteration
af=channels=6,scaletempo,lavcresample=48000,lavcac3enc=1:640:1
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
slang=fr,fre,french,French,Français,français
alang=en,eng,English,english,Anglais,anglais,fr,fre,french,French,Français,français
stop-xscreensaver="yes"
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4

[default]
profile-desc="Défaut"
# Decoding settings
vc=ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,ffodivxvdpau,
# settings for resize, deint, dering, deblock, deband, denoise, unsharp mask
vf=scale=-3:720:0:0:10::0:1,yadif=3,dr,fspp=5,gradfun=1.2:16,hqdn3d=1:2:5:5,unsharp=l5x5:0.5:c5x5:0.5
# Type of screen
monitoraspect=16:9
# Self explanatory
ontop=yes
# Fullscreen
fs=1
# Vdpau settings
vo=vdpau:studio=1:deint=4:pullup:chroma-deint:colorspace=auto:denoise=0.5:sharpen=0.7,xv,x11,
# 2 cores CPU
lavdopts=threads=2
# Max usage of CPU
autoq=100
# Audio output : alsa spdif then esd
ao=alsa:device=iec958,esd
# Sync Video / Audio, not tested
# mc=1
# Passthrough for ac3 and dts, if spdif activated in alsamixer
ac=hwac3,hwdts
# Determine numbers of audio channels, resample to 48khz
# Encode non-ac3 and non-dts audio in ac3 for spdif output
# at 640kb as soon as there's 2 channels input, if spdif activated in alsamixer
af=channels=6,lavcresample=48000,lavcac3enc=1:640:1
# Personnal settings for text based subs
ffactor="10"
sub-bg-alpha="0"
sub-bg-color="0"
subfont-text-scale="5.7"
subfont-blur="1"
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
# Subs in French first
slang=fr,fre,french,French,Français,français
# Audio in English first
alang=en,eng,English,english,Anglais,anglais,fr,fre,french,French,Français,français
# No screensaver
stop-xscreensaver="yes"
# No message
really-quiet=1
# Volume
volume=100
# Boost software volume
#softvol-max=110
# If you have a skin for Mplayer
skin=DVDPlayer-1.1
# Max bandwidth
bandwidth=0
# Cache size in ko
cache=60000
# %age min before playing
cache-min=25
# Max speed of CD
cdda=speed=4
# Max speed of DVD
dvd-speed=4
# Max speed of BD, not tested
#bd-speed=2


If you use XBMC, the playercorefactory.xml


<?xml version="1.0" encoding="iso-8859-1"?>
<playercorefactory>
<players>
<player name="MonPlayer" type="ExternalPlayer" audio="false" video="true">
<filename>/usr/bin/MonPlayerV3.sh</filename>
<args>/fullscreen /close "{1}"</args>
<hidexbmc>true</hidexbmc>
<hideconsole>true</hideconsole>
<warpcursor>none</warpcursor>
</player>

<player name="lxbdplayer" type="ExternalPlayer" audio="false" video="true">
<filename>/usr/bin/lxbdplayer.sh</filename>
<args>/fullscreen /close "{1}"</args>
<hidexbmc>true</hidexbmc>
<hideconsole>true</hideconsole>
<warpcursor>none</warpcursor>
</player>

<player name="Musique" type="ExternalPlayer" audio="true" video="false">
<filename>/usr/bin/Musique.sh</filename>
<args>"{1}"</args>
<hidexbmc>true</hidexbmc>
<hideconsole>true</hideconsole>
<warpcursor>none</warpcursor>
</player>

</players>

<rules action="prepend">
<rule filetypes="mkv|avi|mp4|wmv|mpg|ts|ifo" player="MonPlayer" />
<rule filetypes="mp3|flac|wav|wma" player="Musique" />
<rule filetypes="m2ts|mpls" player="lxbdplayer" />

</rules>


<rules name="system rules">

<!-- BDs -->
<rule name="BD" BD="true" player="lxbdplayer" />
<rule name="bdfile" bdfile="true" player="lxbdplayer" />
<rule name="bdimage" bdimage="true" player="lxbdplayer" />

<!-- DVDs -->
<rule name="DVD" DVD="true" player="MonPlayer" />
<rule name="dvdfile" dvdfile="true" player="MonPlayer" />
<rule name="dvdimage" dvdimage="true" player="MonPlayer" />

<!-- dvdplayer can play standard rtsp streams -->
<rule name="rtsp" protocols="rtsp" filetypes="!(rm|ra)" player="PAPlayer" />

<!-- Internet streams -->
<rule name="streams" internetstream="true"/>
<rule name="flv/aacp/sdp" mimetypes="video/x-flv|video-flv|audio/aacp|application/sdp" player="DVDPlayer" />
<rule name="mp2" mimetypes="application/octet-stream" filetypes="mp2" player="PAPlayer" />


<!-- Others -->
<rule name="rtv" protocols="rtv" player="DVDPlayer" />
<rule name="hdhomerun/myth/rtmp/mms/udp" protocols="hdhomerun|myth|cmyth|rtmp|mms|mmsh|udp" player="DVDPlayer" />
<rule name="lastfm/shout" protocols="lastfm|shout" player="Musique" />

</rules>
</playercorefactory>


As you sure have noticed, there is a lot of double or irrelevant informations in the settings : for example no use for hqdn3d AND denoise of vdpau. Use the settings that work best for you. The same thing for sharpen settings or decoding or profiles...

Adapt with your own resolutions ans refresh rates of course.

Adapt "speed=1.0417" to "speed=1.25" in profiles with "24f" if your TV just output 60hz.
Add "speed=1.2" and "scaletempo" in profiles with "25f" (create them) if your TV just output 60hz.
Don't change the other profiles.
Change to only "60" with the RATE_ID values...

And so on...

For those wondering : lxbdplayer.sh


#!/bin/bash
# V 1.1

lxbdplayer | mplayer -profile 1080p24f

exit 0;


I'll try to answer as best as I can to any question but I'm for from a specialist, just an humble collector... :rolleyes:

Deshi
22nd June 2011, 13:19
Hi everyone !

So more than 900 views and no comments, tips or upgrades ??? :)

LiquidMercury01
21st July 2011, 20:23
Hey all, I am looking for some help setting up sopcast as anexternal player in xbmc under linux I have SopCast-Player installed (hxxp://code.google.com/p/sopcast-player/) and was given this to edit the playerscorefactory.xml (hxxp://forum.xbmc.org/showpost.php?p=832915&postcount=207)

I have attempted to add it, but to no avail, got a feeling I am doing something wrong, any help would be greatly appreciated. Thanks all.

LiquidMercury01
22nd July 2011, 15:52
hey all, been working at this for some time, but I cannot seem to figure it out, I want to add the sopcast-player under linux as an external player in xbmc, I am currently running ubuntu 11.04, I have the sopcast player installed via ppa. I would have to dig up the url of the player page, if that or any other info is needed please let me know. Thanks again.

Deshi
27th July 2011, 09:32
Hi,
normally to use an external player you have to create an playercorefactory.xml file in /usr/share/xbmc/userdata with the correct link to your player.
Everything is clear in here : http://wiki.xbmc.org/index.php?title=XBMC_Online_Manual

Deshi
24th August 2011, 14:08
Hi everyone,

as some of you have probably??? noticed there was a problem in my mplayer.config.

Using vdpau with the option "colorspace" is tricky, one solution is to fix it to BT.601 or 709 : but you'll have trouble either with SD or HD depending on which you choose. "auto" or "0" seemed at that time the right choice but... vdpau decides what is the colorspace is according to the resolution (HD: width >= 1280 or height >= 576).

Since I make a software resize to height 720, then vdpau sees all as HD, hence bad colors for SD.

The solution I found, with no loss of quality in my opinion,(maybe it's just because the video is less stretched and there is more details for the filters to operate...) is to reduce the soft resize to 575, aply the postprocess then let vdpau do the final upscaling with sharpen and denoise values slightly increased.

Tada ! Good colors everytime.

To be continued :cool:

lanzorg
7th September 2011, 18:40
Hello World !

I would like to make a Linux HTPC, but unfortunately nothing is as good as
>>> MPC + FFDSHOW + ReClock + (MadVR)

So when I saw this post I'm excited to see that "all" the features that I missed on linux existed!

I have some questions:
- Can I use VDPAU and multithreading at the same time?
- What version of mplayer are you using?
- The fork mplayer2 is compatible with your scripts?
- Can you create a tutorial or/and a video explaining how to proceed?

Thanks.

nm
7th September 2011, 19:21
- Can I use VDPAU and multithreading at the same time?

There would be no performance improvement when using hardware decoding and filtering. CPU load of the single player thread will be within 1 to 10 percent depending on the processor, so there's no point in multi-threading it.

Multi-threading software filters and using them with hardware decoding might make sense, but this option isn't currently available in MPlayer.

Edit: As Deshi pointed out, multithreaded software decoding + VDPAU filtering and rendering does work and that makes sense.

Deshi
8th September 2011, 07:47
Hello World !

I would like to make a Linux HTPC, but unfortunately nothing is as good as
>>> MPC + FFDSHOW + ReClock + (MadVR)
Technically speaking Mpayer is as good as MPC-HC, find the Skin and/or GUI (smplayer, gnomeplayer...) that you like and you'll be fine.
FFDSHOW uses FFMPEG, libdav etc..., at least 95% of it is already in Mplayer without adding anything.
With the options speed, scaletempo and lavcac3enc you have 99% of what reclock do.
As for MadVR (not totally convinced on my config since I cannot output RGB in MadVR without loosing a third of the video) depending on which Nvidia GPU you have (which is also true with MadVR), the VDPAU options can acchieve same results.

Please give it a try, make YOUR tests, make YOUR OWN opinion on what can be done or not... You'll be surprised ;)
- Can I use VDPAU and multithreading at the same time?
VDPAU is used for 3 seperate things (depending on GPU) : decoding the video, some image filtering and for the video output aka the rendering.
So yes you can use both but it depends on what you want it to do.
- What version of mplayer are you using?
All I need I get it from here :
https://launchpad.net/~motumedia/+archive/mplayer-daily
https://launchpad.net/~ubuntu-x-swat/+archive/x-updates
- The fork mplayer2 is compatible with your scripts?
I honnestly don't know. I think that this fork uses most of mplayer fonctionnality but not all so...
- Can you create a tutorial or/and a video explaining how to proceed?
That's not planned no... I thought that was quite self explanatory... :p

lanzorg
9th September 2011, 00:02
Thank you for the explanation.

It works but I removed some things.

I have more questions:

- Does XBMC can use GUI for mplayer with the shortcut from XBMC? Or is it just that starts mplayer and at the end of the video, it goes back to XBMC?

- Because I want to use "android-xbmcremote (http://code.google.com/p/android-xbmcremote/)" but does it works with mplayer?

Deshi
9th September 2011, 07:43
Thank you for the explanation.

It works but I removed some things.
You're welcome.
Feel free to share your mods, that's why we're here.
- Does XBMC can use GUI for mplayer with the shortcut from XBMC? Or is it just that starts mplayer and at the end of the video, it goes back to XBMC?
I'll try to follow the "chain of events" and I hope that it will answer your questions.
Basic situation :
You open XBMC : you have the GUI of XBMC. You navigate through your video library, you click on a movie/TV show and the internal player of XBMC reads the video. So you have acces to the GUI and the commands of that player (named DVDPlayer I think) but not XBMC since the player is active.
With the scripts :
You open XBMC : you have the GUI of XBMC. You navigate through your video library, you click on a movie/TV show and the external player (Mplayer in our case) reads the video. So if you have a skin and/or a GUI for Mplayer then you have acces to the GUI and the commands of Mplayer but not XBMC since the player is active.
Second question :
Yes, the line "<args>/fullscreen /close "{1}"</args>" in the playercorefactory does this : launch the video you clicked "{1}", in fullscreen then close the player. XBMC then comes back in front.
- Because I want to use "android-xbmcremote (http://code.google.com/p/android-xbmcremote/)" but does it works with mplayer?
I've never used this so I can't help, I'm using a compact keyboard+pad over Bluetooth. But the name seems to imply that it controls XBMC so I would say it works with the commands of the internal player.
I think you might have details on the fonctionnalities in a dedicated forum...

lanzorg
9th September 2011, 15:14
In fact, it does not work ... (I change the name of the config file by saving)
So I'd say it worked ... but no.

So what should I change in your script, here is my config:

16/10 Display, 1680x1050, 60Hz compatible only.
Nvidia GPU (260GTX)

Thank you in advance.

Deshi
9th September 2011, 16:17
As you sure have noticed, there is a lot of double or irrelevant informations in the settings : For example no use for hqdn3d and denoise of vdpau. Use the settings that work best for you. The same thing for sharpen settings or decoding or profiles...

Adapt with your own resolutions and refresh rates of course.

Adapt "speed=1.0417" to "speed=1.25" in profiles with "24f" if your tv just output 60hz.
Add "speed=1.2" and "scaletempo" in profiles with "25f" (create them) if your tv just output 60hz.
Don't change the other profiles.
change to only "60" with the rate_id values...

And so on...

In the post with scripts you have all you need ;)

But all of this is needed only if you have troubles with your video playback and only if you notice bad audio/video sync. Most of the time simply playing your video file in fullscreen will work just fine.
Forcing the output to 60Hz if you can do 24/25/48 will make your GPU work more.
Try with your drivers or other utility to see if your display can support maybe 30Hz or 50Hz with a custom resolution.

Without beeing in front of your hard/software it would be hard for me to customise it for you, especially since I'm no pro in these stuffs just a collector of info...

Deshi
3rd October 2011, 15:58
Hi everyone,

as some of you have probably??? noticed there was a problem in my mplayer.config.

Using vdpau with the option "colorspace" is tricky, one solution is to fix it to BT.601 or 709 : but you'll have trouble either with SD or HD depending on which you choose. "auto" or "0" seemed at that time the right choice but... vdpau decides what is the colorspace is according to the resolution (HD: width >= 1280 or height >= 576).

Since I make a software resize to height 720, then vdpau sees all as HD, hence bad colors for SD.

The solution I found, with no loss of quality in my opinion,(maybe it's just because the video is less stretched and there is more details for the filters to operate...) is to reduce the soft resize to 575, aply the postprocess then let vdpau do the final upscaling with sharpen and denoise values slightly increased.

Tada ! Good colors everytime.

To be continued :cool:

I'm dumb !!!
In all the AVI and DVD profiles in the VDPAU parameters you just have to put "colorspace=iut601" instead of "colorspace=0" (which means auto). That allows to upscale without the limitations on width for color detection.
;)

Deshi
2nd November 2011, 17:28
Hi everyone,

I've updated my Mplayer config file. I hope that way it would be easier to adjust the settings.


[General]
profile-desc="Generic Options"
# http://manpages.ubuntu.com/manpages/oneiric/fr/man1/mplayer.1.html
# Replace 4 by # cores, only for decoding
lavdopts=threads=4
vc=ffodivxvdpau,ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,
# Scaling soft bicubic spline
sws=10
# Scaling soft lanczos
#sws=9
nolirc=1
menu=1
#nomenu=1
osdlevel=3
mouse-movements=1
#nomouseinput=1
msgcolor=1
msgmodule=1
ontop=yes
monitoraspect=16:9
fs=1
ao=alsa:device=iec958,esd
channels=6
alang=us,usa,en,eng,fr,fra,fre
stop-xscreensaver=yes
really-quiet=1
volume=100
cdda=speed=4
dvd-speed=4
#br-speed=4

[Subtitles]
profile-desc="Subtitles format"
slang=fr,fra,fre
ffactor=1
sub-bg-alpha=0
sub-bg-color=0
subfont-text-scale=4
subfont-osd-scale=4
subfont-blur=1
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
spugauss=1.5
subalign=1
subpos=5
sub-fuzziness=1
ass=1
embeddedfonts=1
ass-hinting=7
ass-border-color=00000060
ass-color=FFFFFF00
ass-font-scale=1.5
ass-bottom-margin=100
ass-use-margins=1

[SoundPassthrough]
profile-desc="Sound Options"
gapless-audio=1
afm=hwac3,

[SoundReenc]
profile-desc="Reencoded Sound"
af=lavcresample=48000,volnorm=2:0.3,surround,sub=120:5,center=4,lavcac3enc=1:640:2

[Sound24f]
profile-desc="Sound Option with scale"
gapless-audio=1
# 24fps to 25fps
speed=1.0417
af=scaletempo,lavcresample=48000,volnorm=2:0.3,surround,sub=120:5,center=4,lavcac3enc=1:640:2

[AVI]
profile-desc="Video AVI"
profile=General
profile=Subtitles
profile=SoundPassthrough
profile=SoundReenc
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=itu601:hqscaling=0:denoise=0.1:sharpen=0.2,gl,xv,x11,
#sws=9 alors scale=1920:-3:0:0:4:::0:1
vf=fspp=4,hqdn3d=1:2:5:5,gradfun=1.2:16,scale=1024:-3:0:0:4:::0:1,unsharp=l5x5:0.4,scale=1600:-3:0:0:4:::0:1,gradfun=1.2:8
#ni=yes

[AVI24f]
profile-desc="Video AVI 24fps"
# Only if you can't display 24hz (nor 48 nor 72...)
profile=General
profile=Subtitles
profile=Sound24f
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=itu601:hqscaling=0:denoise=0.1:sharpen=0.2,gl,xv,x11,
#sws=9 alors scale=1920:-3:0:0:4:::0:1
vf=fspp=4,hqdn3d=1:2:5:5,gradfun=1.2:16,scale=1024:-3:0:0:4:::0:1,unsharp=l5x5:0.4,scale=1600:-3:0:0:4:::0:1,gradfun=1.2:8
#ni=yes

[DVD]
profile-desc="Video DVD"
profile=General
profile=Subtitles
profile=SoundPassthrough
profile=SoundReenc
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=itu601:hqscaling=0:denoise=0.1:sharpen=0.2,gl,xv,x11,
#sws=9 alors scale=1920:-3:0:0:4:::0:1
vf=hqdn3d=1:2:5:5,gradfun=1.2:16,scale=1280:-3:0:0:4:::0:1,unsharp=l5x5:0.4,scale=1920:-3:0:0:4:::0:1,gradfun=1.1:8

[DVD24f]
profile-desc="Video DVD 24fps"
# Only if you can't display 24hz (nor 48 nor 72...)
profile=General
profile=Subtitles
profile=Sound24f
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=itu601:hqscaling=0:denoise=0.1:sharpen=0.2,gl,xv,x11,
#sws=9 alors scale=1920:-3:0:0:4:::0:1
vf=hqdn3d=1:2:5:5,gradfun=1.2:16,scale=1280:-3:0:0:4:::0:1,unsharp=l5x5:0.4,scale=1920:-3:0:0:4:::0:1,gradfun=1.1:8

[720p]
profile-desc="Video 720p"
profile=General
profile=Subtitles
profile=SoundPassthrough
profile=SoundReenc
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=itu709:hqscaling=0:sharpen=0.2,gl,xv,x11,
vf=gradfun=1.05:16,unsharp=l5x5:0.4,scale=1920:-3:0:0:4:::0:1,gradfun=1.1:8

[720p24f]
profile-desc="Video 720p 24fps"
# Only if you can't display 24hz (nor 48 nor 72...)
profile=General
profile=Subtitles
profile=Sound24f
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=itu709:hqscaling=0:sharpen=0.2,gl,xv,x11,
vf=gradfun=1.05:16,unsharp=l5x5:0.4,scale=1920:-3:0:0:4:::0:1,gradfun=1.1:8

[1080p]
profile-desc="Video 1080p"
profile=General
profile=Subtitles
profile=SoundPassthrough
profile=SoundReenc
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=itu709:hqscaling=0:sharpen=0.2,gl,xv,x11,
vf=gradfun=1.1:8

[1080p24f]
profile-desc="Video 1080p 24fps"
# Only if you can't display 24hz (nor 48 nor 72...)
profile=General
profile=Subtitles
profile=Sound24f
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=itu709:hqscaling=0:sharpen=0.2,gl,xv,x11,
vf=gradfun=1.1:8

[default]
profile-desc="Default"
vo=vdpau:force-mixer:deint=4:pullup:chroma-deint:colorspace=0:hqscaling=0:denoise=0.3:sharpen=0.5,gl,xv,x11,
lavdopts=threads=4
autoq=100
vc=ffmpeg12vdpau,ffh264vdpau,ffwmv3vdpau,ffvc1vdpau,ffodivxvdpau,
sws=2
vf=fspp=4,hqdn3d=1:2:5:5,scale=-3:1080:0:0:0.33:0.33::0:1,unsharp=l5x5:0.4,gradfun=1.1:8
monitoraspect=16:9
ontop=yes
fs=1
ao=alsa:device=iec958,esd
channels=6
afm=hwac3,
af=lavcresample=48000,volnorm=2:0.3,surround,sub=120:5,center=4,lavcac3enc=1:640:2
ffactor=1
sub-bg-alpha=0
sub-bg-color=0
subfont-text-scale=4
subfont-osd-scale=4
subfont-blur=1
spuaa=4
font=/usr/share/fonts/truetype/msttcorefonts/impact.ttf
spugauss=1.5
subalign=1
subpos=5
sub-fuzziness=1
ass=1
embeddedfonts=1
ass-hinting=7
ass-border-color=00000060
ass-color=FFFFFF00
ass-font-scale=1.5
ass-bottom-margin=100
ass-use-margins=1
slang=fr,fra,fre,eng,en
alang=en,eng,fr,fra,fre
stop-xscreensaver="yes"
volume=100
bandwidth=0
cache=60000
cache-min=25
cdda=speed=4
dvd-speed=4
#bd-speed=2

;)

lanzorg
5th November 2011, 21:06
Amazing!
Thanks for the update!

Deshi
8th November 2011, 08:39
You're welcome... ;)

Feel free to share any comment on how it works for you : what you use and don't, what are your specific tweaks or config...

See ya !

Carpo
11th November 2011, 22:05
so if i have this right this will take a 1920x1080 (or 816 1040 10720 and re-size it to fit the refresh and screen size its on? Only ask as I use my laptop a lot and it can only do 1280x800 and most of the bluray backups i did where 1920x816, as I usually use my main PC but its busted atm

nm
11th November 2011, 22:46
so if i have this right this will take a 1920x1080 (or 816 1040 10720 and re-size it to fit the refresh and screen size its on?

No, that's what all players do by default in full screen mode. This script tries to change screen refresh rate and resolution to match the video file. If the display supports multiple refresh rates, it's always optimal to use a rate that is a multiple of the video framerate. 24 fps video is best displayed at 24 Hz, 48 Hz, 72 Hz and so on while 50 fps video should be displayed at 50 Hz, 100 Hz, 150 Hz or ...

Laptop LCD panels have a fixed refresh rate of 60 Hz, and changing that won't work. Resolution change won't do any good either -- it's best to use the native resolution and let the player/renderer scale the video as usual.

Carpo
13th November 2011, 00:48
so i might as well stick to my tried and tested :)

mplayer -lavdopts threads=2 -x 1280 -y 800 film.name.mkv

nm
13th November 2011, 11:36
mplayer -lavdopts threads=2 -x 1280 -y 800 film.name.mkv

Well, "-x 1280 -y 800" is ok if you want to fill the screen completely without top and bottom black bars, and the wrong aspect ratio doesn't bother you. The other option for filling the screen completely is to crop from left and right (W and E buttons during full screen playback).

If you don't mind black bars, just use full screen mode "-fs" without "-x 1280 -y 800".

Carpo
13th November 2011, 11:37
if i use -fs, it tries to play it at 1920x800 - hence the need for the other options

nm
13th November 2011, 11:44
if i use -fs, it tries to play it at 1920x800 - hence the need for the other options

That's not normal. Which desktop and window manager are you using?

How do you know it plays at 1920x800? Which part of the frame do you see? Top-left or center?

Carpo
13th November 2011, 11:46
at the moment i am in between window managers, might go back to xfce later, but that will take a while as i have to compile it from source as i use gentoo, but i think it does it under kde/konsole and xfce/terminal - will test later and report back

nm
13th November 2011, 12:00
And you really only see part of the frame in full screen mode? No black bars at top and bottom?

If you look at MPlayer's command-line log, it tells you that the video is played back at 1920x800, but that's before rendering. Normally the video gets scaled by the GPU so that it fits within the screen in full screen mode. This scaling does not get reported on the log.

Carpo
13th November 2011, 12:30
i'll recheck on both systems, but im sure on one of them it plays 1920x800 if i do -fs only, although i have recently updated to beta nvidia driver and xorg 1.11.2

Deshi
14th November 2011, 09:04
Hi Carpo,

as nm said, the issue is simple, for a start don't bother with numbers :
- just play your file with -fs,
- and watch if there is any missing part of your video, if there is a portion of your video that is not displayed : top, bottm, left or right...

With your options your video is distorded because it is stretched to the entire screen without taking into account the aspect ratio.

Concerning the script, on your laptop, you could still use part of it, like the "speed" and "scaletempo" parts, for a better fluidity when redering your video.
But to be honnest I've nerver tried playing 24fps with 60hz, so the result might be worse than if you let it be played by itself.

Carpo
14th November 2011, 13:37
Laptop seems to be playing it ok atm, maybe the updated kernel/video drive and xorg have something to do with it, but i noticed when playing Predator which is 1920x1040 - mplayers tells me

[ASPECT] Warning: No suitable new res found!

But it plays with the black bars at the bottom and top of the screen,

On most of the 720p files i have i get

Movie-Aspect is 2.35:1 - prescaling to correct movie aspect.

so im guessing video card is doing what it should be doing

Deshi
15th November 2011, 09:02
In my opinion your player and hardware are working properly, no doubt.
The message you get is due to the fact that the video you played (1920x1040) is not a "perfect" ratio know by the player (it should be 1920x1080, 1280x720...).

Your plackback experience will be better this way because whatever "weird" resolution you throw at it the player will preserve the aspect ratio of your video. It means you won't have any distorded faces and so on.

Forcing your output to 1280x800 wil most of time result in very badly displayed video. Just taking as exemple the file you used earlier (1920x1040 native) : the width will be scaled in a proportion of 1.5 (1920/1280) but the height will be scaled by 1.3 (1040/800), resulting in a distorded image... Even a 1280x720 video will be damaged since the width will be untouched but the height will be elongated.
Don't put any values for -x and -y and let the player adjust dynamicaly the output resolution.

Deshi
18th November 2011, 16:56
Hi everyone !

I was wondering, does any of you know if there is any filter in Mplayer that is multi-threaded ? Except decoding of course...

Or is there a way to "force" a filter into a particular thread ? Creating a sort of affinity or something...

lanzorg
22nd February 2012, 11:24
Hello everyone!

I have some (a lot of) questions :

What is the difference between vo and vf?

You force the video in 25fps? Is it not better to do everything in 24fps? For the original voice?
Or is it because your tv does not support 24fps?
So we could force the framerate on linux? Without stuttering?
I saw it in XBMC which made me 23.95fps while my laptop can do only the 60fps!
So if I understand, it does not change the framerate, but changes the video (scaletempo)?

I've heard that mplayer2 was much better than mplayer now ... Did you try?

What is your opinion about XT7-player (http://xt7-player.sourceforge.net/xt7forum/viewtopic.php?f=4&t=2)?
It is much like a mix between mpc-hc and ffdshow.

What is your office environment? (gnome2, gnome3, kde, openbox, ...)?
Because I am on "Unity" and I have tearing (not much) on all my video (flash, mplayer, vlc) and I think it's my office environment the guilty.

Deshi
22nd February 2012, 17:11
Hi lanzorg,

I'll try to give (some) answers :D

As I've stated earlier in the thread the script tries to be as general as possible.
But as I'm french, VO is for "Version Originale" and VF for "Version Française". Sorry about that ;)

Some people might have a display that can only take 50 or 60hz so you have to "alter" the audio stream to match the video before it is rendered. Of course it's better to render in 23 (aka 23.976), 24/48/72, 25/50/75 or 30/60/120 if your display allows it.

Yes you can "force" a resolution and a framerate in linux, that's what the command xrandx is for, as long as your display allows it.

In XBMC I know that there is 2 or 3 ways to sync A/V but I don't know exactly how they work : resampling, dithering...

Scaletempo is a function in Mplayer which allows (when you cannot display at the appropriate refresh rate) to sync the audio (it doesn't alter the video) without altering pitch. A problem often know as Palspeedup for us europeans.

Last time I checked Mplayer2 missed a lot of things compared to Mplayer :
http://www.mplayer2.org/comparison.html
No I've never tried it because if you use the latest version of Mplayer for example from here :
https://launchpad.net/~motumedia/+archive/mplayer-daily
you'll have daily builds with all fonctionnalities up to date.
The only thing that Mplayer and Mplayer2 lack is multi-threaded filtering (aka live post-treatment). Both support multi-threaded decoding but not with the filters.

Regarding XT7-player, I've never looked into it...

My favorite desktop is Xfce, I know very little about Gnome or Unity.

Edit : XT7-player is a GUI, a Graphical User Interface for Mplayer, it gives no additional fonctionnality except that you can configure most of the options by using a graphical interface. By the way, no GUI is supported by Mplayer2...

lanzorg
23rd February 2012, 00:28
But as I'm french, VO is for "Version Originale" and VF for "Version Française". Sorry about that.

French is my native language too. I talked to vf = ... and vo = ... in the script.

Yes you can "force" a resolution and a framerate in linux, that's what the command xrandx is for, as long as your display allows it.

By "force", I mean without considering the limitation of the screen! Xbmc "changes" the framerate (23,96, 24, 25) while my laptop only supports 60fps, making maybe the scaletempo or something else, so it doesn't really change the framerate!

The PPA is really great especially for this kind of software. On windows, need to update constantly mpc-hc, ffdshow, lavfilter, reclock, ... is really a waste of time. But ffdshow and avisynth are multithreaded! The idea of ​​using one thread by filter is really great and should work, the harder is to find out how.

Are there still problems with GTK3 applications under xfce?

Thanks :D

Deshi
23rd February 2012, 16:33
Hi,
vo...vf, ooops I've read that one too quickly !
By script you meant in the config file of Mplayer :
vo= stands for video output (aka the renderer)
vf= stands for video filter(s) (aka post-processing)
http://manpages.ubuntu.com/manpages/oneiric/fr/man1/mplayer.1.html

If you force a non-supported resolution or refresh rate you'll just have a black screen for a moment before the previous settings take over. For XBMC I don't know it works : does it really tries to change resolution and/or refresh rate ? Does it only adjust the audio/video sync to match actual screen resolution and/or refresh rate ?

Regarding problems on GNU/Linux, as far as I'm concerned the only trouble I had was with the "nouveau" driver for my Nvidia GPU. I installed the proprietary one and that's all.

lanzorg
25th February 2012, 12:17
Thanks !

tvferret
14th March 2012, 10:09
Hi Deshi,

I hope you still occasionally read this thread. I have implemented most of your stuff here. I have a slightly different setup, I use Freevo instead of XBMC but nevertheless, principles are the same, I use mplayer for playback. I have managed to switch the refresh rate of my TV to 23.976 successfully, this was a problem as the TV (Sony LED) reported incorrect EDID. I managed to get this working and video is working fine, smooth playback, no judder. Now, I use audio over HDMI to my Onkyo AV Receiver and this is where the problems are. Audio is delayed for all content that is 23.976 with the TV's refresh rate set to the same value. No audio sync problems when TV is set to 59.94 Hz but I get judder.

Reading various forums/posts I gather that this is a common problem. I can't seem to find a solution. Have you noticed similar problems? If so, how have you solved it?

Deshi
14th March 2012, 10:48
Hi tvferret,

It's nice to have more report about my wanderings... :D

Unfortunately (or not ;) ) I didn't have any problem of delayed audio on my setup but my A/V Amp is much less sophisticated than yours maybe that helps me for that matter : sony STR-DH510.

As far as I know Onkyo receivers are quite complete and I'm sure there is a setting to enter a delay for the audio. But the problem is that it will always delay audio and not only for a specific file.

I think you'll have to enter a new parameter in the appropriate profile in mplayer.
It is one of these two but I don't remerber which one is for mplayer and mencoder :

delay <sec>
delay audio in seconds, negative or positive value is possible.
adelay=<1-32760>
delay initial audio in milliseconds (default : 0), use it to delay audio from video.

I hope that helps, otherwise you'll have to search the man page of mplayer to find what you need.

tvferret
14th March 2012, 14:45
Hmm, delay is the right option. I already checked it out. It does not fix the problem. BTW, this is not a problem of Onkyo, if I connect the HDMI cable directly to the TV, problem still persists.

Setting delay in the mplayer config does not work, any manipulation of this variable results in even greater loss of A/V sync. The only thing that seems to work (well kind of) is to set the A/V delay of approx. 250ms in the receiver. It's not perfect as the delay is not constant. It seems to drift a bit in both directions.

I have read a lot of posts on various forums (XBMC, MythTV, Boxee etc.) and this is a well known issue. It manifests itself when the monitor's refresh rate = movie's FPS, in this case 23.976 and when audio is routed via HDMI. It could be an NVIDIA problem but I have seen claims that ATI suffers too.

Nothing that I do seem to work. I got latest (Squeeze backports) NVIDIA driver, mplayer etc. All to no avail :-(

Deshi
14th March 2012, 17:11
Too bad that didn't work.

Did you try to adjust the refresh just to 24 ?
It would not be a perfect match but the difference might not be visible at all and maybe it will solve the problem.

Otherwise you can still adjust the audio delay during playback with the + and - keys.

tvferret
15th March 2012, 12:42
I haven't tried 24.00 Hz yet. Will do this tonite. Also, I will as a last resort, try the mplayer2 which apparently handles A/V sync much better than mplayer (in general, not related to 23.976 problem, at least not obviously).

Strange, the XMBC player (native one) has exactly the same problem, still not fixed. I'm just wondering what the XMBC guys based their player on? I seriously doubt they wrote it from scratch, could it be mplayer based? If so, this would explain why the bug manifests itself in it too.

http://forum.xbmc.org/showthread.php?tid=111722

tvferret
20th March 2012, 11:09
OK, fixed the problem or so it seems for now. I haven't tested it thouroughly enough to be sure but it looks promising. Basically, I build latest mplayer from SVN but to no avail. Then I tried mplayer 2 (from Debian Squeeze backports) and it was slightly better, some videos were in sync but majority (90%) had exactly same problem, audio 300ms ahead of video. I tried to compile latest mplayer2 from git (the one in backports is 12 months old) and the compilation failed but as a side result I ended up with the latest ffmpeg lib (I built it by hand from git because mplayer2 configure script complained about one I had installed as being too old) and voilà! A/V sync now seems to be spot on while playing back @ 24p! :-) Tonite I'll try mplayer to see if it got fixed too.

tvferret
20th March 2012, 11:16
BTW, I seem to have a problem now with ass subtitles. Mplayer2 uses libass by default and I liked it much better than standard subs in mplayer (for one it formats microdvd subs correctly by using tags) but I have a problem with font size. I like my subs at constant size so I tried to set FontSize to constant value. No luck. It seems that for vidoes that are true 16:9 aspect subs are larger than for the ones in 2.39:1 aspect. So I tried to force PlayResX and PlayResY to something like 1280 and 720 respectively. This should have worked but still no luck. It seems to me that the final font size is the product of the FontSize, PlayResX:PlayResY and the height of the video. This should not happen. I disabled all font scaling. Both, mplayer (from SVN) and mplayer2 behave alike. I'll update the libass tonite to see if this is it but I suspect it's mplayer throwing the movie height to the equation.

lanzorg
16th May 2012, 17:21
Did you try AviSynth with Wine or AvxSynth (Native Linux port of AviSynth) for multithreaded effects/filters?

Something else, I really feel like a superior image quality using XV.