use aac encoder(libvo_aacenc) available in ubuntu 12.04 universe (libavcodec-extra-53)

This commit is contained in:
j 2012-12-16 19:56:54 +01:00
parent 348adff954
commit 6cfaa54f97
6 changed files with 56 additions and 26 deletions

10
README
View file

@ -29,7 +29,7 @@ To run pan.do/ra you need to install and setup:
python-geoip python-html5lib python-lxml \ python-geoip python-html5lib python-lxml \
python-gst0.10 gstreamer0.10-plugins-good gstreamer0.10-plugins-bad \ python-gst0.10 gstreamer0.10-plugins-good gstreamer0.10-plugins-bad \
postgresql postgresql-contrib rabbitmq-server \ postgresql postgresql-contrib rabbitmq-server \
ffmpeg2theora ffmpeg \ ffmpeg2theora libav-tools libavcodec-extra-53 \
python-ox oxframe python-ox oxframe
@ -138,14 +138,6 @@ b) apache2 (if you need it for other sites on the same server)
Now you can open pandora in your browser, the first user to sign up will become admin. Now you can open pandora in your browser, the first user to sign up will become admin.
* A note about providing H.264 versions
For H.264 videos, you need ffmpeg with x264 and libfaac enabled,
you also need to install qt-faststart (from ffmpeg/tools)
(you can use medibuntu.org packages or compile ffmpeg yourself)
to enable H.264 derivatives add "mp4" to video.formats in your config.jsonc
=== Updating === === Updating ===
To update a pandora installation get the latest version from bzr by running To update a pandora installation get the latest version from bzr by running
su pandora su pandora

View file

@ -14,6 +14,8 @@ from django.contrib.auth.models import User
import ox.jsonc import ox.jsonc
from ox.utils import json from ox.utils import json
from archive.extract import supported_formats, AVCONV
_win = (sys.platform == "win32") _win = (sys.platform == "win32")
@ -49,6 +51,32 @@ def load_config():
for key in config['itemKeys']: for key in config['itemKeys']:
config['keys'][key['id']] = key config['keys'][key['id']] = key
old_formats = getattr(settings, 'CONFIG', {}).get('video', {}).get('formats', [])
formats = config.get('video', {}).get('formats')
if set(old_formats) != set(formats):
sformats = supported_formats()
if sformats:
for f in formats:
if f not in sformats or not sformats[f]:
sys.stderr.write('''WARNING:
Your configuration contains a video format "%s" that is
not supported by your version of avconv. Make sure you
dont have a local version of avconv in /usr/local/bin
and libavcodec-extra-53 and libav-tools are installed:
sudo apt-get install libavcodec-extra-53 libav-tools
''' % f)
else:
sys.stderr.write('''WARNING:
You dont have "%s" installed.
To fix this on Ubuntu 12.04, run:
sudo apt-get install libavcodec-extra-53 libav-tools
check the README for further details.
''' % AVCONV)
settings.CONFIG = config settings.CONFIG = config
admin = len(settings.CONFIG['userLevels']) - 1 admin = len(settings.CONFIG['userLevels']) - 1
if not 'syncdb' in sys.argv \ if not 'syncdb' in sys.argv \

View file

@ -20,7 +20,8 @@ from ox.utils import json
img_extension='jpg' img_extension='jpg'
FFMPEG2THEORA = 'ffmpeg2theora' AVCONV = 'avconv'
MAX_DISTANCE = math.sqrt(3 * pow(255, 2)) MAX_DISTANCE = math.sqrt(3 * pow(255, 2))
@ -46,6 +47,20 @@ class AspectRatio(fractions.Fraction):
def ratio(self): def ratio(self):
return "%d:%d" % (self.numerator, self.denominator) return "%d:%d" % (self.numerator, self.denominator)
def supported_formats():
p = subprocess.Popen(['which', AVCONV],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
if not stdout.strip():
return None
p = subprocess.Popen([AVCONV, '-codecs'],
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = p.communicate()
return {
'ogg': 'libtheora' in stdout and 'libvorbis' in stdout,
'webm': 'libvpx' in stdout and 'libvorbis' in stdout,
'mp4': 'libx264' in stdout and 'libvo_aacenc' in stdout,
}
def stream(video, target, profile, info): def stream(video, target, profile, info):
if not os.path.exists(target): if not os.path.exists(target):
@ -207,14 +222,13 @@ def stream(video, target, profile, info):
if audiobitrate: if audiobitrate:
audio_settings += ['-ab', audiobitrate] audio_settings += ['-ab', audiobitrate]
if format == 'mp4': if format == 'mp4':
audio_settings += ['-acodec', 'libfaac'] audio_settings += ['-acodec', 'libvo_aacenc']
else: else:
audio_settings += ['-acodec', 'libvorbis'] audio_settings += ['-acodec', 'libvorbis']
else: else:
audio_settings = ['-an'] audio_settings = ['-an']
ffmpeg = FFMPEG2THEORA.replace('2theora', '') cmd = [AVCONV, '-y', '-i', video, '-threads', '4'] \
cmd = [ffmpeg, '-y', '-i', video, '-threads', '4'] \
+ audio_settings \ + audio_settings \
+ video_settings + video_settings
@ -226,14 +240,14 @@ def stream(video, target, profile, info):
else: else:
cmd += [target] cmd += [target]
print cmd #print cmd
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, p = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=open('/dev/null', 'w'), stdout=open('/dev/null', 'w'),
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)
p.communicate() p.communicate()
if format == 'mp4': if format == 'mp4':
cmd = ['qt-faststart', "%s.mp4" % target, target] cmd = ['qt-faststart', "%s.mp4" % target, target]
print cmd #print cmd
p = subprocess.Popen(cmd, stdin=subprocess.PIPE, p = subprocess.Popen(cmd, stdin=subprocess.PIPE,
stdout=open('/dev/null', 'w'), stdout=open('/dev/null', 'w'),
stderr=subprocess.STDOUT) stderr=subprocess.STDOUT)

View file

@ -609,6 +609,7 @@
"userLevels": ["guest", "member", "staff", "admin"], "userLevels": ["guest", "member", "staff", "admin"],
"video": { "video": {
"download": true, "download": true,
//supported formats: webm, mp4
"formats": ["webm"], "formats": ["webm"],
"previewRatio": 1.3333333333, "previewRatio": 1.3333333333,
//supported resolutions are //supported resolutions are

View file

@ -42,7 +42,8 @@ sudo vmbuilder vbox ubuntu --suite=precise \
--addpkg gstreamer0.10-plugins-good \ --addpkg gstreamer0.10-plugins-good \
--addpkg gstreamer0.10-plugins-bad \ --addpkg gstreamer0.10-plugins-bad \
--addpkg oxframe \ --addpkg oxframe \
--addpkg ffmpeg \ --addpkg libavcodec-extra-53 \
--addpkg libav-tools \
--addpkg ffmpeg2theora \ --addpkg ffmpeg2theora \
--execscript=$base/install.sh \ --execscript=$base/install.sh \
--firstboot=$base/firstboot.sh --firstboot=$base/firstboot.sh

View file

@ -4,12 +4,6 @@ apt-get -y install ipython ntp
add-apt-repository ppa:j/pandora add-apt-repository ppa:j/pandora
#ffmpeg installed as apt package
#wget http://firefogg.org/nightly/ffmpeg.linux -O /usr/local/bin/ffmpeg
#chmod 755 /usr/local/bin/ffmpeg
#wget http://firefogg.org/nightly/ffmpeg2theora.linux -O /usr/local/bin/ffmpeg2theora
#chmod 755 /usr/local/bin/ffmpeg2theora
#postgresql #postgresql
apt-get -y install postgresql postgresql-contrib apt-get -y install postgresql postgresql-contrib
sudo -u postgres createuser -S -D -R pandora sudo -u postgres createuser -S -D -R pandora