Mot-clef: Netcat

Streaming video avec netcat et mencoder

septembre 28th, 2009

netcat & mencoder

Serveur Side

open_streaming.sh

#!/bin/bash

# 500 is acceptable for bitrate, 1000 gives very nice quality

BITRATE=500

MAX_XRES=640

MAX_YRES=480

LISTEN_PORT=443

# oac copy should work fine most of the time

#AUDIO="-oac mp3lame -lameopts preset=192"

AUDIO="-oac copy"

mkfifo "/tmp/maemo_stream-$$"

{ nc -q 0 -l -p $LISTEN_PORT < "/tmp/maemo_stream-$$"; killall -9 mencoder; rm -f "/tmp/maemo_stream-$$"; } &

mencoder -o "/tmp/maemo_stream-$$" $AUDIO -ovc lavc \

-lavcopts vcodec=mpeg4:vbitrate=${BITRATE}:aspect=${MAX_XRES}/${MAX_YRES}:mbd=2:trell:threads=2 \

-idx -zoom -vf-add dsize=${MAX_XRES}:${MAX_YRES}:2,scale \

-vf-add expand=${MAX_XRES}:${MAX_YRES}::::${MAX_XRES}/${MAX_YRES} -vf-add crop=${MAX_XRES}:${MAX_YRES} \

-ffourcc FMP4 "$1"

rm -f "/tmp/maemo_stream-$$"

Client Side

nc -q 0 hostname 443 | mplayer -fs -vo sdl -hardframedrop -cache 512 -cache-min 80 -

Tags: , , ,
Posted in App | No Comments »