rtl_fm_streamer
rtl_fm_streamer copied to clipboard
LIMIT RECORDING
From @fabri8bit on November 27, 2016 17:4
if open with VLC the url because the end duration is "-12:25:30"?
I use ffmpeg for recording but after "06:12:49" is timer block. Because?
I can recording all day long?
Copied from original issue: AlbrechtL/rtl_dab_streamer#1
The problem is that the WAV-stream header is not set correctly. But it should be possible to stream all day long.
How should you set header? you can convert mp3 to solve the problem? you can release an update?
To fix this the WAV-header inside rtl_fm_streamer.c has to be fixed. Unfortunately, there are no plans to fix this. Even an MP3 stream is not planed. But it should be possible to use ffmpeg to convert the WAV-stream into a MP3-stream.
If you like you can fix the issue and send me an pull request.
I tried it with the library lame:
static void * output_thread_fn(void *arg) { ssize_t SentNum = 0; struct output_state *s = arg; char buf[DEFAULT_BUF_LENGTH]; char input[DEFAULT_BUF_LENGTH]; uint32_t len = DEFAULT_BUF_LENGTH;
lame_t lame;
int endian = 0;
char output_buf[DEFAULT_BUF_LENGTH];
int nb_read = 0;
int nb_write = 0;
int nb_total = 0;
bool send_header=false;
lame = lame_init();
lame_set_num_channels(lame, 1);
lame_set_in_samplerate(lame, 44100);
//lame_set_brate(lame, 8);
lame_set_mode(lame, MONO);
lame_set_quality(lame, 5);
lame_set_VBR(lame, vbr_default);
lame_set_decode_only(lame,1);
lame_set_write_id3tag_automatic(lame, 0);
lame_init_params(lame);
lame_print_config(lame);
while (!do_exit) {
while (output_buffer_size < len) {
//safe_cond_wait(&s->ready, &s->ready_m);
if (do_exit) return 0;
usleep(6000);
}
pthread_rwlock_rdlock(&s->rw);
memcpy(buf, output_buffer + output_buffer_rpos, len);
output_buffer_rpos += len;
output_buffer_size -= len;
if (output_buffer_rpos >= output_buffer_size_max) output_buffer_rpos = 0;
pthread_rwlock_unlock(&s->rw);
if (isStartStream) {
memset(input, 0, sizeof(input));
memcpy(input, buf, DEFAULT_BUF_LENGTH);
lame_encode_buffer(lame, input, NULL, len, output_buf, len);
SentNum = send(ConnectionDesc, output_buf, sizeof(output_buf), MSG_NOSIGNAL);
if (SentNum < 0) {
fprintf(stderr, "Error sending stream: \"%s\". Close the connection!\n", strerror(errno));
// Close connection
close_connection(ConnectionDesc);
isStartStream = false;
// Stop reading samples from dongle
rtlsdr_cancel_async(dongle.dev);
pthread_join(dongle.thread, NULL);
isReading = false;
}
}
}
return 0;
}
- Problem duration FIX.
but the sound every 2 second is noise. The problem may be the frame header to each sending tcp?
[ buf -> encode - send - a part audio is ok + zzzzzzzz noise ] .... [ buf -> encode - send - a part audio is ok + zzzzzzzz noise ]
you think you help me?
Thanks