2019-10-09T22:38:42 hlubenowAhoi,
Ich würde gucken, ob "mplayer" den Stream von der Konsole aus eingegeben abspielen kann. Wenn ja, könnte man versuchen, mit der Option "-dumpstream" oder dergleichen zu speichern.
2019-10-10T10:53:02 PerlentaucherDie Frage ist, wie beende ich die Aufnahme nach x Sekunden. Der mplayer hat irgendwie keine solcher Begrenzungsparameter.
QuoteBEISPIEL:
-endpos 56
Encodiere nur 56 Sekunden.
-endpos 01:10:00
Encodiere nur 1 Stunde 10 Minuten.
1 2 3 4 5 6 7 8
use IO::Socket; my $s = IO::Socket::INET->new("rolfrost.de:80") or die $@; $s->print(qq(GET / HTTP/1.0 Host: rolfrost.de )); print while <$s>;
2019-10-10T06:06:19 rostiWenn es nur darum geht den Stream zu speichern:
Mach ein Socket auf, sende einen HTTP-Request-Header, und lese dann daraus solange wie Du willst.
Code (perl): (dl )1 2 3 4 5 6use IO::Socket; my $s = IO::Socket::INET->new("rolfrost.de:80") or die $@; $s->print(qq(GET / HTTP/1.0 Host: rolfrost.de )); print while <$s>;
2019-10-10T09:40:11 rostiWas spricht denn gegen ein dediziertes Programm was den Stream speichert? Und mit nohup ... könntest Du ein Solches sogar auf einen anderen Host laufen lassen bis es fertig ist.
PS: Und nice gibts ja auch noch.
1
2
3
4
5
6
7
8
9
10
11
12
my $RecordingTime = 5;
my $WebCamUrl = "http://192.168.178.66/bha-api/video.cgi?sessionid=pYSFU7KtdTu45emxoP05UeIj3rlpVkbqkBVaB5pqSwyUhxXtJmV1HNWx2BOpx";
my $VideoFilePath = "/home/pi/Documents/Video/201910101435-Video.mjpeg";
my $ShellCommand = "nohup (sleep " . $RecordingTime . "; echo quit) | mplayer " . $WebCamUrl . " -dumpstream –dumpfile " . $VideoFilePath;
eval {
system($ShellCommand) or die "Could not execute" . $ShellCommand;
};
### If error message appeared
if ( $@ ) {
$ErrorMessage = $@;
}
1
2
3
4
5
6
7
8
9
10
11
12
my $duration = 5;
my $CommandURL = "http://192.168.178.66/bha-api/video.cgi?sessionid=pYSFU7KtdTu45emxoP05UeIj3rlpVkbqkBVaB5pqSwyUhxXtJmV1HNWx2BOpx";
my $VideoFilePath = "/home/pi/Documents/Video/201910101435-Video.mjpeg";
### Create command for shell
my $ShellCommand = "timeout " . $duration . " ffmpeg -hide_banner -loglevel panic -re -i '" . $CommandURL . "' -filter:v setpts=4.0*PTS -y " . $VideoFilePath . " &";
eval {
system($ShellCommand) or die "Could not execute" . $ShellCommand . " ". $@;
};
#### Ab hier jede menge weiterer Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#!/usr/bin/perl use strict; use warnings; use IO::Socket; use IO::File; my $host = "149.210.139.172"; my $port = "8200"; my $CRLF = "\r\n"; my $file = "radio19.mp3"; my $size = 300000; # ca 14 Sekunden # HTTP Request an Radio 19 International my $s = IO::Socket::INET->new("$host:$port") or die $@; $s->print("GET /standard?icy=http HTTP/1.0$CRLF"); $s->print("Host: $host$CRLF$CRLF"); # mp3 Datei anlegen my $fh = IO::File->new; $fh->open($file, O_CREAT|O_BINARY|O_RDWR|O_TRUNC) or die $!; # Socket lesen und mp3 Datei beschreiben my $c = 0; while( $c += read($s, my $buffer, 1) ){ $fh->print($buffer); last if $c > $size; } # # http://149.210.139.172:8200/standard?icy=http