Created
December 18, 2012 10:07
-
-
Save anonymous/4326815 to your computer and use it in GitHub Desktop.
Play Framework Iteratees + UNIX Pipe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
object CLI { | |
def apply(cmd: String): Enumeratee[Array[Byte], Array[Byte]] = ... | |
} | |
object Application extends Controller { | |
val videoSrc = "http://ftp.nluug.nl/pub/graphics/blender/demo/movies/Sintel.2010.720p.mkv" | |
def stream = Action { | |
var downloadStream = Concurrent.unicast[Array[Byte]]( channel => { | |
WS.url(videoSrc).get { header => | |
Iteratee.foreach[Array[Byte]](channel.push(_)) | |
} | |
}, () => ()) | |
val encoder = CLI("ffmpeg -i pipe:0 -vcodec mpeg4 -s qcif -f m4v -y pipe:1") | |
Ok.stream(downloadStream &> encoder). | |
withHeaders( (CONTENT_TYPE, "video/mpeg"), | |
(CACHE_CONTROL, "no-cache") ) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment