From 030251fdf60f7bad5a30b3a99d946203f1cb036a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20K=C3=BChling?= Date: Wed, 27 Apr 2011 08:28:37 +0200 Subject: [PATCH] mplayer: Make alsa work (use larger buffer), and use it instead of OSS This reduces CPU load during playback, and also makes the audio mixer react much more quickly (note: if mplayer automatic resampling kicks in now, we should add -af-adv force=2 to make it use the fastest resampling filter) --- mplayer/Makefile | 4 ++- mplayer/README | 40 +++++++++++++++++++++++---- mplayer/patches/020-alsa-buffer.patch | 15 ++++++++++ 3 files changed, 53 insertions(+), 6 deletions(-) create mode 100644 mplayer/patches/020-alsa-buffer.patch diff --git a/mplayer/Makefile b/mplayer/Makefile index 1e781a0..1856919 100644 --- a/mplayer/Makefile +++ b/mplayer/Makefile @@ -10,7 +10,7 @@ PKG_NAME:=MPlayer PKG_REV:=33333 FFMPEG_REV:=d84f191d37b8123203dff250531a4b4c0d5f587a PKG_VERSION:=r$(PKG_REV) -PKG_RELEASE:=2 +PKG_RELEASE:=3 PKG_SOURCE=$(PKG_NAME)-$(PKG_VERSION).tar.gz FFMPEG_SOURCE_URL:=git://git.videolan.org/ffmpeg.git @@ -79,6 +79,8 @@ CONFIGURE_ARGS := --target=mips \ --disable-vdpau \ --disable-gl \ --disable-xf86keysym \ + --disable-ossaudio \ + --enable-alsa \ --enable-vidix \ --disable-vidix-pcidb \ --with-vidix-drivers="no" \ diff --git a/mplayer/README b/mplayer/README index bc06617..e5aa018 100644 --- a/mplayer/README +++ b/mplayer/README @@ -1,11 +1,41 @@ -this is outdated; mpeg1 support currently disabled (patents?). +1. prepare your video files for Ben: -Use ffmpeg2theora or ffmpeg with vp8, vorbis, mkv +Use ffmpeg2theora or ffmpeg with vp8, vorbis, mkv. -1. prepare your avi files for Ben: +When using theora, try to use a video width and height that are a multiple of +16. Currently theora decoding displays strange borders, if size is not a +multiple of 16. -for i in $(echo "*.avi"); do /usr/bin/mencoder -o "$i.mpg" -vf scale=320:-2 -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video:vpass=1:vbitrate=200 -ofps 24000/1001 -oac lavc -lavcopts acodec=mp2:abitrate=64 "$i" && /usr/bin/mencoder -o "$i.mpg" -vf scale=320:-2 -of mpeg -ovc lavc -lavcopts vcodec=mpeg1video:vpass=2:vbitrate=200 -ofps 24000/1001 -oac lavc -lavcopts acodec=mp2:abitrate=64 "$i"; done +Try to use an audio sampling rate of 44100 for the vorbis audio. If the +automatic resampling of the alsa OSS emulation is triggered, quality degrades +a lot. Alternatively use 'mplayer -af resample=44100:1:1' on playback. + +For encoding try to use libtheora 1.2 ("ptalarbvorm") which improves visual +qality a lot compared to previous versions. Always encode with +constant-quality *not* giving a bitrate target. + +Here's an example encoding command: + +ffmpeg2theora -o output.ogv input.avi \ + -v8 -x320 -y176 \ + -a0 --channels 2 --samplerate 44100 + +Yielding a pretty high visual quality (-v8 i.e. "80%"). Use -v6 for +approximately half the bitrate with moderate quality. 2. play your files with Ben: -mplayer -vo sdl -ac mad file.mpg +mplayer output.ogv + +(Assumptions: + +the following options should be set in your ~/.mplayer/config: + +volume=10 +vo=cvidix +screenw=320 +screenh=240 +fs=1 +ac=tremor +quiet=1 +) diff --git a/mplayer/patches/020-alsa-buffer.patch b/mplayer/patches/020-alsa-buffer.patch new file mode 100644 index 0000000..140b47c --- /dev/null +++ b/mplayer/patches/020-alsa-buffer.patch @@ -0,0 +1,15 @@ +Index: MPlayer-r33304/libao2/ao_alsa.c +=================================================================== +--- MPlayer-r33304.orig/libao2/ao_alsa.c 2011-04-27 08:12:35.000000000 +0200 ++++ MPlayer-r33304/libao2/ao_alsa.c 2011-04-27 08:12:55.000000000 +0200 +@@ -313,8 +313,8 @@ + */ + static int init(int rate_hz, int channels, int format, int flags) + { +- unsigned int alsa_buffer_time = 500000; /* 0.5 s */ +- unsigned int alsa_fragcount = 16; ++ unsigned int alsa_buffer_time = 1000000; /* 0.5 s */ ++ unsigned int alsa_fragcount = 4; + int err; + int block; + strarg_t device;