AW: Dreambox stream über Debian (VLC) ins Internet
Achso und sobald ich versuche die Audiospur in MP3 oder MP4a zu kompremieren sagt vlc mir das der codec fehlt. Kann mann irgendwo den ffmpeg (inkl. mp3 codec) laden?
guck mal hier:
Sie müssen registriert sein, um Links zu sehen.
/edit: hab gerade gemerkt das es nicht mehr "vlc:quit" ist sondern:
mit deinen SOUT einstellungen @ Biland kriege ich es aber nicht zum laufen, hast du noch irgendwelche anderen pakete dafür installiert?
ich hab auch ein kleines php script geschrieben um ein stream zu starten:
beachten sollte man aber, das man dadurch zumindest betrachtend zugriff auf das komplette dateisystem des servers kriegt, da man über eine eingabemaske das zu streamende file auswählen kann/muss.
also erst gibt man den pfad ein und klickt auf Browse. dann wählt man das file und klickt auf "Stream It". daraufhin wird der stream gestartet und der output angezeigt sowie gescrollt..
da man also auch " / " eingeben könnte, sähe man dann alle dateien und verzeichnisse im wurzelverzeichnis, genauso eben bei der eingabe von /root/ usw.. man kann die dateien aber nicht betrachten, nur zum abspielen mit vlc selektieren..
habe es auch noch ein bischen angepasst sodass man auf verzeichnisse drauf klicken kann und er dann darein wechselt.
ausserdem kann man am anfang des scripts einen pfad ($PathToFile) voreinstellen in dem man sich sofort befindet und auch nicht herraus kann.
und wenn man $ValidFileEndings setzt, zeigt er auch nur noch die dateien an die auf zum beispiel ".rar" oder ".mpeg" enden..
den geöffneten browser mit stream.php kann man ebenfals schliesen, da sieht man beim nächsten aufruf dann aber nur einen "Stop Stream!" button aber nicht was gestreamt wird usw, vlc läuft aber trotzdem im hintergrund solange bis er fertig gestreamt hat oder man auf besagten Stop button drückt..
mehrere streams auf einmal funktioniert aber auch nicht! weiss auch nicht ob ich das überhaupt einbauen werde.. man muss also auf jedenfall den einen erstmal stoppen
ich empfehle ein untypisches verzeichnis im www-root anzulegen:
/var/www/.stream/
da rein müssen 2 files kopiert werden:
-> Stream.sh
Code:
#!/bin/bash
BINDIP="0.0.0.0"
STREAMPORT="7777"
IFACEPORT="7977"
DEBUGLVL=1
LN="$BINDIP:$STREAMPORT"
OPTIONS="--verbose $DEBUGLVL -I dummy"
if [ -n "$IFACEPORT" ]; then
OPTIONS+=" --extraintf=http --http-host $BINDIP --http-port $IFACEPORT"
fi
#SOUT="#transcode{venc=x264{subme=5,ref=3,bframes=16,b-adapt=1,bpyramid=none,weightp=0},vcodec=h264,vb=400,width=420,deinterlace,threads=2}:std{access=http,mux=asf,dst=$LN}"
SOUT="#transcode{vb=400,threads=2}:standard{access=http,mux=asf,dst=$LN}"
if [ -z "$1" ]; then
echo "Usage: $0 <files2stream>"
exit 0
else
STREAMFILES=$1
fi
chown www-data:www-data $PWD
vlc $OPTIONS --sout $SOUT $STREAMFILES vlc://quit &
[ $? -gt 0 ] && echo "ERROR: $?" || echo $! > .pid.stream
exit 0
-> stream.php
Code:
<?php
$STREAMscript = "/var/www/.stream/Stream.sh";
$PathToFile = "/mnt/windowsfreigabe";
$ValidFileEndings = "rar avi mpg mpeg mkv wmv mp3 wav";
//----------------------------------------------------------------------
//v0.2 .. (c) ipc.pebkac.at
//----------------------------------------------------------------------
if (!isset($PathToFile) OR empty($PathToFile)) {
$PathToFile = isset($_POST["pathtofile"]) ? $_POST["pathtofile"] : "";
}
$FILES = isset($_POST["FILES"]) ? $_POST["FILES"] : "";
$StartStream = isset($_POST["StreamIT"]) ? $_POST["StreamIT"] : "";
$StopStream = isset($_POST["StopStream"]) ? $_POST["StopStream"] : "";
if (isset($_GET["pathtofile"])) $PathToFile = isset($_GET["pathtofile"]) ? $_GET["pathtofile"] : "";
#ini_set("max_execution_time", "240");
ob_implicit_flush(true);
@ob_end_flush();
?>
<!DOCTYPE html>
<html>
<head>
<title>VLC Streamer</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="robots" content="DISALLOW">
<script language="JavaScript">
function scrollNow() { scrollTo(1, 100000); setTimeout("scrollTo(1, 100000)", 10); }
</script>
<script>
function select(a) {
var theForm = document.streamform;
for (i=0; i<theForm.elements.length; i++) {
if (theForm.elements[i].name=='FILES[]')
theForm.elements[i].checked = a;
}
}
</script>
<style>
.tab {
font-family: verdana, arial, helvetica, verdana, tahoma, sans-serif;
font-size:10px;
color:#008b8b;
font-weight:normal;
}
</style>
</head>
<body>
<p><a href="<?php echo $_SERVER['PHP_SELF']; ?>">Home</a></p>
<b>Enter Path to File:</b>
<form name="pathform" action="" method="POST">
<input size="90" type="text" name="pathtofile" placeholder="../path/to/file/.." value="<?php echo $PathToFile; ?>">
<input style="font-weight:bold;" type="submit" name="Browse" value="Browse"/>
</form>
<?php
if (isset($ValidFileEndings) AND !empty($ValidFileEndings)) { $ValidFileEndings = explode(" ",$ValidFileEndings); }
if (!empty($PathToFile)) {
echo "<br/><b>Select Files to Stream:<b><br/>\n";
$verzeichnisinhalt = array_slice(scanDir($PathToFile), 2);
$c=0;
echo "<form name='streamform' action='' method='POST'>\n";
echo "<table border='0' cellspacing='1' cellpadding='1'>\n";
foreach ($verzeichnisinhalt AS $file) {
if (isset($ValidFileEndings) AND !empty($ValidFileEndings) AND !is_dir("$PathToFile/$file")) {
$VALID=0;
foreach ($ValidFileEndings AS $VFE) {
if (strstr($file,".$VFE")) { $VALID=1; }
}
if ($VALID === 0) { continue; }
}
echo "<tr>\n";
if (is_dir("$PathToFile/$file")) {
echo "<td> </td>\n";
echo "<td> <a href='".$_SERVER['PHP_SELF']."?pathtofile=".$PathToFile."/".$file."'>".$file."</a></td>\n";
} else {
echo "<td><input id='checkbox-".$c."' type='checkbox' name='FILES[]' value='".$PathToFile."/".$file."'/></td>";
echo "<td> ".$file."</td>\n";
}
echo "</tr>\n";
$c++;
}
echo "</table>\n";
echo "<p><b class='tab'><a href='javascript:select(1)'>Check</a> / <a href='javascript:select(0)'>Uncheck</a> all</b></p>";
echo "<br/>\n";
echo "<input style='font-weight:bold;' type='submit' name='StreamIT' value='Stream It!'/>\n";
echo "</form>\n";
echo "<br/>\n";
}
if (!empty($StartStream)) {
if (empty($FILES)) { echo "<b style='color:firebrick;'>ERROR: No Files selected!</b>"; exit(); }
ReadBashScript();
$STREAMp = popen("bash $STREAMscript \"".implode(" ",$FILES)."\" 2>&1", 'rb');
echo "<b style='color:limegreen;'>Streaming files:</b><br/>\n";
echo "<b>".implode("<br/>",$FILES)."<b><br/>\n";
if (isset($STREAMPORT) AND !empty($STREAMPORT)) {
$StreamURL = "http://".$_SERVER['SERVER_ADDR'].":".$STREAMPORT."";
echo "<b>Stream URL: <a href='".$StreamURL."'>$StreamURL</a></b><br/>";
}
if (isset($IFACEPORT) AND !empty($IFACEPORT)) {
$StreamIURL = "http://".$_SERVER['SERVER_ADDR'].":".$IFACEPORT."";
echo "<b>Stream Interface: <a href='".$StreamIURL."' target='_blank'>$StreamIURL</a></b><br/>";
}
echo "<p><form name='streamform' action='' method='POST'>\n";
echo "<input style='font-weight:bold;' type='submit' name='StopStream' value='Stop Stream!'/>\n";
echo "</form></p>\n";
while (!feof($STREAMp)) {
$line = stream_get_line($STREAMp,99999,"\n");
if (empty($line)) { continue; }
$fontcolour="#000000";
if (preg_match("/error/i",$line)) { $fontcolour="#FF0000"; }
#echo ("<font face='Arial, Helvetica, sans-serif' size='1' color='".$fontcolour."'>".str_replace(" "," ",$line)."</font><br/>\n");
echo ("<font color='".$fontcolour."'>".str_replace(" "," ",$line)."</font><br/>\n");
echo "<script language='JavaScript'>scrollNow();</script>\n";
flush();
}
if (isset($STREAMp) AND feof($STREAMp)) pclose($STREAMp);
}
if (!empty($StopStream)) {
$PID = exec("cat .pid.stream");
$KILL = exec("kill -9 ".$PID."");
$KILL = exec("killall -9 vlc");
$KILL = exec("rm -f .pid.stream");
}
if (file_exists(".pid.stream")) {
echo "<br/><form name='streamform' action='' method='POST'>\n";
echo "<input style='font-weight:bold;' type='submit' name='StopStream' value='Stop Stream!'/>\n";
echo "</form>\n";
}
// Auslesen des $STREAMscript
// nur variablen in " " werden ausgelesen
function ReadBashScript() {
global $STREAMscript;
$handle=fopen("$STREAMscript","r");
while($input = fgets($handle, 1024)) {
preg_match("/^(.+)=\"(.*)\"/",trim($input),$find);
if (isset($find[1]) AND !empty($find[1])) {
if (!preg_match("/^\[|^.+\[\".+\"\]/",trim($find[1]))) {
global $$find[1];
if (empty($find[2])) { $find[2]='""'; }
$$find[1] = $find[2];
}
}
}
@fclose($handle);
}
?>
</body>
</html>
und danach dem apache2 benutzer www-data die rechte auf diese dateien geben:
chown -R www-data:www-data /var/www/.stream
das verzeichnis sollte man danach auch mit htaccess vor fremden zugriff schützen:
-> /var/www/.stream/.htaccess
Code:
AuthName "Secret Place"
AuthType Basic
Require valid-user
AuthUserFile /var/www/.stream/.htpasswd
AddDefaultCharset ISO-8859-1
<Files ~ "^.(htaccess|htpasswd)$">
deny from all
</Files>
Code:
htpasswd -cb /var/www/.stream/.htpasswd '[COLOR=#ff0000]USER[/COLOR]' '[COLOR=#FF0000]PWD[/COLOR]'
USER und
PWD mit den zugangsdaten ersetzen (die ' sorgen dafür das auch sonderzeichen benutzt werden können)
ich hoffe die schlichtheit stört nicht, primär sollte es erstmal einfach nur funktionieren
PS: für die jenigen die jetzt erst hierrauf stossen in post#6 steht wie man vlc installieren muss damit das funktioniert