Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
update hook/downloader/transcoder/output handling to handle empty lists
Browse files Browse the repository at this point in the history
  • Loading branch information
chocolateboy committed Feb 20, 2011
1 parent 725bae2 commit d579f61
Show file tree
Hide file tree
Showing 11 changed files with 70 additions and 60 deletions.
42 changes: 26 additions & 16 deletions TODO.groovy
Expand Up @@ -234,30 +234,40 @@ class MyTranscoder extends Transcoder {

profile('Foo') {
pattern {
match { uri == 'http://...' }
match { uri == 'http://whatever' } // TODO: make uri an actual URI rather than a string
}

action {
// default
transcoder.id = FFMPEG // enum Transcoder { FFMPEG, MENCODER, VLC }
transcoder = new FFmpeg() // assigns default args
transcoder.args = "string -or -list"
trancoder.args = FFmpeg.args
transcoder.output = "string -or -list" // ffmpeg only: output options

// add a downloader
downloader.id = MENCODER
downloader.args = [ 'string', '-or', '-list' ]
dowloader.args.set('-foo': 'bar')
def mplayer = new MPlayer(uri)
mplayer.args = [ 'string', '-or', '-list' ]
mplayer.args.set([ '-foo': 'bar' ])
transcoder.downloader = mplayer
}
}

// maybe
transcoder = new MEncoder() // assigns default args
transcoder.args.whatever(...)
transcoder.output = ... // invalid (at compile-time with .gpp extension?) - only for ffmpeg!
// No need to expose $PMS. Just use PMS.get() as normal

// completely custom
// store the original URI: e.g. for mplayer.groovy

if (transcoder instanceof FFmpeg) {
// ...
}
}
}
if (originalUri.protocol == 'concat') { ... }

// bring back reject: e.g. for mplayer.groovy:

reject $URI: '^concat:'

// add a commit method which stops all further profile matching for this request

/*
image to video:
ffmpeg -r 24 -i http://ip:port/plugin/name/imdb_plot?id=42&fmt=png \
-vcodec mpeg2video -qscale 2 -vframes 1 transcoder.out
*/
36 changes: 18 additions & 18 deletions misc/conf/WEB.test.conf
@@ -1,18 +1,18 @@
videofeed.Web,ZDF=http://www.zdf.de/ZDFmediathek/rss/562?view=rss
videofeed.Web,3sat=http://www.3sat.de/mediathek/rss/mediathek_scobel.xml
videofeed.Web,3sat=http://www.3sat.de/mediathek/rss/mediathek_boerse.xml
videofeed.Web,3sat=http://www.3sat.de/mediathek/rss/mediathek_hitec.xml
videofeed.Web=http://day9tv.blip.tv/rss
videostream.Web,TV=Bloomberg TV,http://www.bloomberg.com/streams/video/LiveBTV200.asx
videostream.Web,TV=Bloomberg Live,mms://a627.l2479952251.c24799.g.lm.akamaistream.net/D/627/24799/v0001/reflector:52251,http://www.definedbymedia.com/images/logos/logos-bloombergtelevision.jpg
videostream.Web,TV=Bloomberg Live stream 2,mms://a536.l2479952400.c24799.g.lm.akamaistream.net/D/536/24799/v0001/reflector:52400,http://www.definedbymedia.com/images/logos/logos-bloombergtelevision.jpg
videostream.Web,TV=Bloomberg Live stream 3,mms://a1598.l2489858165.c24898.n.lm.akamaistream.net/D/1598/24898/v0001/reflector:58165,http://www.definedbymedia.com/images/logos/logos-bloombergtelevision.jpg
videostream.Web,TV=Bloomberg Live stream 4,mms://a1332.l2489859148.c24898.n.lm.akamaistream.net/D/1332/24898/v0001/reflector:59148,http://www.definedbymedia.com/images/logos/logos-bloombergtelevision.jpg
videofeed.Web,Eurogamer=http://rss.feedsportal.com/feed/eurogamer/eurogamer_tv
videofeed.Web,Gamestar=http://www.gamestar.de/videos/rss/videos.rss
videofeed.Web,Wimp=http://www.wimp.com/rss/
videofeed.Web,GiantBomb=http://pipes.yahoo.com/pipes/pipe.run?_id=cf668f0d78945d30144d7d48d5021edc&_render=rss
videofeed.Web,PCGames=http://videos.pcgames.de/rss/newest.php
videostream.Web,TV=Politiek 24,http://livestreams.omroep.nl/nos/politiek24-bb,http://assets.www.omroep.nl/system/files/2140/thumbnail/Politiek_24.jpg
videofeed.Web,WinFuture=http://rss.feedsportal.com/c/617/f/448481/index.rss
videofeed.Web,YouTube=http://gdata.youtube.com/feeds/base/users/freddiew/uploads?alt=rss&v=2&orderby=published
videofeed.Web,Test,ZDF=http://www.zdf.de/ZDFmediathek/rss/562?view=rss
videofeed.Web,Test,3sat=http://www.3sat.de/mediathek/rss/mediathek_scobel.xml
videofeed.Web,Test,3sat=http://www.3sat.de/mediathek/rss/mediathek_boerse.xml
videofeed.Web,Test,3sat=http://www.3sat.de/mediathek/rss/mediathek_hitec.xml
videofeed.Web,Test=http://day9tv.blip.tv/rss
videostream.Web,Test,TV=Bloomberg TV,http://www.bloomberg.com/streams/video/LiveBTV200.asx
videostream.Web,Test,TV=Bloomberg Live,mms://a627.l2479952251.c24799.g.lm.akamaistream.net/D/627/24799/v0001/reflector:52251,http://www.definedbymedia.com/images/logos/logos-bloombergtelevision.jpg
videostream.Web,Test,TV=Bloomberg Live stream 2,mms://a536.l2479952400.c24799.g.lm.akamaistream.net/D/536/24799/v0001/reflector:52400,http://www.definedbymedia.com/images/logos/logos-bloombergtelevision.jpg
videostream.Web,Test,TV=Bloomberg Live stream 3,mms://a1598.l2489858165.c24898.n.lm.akamaistream.net/D/1598/24898/v0001/reflector:58165,http://www.definedbymedia.com/images/logos/logos-bloombergtelevision.jpg
videostream.Web,Test,TV=Bloomberg Live stream 4,mms://a1332.l2489859148.c24898.n.lm.akamaistream.net/D/1332/24898/v0001/reflector:59148,http://www.definedbymedia.com/images/logos/logos-bloombergtelevision.jpg
videofeed.Web,Test,Eurogamer=http://rss.feedsportal.com/feed/eurogamer/eurogamer_tv
videofeed.Web,Test,Gamestar=http://www.gamestar.de/videos/rss/videos.rss
videofeed.Web,Test,Wimp=http://www.wimp.com/rss/
videofeed.Web,Test,GiantBomb=http://pipes.yahoo.com/pipes/pipe.run?_id=cf668f0d78945d30144d7d48d5021edc&_render=rss
videofeed.Web,Test,PCGames=http://videos.pcgames.de/rss/newest.php
videostream.Web,Test,TV=Politiek 24,http://livestreams.omroep.nl/nos/politiek24-bb,http://assets.www.omroep.nl/system/files/2140/thumbnail/Politiek_24.jpg
videofeed.Web,Test,WinFuture=http://rss.feedsportal.com/c/617/f/448481/index.rss
videofeed.Web,Test,YouTube=http://gdata.youtube.com/feeds/base/users/freddiew/uploads?alt=rss&v=2&orderby=published
22 changes: 11 additions & 11 deletions src/main/groovy/com/chocolatey/pmsencoder/PMSEncoder.groovy
Expand Up @@ -136,14 +136,14 @@ public class PMSEncoder extends MEncoderWebVideo implements LoggerMixin {
List<String> transcoderArgs = command.getTranscoder()
def newURI = quoteURI(newStash.get('$URI'))

if (hookArgs != null) {
if (hookArgs) {
processManager.handleHook(hookArgs)
}

// automagically add extra command-line options for the PMS-native downloaders/transformers
// and substitute the configured paths for 'MPLAYER', 'FFMPEG' &c.
// TODO: add support for GET_FLASH_VIDEOS, YOUTUBE_DL and RTMPDUMP "macros" (any others?)
if (downloaderArgs != null && downloaderArgs.size() > 0 && downloaderArgs[0] == 'MPLAYER') {
if (downloaderArgs && downloaderArgs[0] == 'MPLAYER') {
/*
plugin the input/output e.g. before:
Expand All @@ -158,11 +158,11 @@ public class PMSEncoder extends MEncoderWebVideo implements LoggerMixin {
downloaderArgs += [ '-dumpfile', downloaderOutputPath, newURI ]
}

if (transcoderArgs != null && transcoderArgs.size() > 0) {
if (transcoderArgs) {
def transcoder = transcoderArgs[0]

if (transcoder != null && transcoder in [ 'FFMPEG', 'MENCODER', 'MENCODER_MT' ]) {
def transcoderInput = (downloaderArgs == null) ? newURI : downloaderOutputPath
def transcoderInput = downloaderArgs ? downloaderOutputPath : newURI

if (transcoder == 'FFMPEG') {
/*
Expand All @@ -172,18 +172,18 @@ public class PMSEncoder extends MEncoderWebVideo implements LoggerMixin {
after (with downloader):
/path/to/ffmpeg -v 0 -y -threads nbcores -i $DOWNLOADER_OUT -sameq \
-target pal-dvd $TRANSCODER_OUT
/path/to/ffmpeg -v 0 -y -threads nbcores -i $DOWNLOADER_OUT \
-target pal-dvd -b 4096 $TRANSCODER_OUT
after (without downloader):
/path/to/ffmpeg -v 0 -y -threads nbcores -i $URI -sameq -target pal-dvd $TRANSCODER_OUT
/path/to/ffmpeg -v 0 -y -threads nbcores -i $URI -target pal-dvd -b 4096 $TRANSCODER_OUT
*/

transcoderArgs[0] = ffmpeg
transcoderArgs += [ '-i', transcoderInput ]
if (command.output != null) {
transcoderArgs += command.output // defaults to: -sameq -target pal-dvd
if (command.output) {
transcoderArgs += command.output // defaults to: -target pal-dvd -b 4096
}
transcoderArgs += [ transcoderOutputPath ]
} else { // mencoder
Expand All @@ -201,7 +201,7 @@ public class PMSEncoder extends MEncoderWebVideo implements LoggerMixin {
/path/to/mencoder -mencoder -options -o $TRANSCODER_OUT $URI
*/

transcoderArgs[0] = (transcoder == 'MENCODER' ? mencoder : mencoder_mt)
transcoderArgs[0] = transcoder == 'MENCODER' ? mencoder : mencoder_mt
transcoderArgs += [ '-o', transcoderOutputPath, transcoderInput ]
}
}
Expand All @@ -211,7 +211,7 @@ public class PMSEncoder extends MEncoderWebVideo implements LoggerMixin {
// http://stackoverflow.com/questions/4025222
def transcoderProcess = null

if (downloaderArgs != null) {
if (downloaderArgs) {
if (isWindows) {
transcoderProcess = processManager.handleDownloadWindows(downloaderArgs, transcoderArgs)
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/main/groovy/com/chocolatey/pmsencoder/Plugin.groovy
Expand Up @@ -144,7 +144,7 @@ public class Plugin implements ExternalListener, FileListener {
private void loadDefaultLogConfig() {
// XXX squashed bug - don't call this log4j.xml, as, by default,
// log4j attempts to load log4j.properties and log4j.xml automatically
def defaultLogConfig = this.getClass().getResource('/default_log4j.xml')
def defaultLogConfig = this.getClass().getResource('/log4j_default.xml')
info("loading built-in log4j config file: $defaultLogConfig")

try {
Expand Down
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions src/main/resources/scripts/BEGIN.groovy
@@ -1,5 +1,5 @@
begin {
// global variables available in all scripts; uncomment/adjust accordingly
// global variables available in all scripts; uncomment/adjust accordingly.
// a builtin version of this file with paths uncommented is loaded automatically
// so simply copy that and set the values that should be defined or overidden

Expand All @@ -10,7 +10,7 @@ begin {
'Version/4.0.4 Mobile/7B334b Safari/531.21.10'
SOPCAST_URI = 'http://127.0.0.1:8902/stream' // only used if SOPCAST is defined below

if ($PMS.get().isWindows()) {
if ($PMS.isWindows()) {
// GET_FLASH_VIDEOS = 'C:\\Perl\\Scripts\\get_flash_videos'
// HLS_PLAYER = 'C:\\Python\\bin\\hls-player''
// PERL = 'C:\\Perl\\bin\\perl'
Expand All @@ -24,7 +24,7 @@ begin {
// NOTIFY_SEND = '/usr/bin/notify-send'
// PERL = '/usr/bin/perl'
// PYTHON = '/usr/bin/python'
// SOPCAST = '/path/to/sopcast'
// SOPCAST = '/usr/bin/sopcast-server'
// YOUTUBE_DL = '/usr/bin/youtube-dl'
}
}
10 changes: 5 additions & 5 deletions src/main/resources/scripts/INIT.groovy
Expand Up @@ -13,7 +13,7 @@
init {
def nbcores = $PMS.getConfiguration().getNumberOfCpuCores()
// have to be completely silent on Windows as stdout is sent to the transcoder
def mplayerLogLevel = $PMS.get().isWindows() ? 'all=-1' : 'all=2'
def mplayerLogLevel = $PMS.isWindows() ? 'all=-1' : 'all=2'

/*
Matcher-level (global) lists of strings that provide provide useful default options
Expand All @@ -25,8 +25,8 @@ init {
$TRANSCODER = $FFMPEG:
$TRANSCODER = "ffmpeg -v 0 -y -threads nbcores -i ${$URI} -sameq -target pal-dvd $TRANSCODER_OUT"
$TRANSCODER = "ffmpeg -v 0 -y -threads nbcores -i $DOWNLOADER_OUT -sameq -target pal-dvd $TRANSCODER_OUT"
$TRANSCODER = "ffmpeg -v 0 -y -threads nbcores -i ${$URI} -target pal-dvd -b 4096 $TRANSCODER_OUT"
$TRANSCODER = "ffmpeg -v 0 -y -threads nbcores -i $DOWNLOADER_OUT -target pal-dvd -b 4096 $TRANSCODER_OUT"
$TRANSCODER = $MENCODER:
Expand All @@ -52,11 +52,11 @@ init {
// all four of these values are initialized to empty lists, so we're relying on the "is nonempty"
// meaning for these checks
if (!$FFMPEG)
$FFMPEG = "FFMPEG -v 0 -y -threads ${nbcores}"
$FFMPEG = "FFMPEG -v 0 -y -threads ${nbcores}" // -threads 0 doesn't work for all codecs - better to specify

// default ffmpeg output options
if (!$FFMPEG_OUT)
$FFMPEG_OUT = '-sameq -target pal-dvd'
$FFMPEG_OUT = '-target pal-dvd -b 4096'

// default mencoder transcode command
if (!$MENCODER) {
Expand Down
8 changes: 4 additions & 4 deletions src/main/resources/scripts/mplayer.groovy
Expand Up @@ -4,19 +4,19 @@ end {
match {
// http://www.ffmpeg.org/ffmpeg-doc.html#SEC33
!($PROTOCOL in [
'concat',
'file',
'gopher',
'http',
'pipe',
'rtmp',
'rtmpt',
'rtmpe',
'rtmpte',
'rtmps',
'rtmpt',
'rtmpte',
'rtp',
'tcp',
'udp',
'concat'
'udp'
])
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/scripts/screen_unix.groovy
Expand Up @@ -3,7 +3,7 @@
script {
profile ('Screen') {
pattern {
match { !$PMS.get().isWindows() && CVLC }
match { !$PMS.isWindows() && CVLC }
protocol 'screen'
}

Expand Down
2 changes: 1 addition & 1 deletion src/test/groovy/PMSEncoderTestCase.groovy
Expand Up @@ -15,7 +15,7 @@ abstract class PMSEncoderTestCase extends GroovyTestCase {
private URL defaultScript

void setUp() {
def log4jConfig = this.getClass().getResource('/test_log4j.xml')
def log4jConfig = this.getClass().getResource('/log4j_test.xml')
DOMConfigurator.configure(log4jConfig)

defaultScript = this.getClass().getResource('/DEFAULT.groovy')
Expand Down

0 comments on commit d579f61

Please sign in to comment.