Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: recording from stream rather than sound card #291

Open
GroundTruthNZ opened this issue Sep 9, 2017 · 10 comments

Comments

@GroundTruthNZ
Copy link

commented Sep 9, 2017

It would be great to see this as an option in Libretime and as a way getting it working fully in AWS or other virtualisation. At the moment, if you need to record shows you end up having to host the the Libretime server actually in the studio.

I got this sort of working in Airtime 2.5.2 see hack by replacing ecasound with sox to record a stream and push it to the master source at the same time. I better option might be to record from the master or show source directly?

@hairmare

This comment has been minimized.

Copy link
Member

commented Sep 9, 2017

Currently the record from line in feature is not working 100% as reported in #42. Having it also record from the stream is certainly a feature that would benefit lots of stations.

Liquidsoap has file recording facilities as well. They may be the better option since less re-encoding needs to be done that way. I did have some buffering issues when I was playing with those in a different piece of software, those may have stemmed from my setup being underspeced.

This should probably be implemented in a way that makes sense for both the line-in and stream-in case. There might also be some overlap with some stations 24/7 recoding needs. Where I'm at we need to keep such recordings as mandated by the broadcast authority. We are currently opening those archives up to the members of our community station and I have been considering re-uploading (or watching) those same recordings in LibreTime to be able to replay them.

The line-in recording feature is currently missing is a way to get the shows linked to the original show. during import. This would be needed for stream recordings as well. Originally this was handled by media-monitor and never ported to analyzer.

@xabispacebiker

This comment has been minimized.

Copy link

commented Oct 4, 2017

I think this is not needed as you can do that right now (as soon as the line in feature works 100% ).

You'd just need to activate ALSA sound card and do a loop back from the output of your soundcard to the input (you may connect a physical cable too.. but why when you can use the loopback feature?)

http://www.sabi.co.uk/Notes/linuxSoundALSA.html#tasksRecordPlay

I want to achieve something similar so I'll do some test. I'll let you know as soon as I investigate a bit more about it.

@GroundTruthNZ

This comment has been minimized.

Copy link
Author

commented Oct 16, 2017

I'm not sure I understand this @xabispacebiker. What if you don't have a sound card? Our current Airtime setup uses a Raspberry Pi which has a doesn't have a good sound card - so we record off a stream instead. Which also means that you can record from any source anywhere...

@hairmare In case it is of interest I'm attaching the script we use to record everything that comes out of the station (both live and scheduled). It might be useful to cover your legal requirements...

radiobackup.txt

@GroundTruthNZ

This comment has been minimized.

Copy link
Author

commented Oct 16, 2017

(run from cron)
0 * * * * /usr/loca/bin/radiobackup.sh http://airtime.address.com:8000/airtime.ogg >> /dev/null 2>&1

@hairmare

This comment has been minimized.

Copy link
Member

commented Oct 17, 2017

@GroundTruthNZ Thanks for posting the script, nice streamwripper wrapper :)

At our station we recently rolled out a nice rails app to manage our archive. It covers both our legal and comfort use cases, under the hood it uses some hacky liquidsoap scripts for 24x7 recording. It depends on LibreTime's database as source of truth regarding the program grid.

The current (broken) recording solution is more about recording individual shows for rebroadcast. What I beleive is really needed to get some progress going into the pre-recording situation (being it line-in or streams) is some proper docs on the REST upload API that make it easy to identify what's missing in the MVCs modules/rest parts so the recording from wherever can be uploaded as such, this would also be the api the ecasound recordings take which why #42 needs tagging on this issue.

@ronstep

This comment has been minimized.

Copy link

commented Oct 17, 2017

We currently use curl --output on a cron job

regards and respect to all

@JohnnyC1951

This comment has been minimized.

Copy link

commented Apr 9, 2018

It might be possible to avoid the multiple files/sox step by using a substitute for curl which is also very kind to memory usage. I will try it out as a client has a current need for this and report back.

@JohnnyC1951

This comment has been minimized.

Copy link

commented Apr 9, 2018

`<?php
/* Curl-less, Streamripper-less, ffmpeg & mplayer-less, low memory use, simple native php CLI script which can be called from a cron job. It avoids the re-encoding stuff that many solutions use, so loss of fidelity and less resource load on the server. It also tries to recover from stream breaks. Questions/queries to John Chewter info@deprogrammedradio.com

Syntax in bash (cron) is: php /your/path/ripstream.php yourfilename minutes

NB. No spaces in filename are permitted. Minutes can have partial minutes in decimal format, so 45.5 minutes would be 45 mins and 30 seconds. */

$streamurl = 'http://x-pedia.org:8000/deprogrammedradio.mp3';
$savepath = dirname(FILE).'/downloads';

$got_commands = true;

if (isset($argv[0])){
$filename = $argv[1];
} else {
$got_commands = false;
echo "Error - No file name specified.\n";
}

if (isset($argv[1])){
$myminutes = $argv[2];
} else {
$got_commands = false;
echo "Error - No minutes specified.\n";
}

if (isset($argv[3])){
echo "Oops! Too many arguements. Have you spaces in your filename?\n";
$got_commands = false;
}

if ($got_commands == false) {
echo "Syntax in bash (cron) is: php /your/path/ripstream.php yourfilename minutes\n";
echo "NB. No spaces in filename are permitted.\n";
echo "Minutes can have partial minutes in decimal format, so 45.5 minutes would be 45 mins and 30 seconds.\n\n";
exit(1);
}

function downloadStream($streamurl, $filename, $savepath, $myminutes) {
$retry = 0;
$gotFile = false;
$max_time = 60 * $myminutes;
$end_time = microtime(true) + $max_time;
$blocksize = 1024 * 8;
$current_time = microtime(true);
while ((microtime() < $end_time) && ($retry < 10)) {
if ($streamhandle = fopen ($streamurl, "rb")){
if ($streamhandle) {
$show_filename = $savepath.'/'.date('m-d-Y_hia').'-'.$filename;
$newf = fopen ($show_filename, "wb");
if ($newf){
while($current_time < $end_time) {
$current_time = microtime(true);
fwrite($newf, fread($streamhandle, $blocksize ), $blocksize );
}
}
}
if ($newf) {
fclose($newf);
$gotFile = true;
}
$t = 100;
break;
} else {
$t=$t+1;
sleep(2);
}
if ($streamhandle) { fclose($streamhandle); }
}
if ($streamhandle) { fclose($streamhandle); }
return $gotFile;
}

if (!file_exists($savepath)) {
mkdir($savepath);
}

if (downloadStream($streamurl, $filename, $savepath, $myminutes)){
echo "Download OK";
exit(0);
} else {
echo "Download Failed";
exit(1);
}
?>
`

@GroundTruthNZ

This comment has been minimized.

Copy link
Author

commented Jul 19, 2018

Nice one @JohnnyC1951! Something like this could presumably also be used in the recorder.py script (rather than ecasound) to record a stream for rebroadcasting...

@aj2199

This comment has been minimized.

Copy link

commented Sep 17, 2019

We would back this feature as well at our station, We are now looking to move away from SAM Cloud because of the cost and I'm currently going with LT however this feature would make life 1000's times easier as we repeat almost every show we have.

Cheers
AJ from RW

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants
You can’t perform that action at this time.