I've problem with vlc input!

258 views
Skip to first unread message

Abol

unread,
Jun 16, 2017, 6:44:13 AM6/16/17
to mmbtools
Hi,
2 weeks ago I was tested odr-audioenc with vlc as decoder successfully.
the type of input I used was fifo.

I have written a server in c code that reads an offline es1.aac file and sends it to a fifo file.
after that odr-audioenc can read this fifo.

it was ok, but after two weeks I can not pass the test again.
the terminal output for audio encoder is as below(after running the server):

a@a-pc:~/Desktop/dab/MyTest/Radio_ES_Logs$ odr-audioenc -l -v file://$PWD/es_fifo.aac -D -b 64 --sbr -o ppp.dabp
Welcome to ODR-AudioEnc v2.1.0, compiled at Jun 16 2017, 13:42:05
  http://opendigitalradio.org

Using 8 subchannels. AAC type: HE-AAC. channels=2, sample_rate=48000
AAC bitrate set to: 64000
DAB+ Encoding: framelen=1920 (7680B)
Initialising VLC...
You are using VLC with size_t size callbacks
[00007f4a2c00ba18] core stream error: cannot pre fill buffer
Start VLC thread
Starting encoding
VLC state is 7
Detected fault in VLC input!

terminate called without an active exception
Aborted (core dumped)


where is the problem?

I attached my fifo server codes and es1.aac used in it, can any body help me?

ES_server codes is as below: please help me to improve it, cause I'm not a professional.


#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <string.h>


#define INITIALIZE_TIMERS(num) struct timeval iTimer[num]
#define UPDATE_TIMER(num) gettimeofday(&iTimer[num], NULL)
#define CONV_TO_MS(num) (((double)iTimer[num].tv_sec*1000.0) + ((double)iTimer[num].tv_usec/1000.0))




int main(int argc, char* argv[])
{
    FILE
*fp;
    fp
= fopen("es1.aac","r");
   
if(fp==NULL){
    printf
("Could not open ES fiel\n");
   
return -1;    
   
}
   
char * buff;
    buff
= (char *) malloc(1<<20);

   
int rdcnt = fread (buff, sizeof(char), (1<<20), fp);
    fclose
(fp);
    printf
("ES file rdcnt = %d\n" , rdcnt );
   
if(rdcnt<=0)
   
return -1;

   
int fds;
   
char *myfifo = "./es_fifo.aac";
   
    pipe
(fds);
   
int ret = mkfifo(myfifo,0666);
   
if (ret == -1)
    printf
("Could not create fifo\n");

    fds
=open(myfifo,O_WRONLY | O_CREAT | O_TRUNC );


   
const int T_Step = 10;//ms
   
const int Samplerate = 32000;//kbps
   
const int PackSize = T_Step/1000.0 * Samplerate / 8;

   
    INITIALIZE_TIMERS
(2);
    UPDATE_TIMER
(0);// reference time
   
int TimeStep=0;
   
   
while(1)
   
//for(int ii=0;ii<100;ii++)
   
{
   
int TotalWrCnt=0;
   
while(TotalWrCnt<rdcnt){
        printf
("writing to fifo...");
       
int wrcnt = 0;
       
if(rdcnt - TotalWrCnt > PackSize)
            wrcnt
= write(fds, buff + TotalWrCnt, PackSize);
       
else
            wrcnt
= write(fds, buff + TotalWrCnt, rdcnt - TotalWrCnt);

        printf
("wrcnt = %d Total WrCnt = %d \n", wrcnt,TotalWrCnt);
       
if(wrcnt!=-1){
           
TotalWrCnt += wrcnt;
            printf
("wrcnt = %d TotalWrCnt = %d \n", wrcnt,TotalWrCnt);    
       
}
                UPDATE_TIMER
(1);
       
while(CONV_TO_MS(1)-CONV_TO_MS(0) - TimeStep < T_Step){
            usleep
(1000);
            UPDATE_TIMER
(1);
       
}
       
//printf("\n");
       
TimeStep = TimeStep + T_Step;    

   
}
   
}
       

    close
(fds);
    unlink
(myfifo);
   
return 0;
}




es1.aac
ES_fserver.c

Matthias Brändli

unread,
Jun 16, 2017, 7:12:36 AM6/16/17
to crc-mm...@googlegroups.com
Hi Abol,

I had a quick look through your code. A few remarks:

- I understand that you read up to 1MB from the es1.aac file, and you
loop the data at the output, with a rate limitation.

- 1<<20 is unreadable. Use 1024*1024 instead, then we immediately see
it's one MB.

- pipe(fds) is useless and wrong. The pipe function signature is
different! Please see the manpage. Also, please compile your code with
the option -Wall and fix all warnings!

- your timer is not accurate because you use gettimeofday and not
clock_gettime with the CLOCK_MONOTONIC clock. The best way to throttle
the rate of a program is to do what I do in the multiplexer simul://
output. I am currently using C++, but in earlier versions it was
implemented with clock_gettime [1]

- Regarding the if(rdcnt - TotalWrCnt > PackSize) condition: do you need
to properly take in account the smaller size of the last write in your
rate limiting? Because you're not doing it currently.

Hope this helps!

mpb

[1]
https://github.com/Opendigitalradio/ODR-DabMux/blob/b7cdca615db89454b0f742fe603f723ce5ed7c29/src/dabOutput/dabOutputSimul.cpp
> fp =fopen("es1.aac","r");
> while(CONV_TO_MS(1)-CONV_TO_MS(0)-TimeStep<T_Step){
> usleep(1000);
> UPDATE_TIMER(1);
> }
> //printf("\n");
> TimeStep=TimeStep+T_Step;
>
> }
> }
>
>
> close(fds);
> unlink(myfifo);
> return0;
> }
> |
>
>
>
>
> --
> You received this message because you are subscribed to the Google
> Groups "mmbtools" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to crc-mmbtools...@googlegroups.com
> <mailto:crc-mmbtools...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

Abol

unread,
Jun 16, 2017, 7:59:53 AM6/16/17
to mmbtools, matthias...@mpb.li
so thanks, I will try to do your guides.

Abol

unread,
Jun 16, 2017, 9:29:03 AM6/16/17
to mmbtools, matthias...@mpb.li

I removed pipe(fds) from my code .
considering no need to accurate rate limitation at this point, I tested again but problem exist yet.

consider that I can use cvlc with no problem by below commands in separate terminals:

./es_fserver
cvlc file://$PWD/es_fifo.aac

but using odr-audioenc causes the es_fserver to break down.
more debugging shows that es_fserver breaks down when reaches the line below


wrcnt = write(fds, buff + TotalWrCnt, PackSize);



I tried to using mkfifo from terminal and commented using mkfifo in ES_fserver.c but the result is same.

Matthias Brändli

unread,
Jun 16, 2017, 9:37:12 AM6/16/17
to crc-mm...@googlegroups.com
What do you mean with "break down" ?

I'd try to find a way to go SPI -> UDP -> VLC, I believe that would be
more robust than using files and fifos.

mpb

Abol

unread,
Jun 16, 2017, 10:22:41 AM6/16/17
to mmbtools, matthias...@mpb.li
break down:
when I run ./es_fserver in a terminal, it shows lines below and waits

a@a-pc:~/Desktop/dab/MyTest/Radio_ES_Logs$ ./es_fserver
ES file rdcnt = 246780



in another terminal I run odr-audioenc and it show the below error, and es_fserver stops immediately and comes up out with no messages


Auto Generated Inline Image 1
Auto Generated Inline Image 2

Abol

unread,
Jun 16, 2017, 10:26:07 AM6/16/17
to mmbtools, matthias...@mpb.li

SPI -> UDP -> VLC would be very helpfull,
thank u,

I googled to find a way to send data to vlc by udp but i could not to find any helpful thing.

Peter Whisker

unread,
Jun 16, 2017, 2:16:26 PM6/16/17
to crc-mm...@googlegroups.com
You can use a fifo. mpd can use a fifo to feed odr-aacenc. I think it supports AAC and mp3.
Peter

--
You received this message because you are subscribed to the Google Groups "mmbtools" group.
To unsubscribe from this group and stop receiving emails from it, send an email to crc-mmbtools+unsubscribe@googlegroups.com.

Abol

unread,
Jun 16, 2017, 9:55:37 PM6/16/17
to mmbtools

there is some points about this problem:

1) considering my last command:
$ odr-audioenc -l -v file://$PWD/es_fifo.aac -D -b 64 --sbr -o test.dabp
I think that vlc not treats as fifo(name pipe) for inputs of type file://... then it opens and closes the es_fifo.aac when it wants and this causes to es_fserver be crashed by calling write() function.

2) I found this page telling how to use fifos for vlc input but it didn`t work for me.

https://wiki.videolan.org/Uncommon_uses/



3) there is other type of input for vlc (stream://...) that can read from fifo but the output of this method has jumping on audio and I don`t want to use it
$ odr-audioenc -l -v stream://$PWD/es_fifo.aac -D -b 64 --sbr -o test.dabp

Auto Generated Inline Image 1

Peter Whisker

unread,
Jun 17, 2017, 12:36:10 AM6/17/17
to mmbtools
Hi

When I used a fifo with mpd I used the following command line:

odr-audioenc -L --audio-resampler=speex_resampler -L --speex-resampler-quality=8 -g -3 -i /tmp/audmpd.fifo -f raw -r 48000 -b 128 -D -p 24 -P /tmp/padmpd.fifo -o tcp://localhost:9099

In /etc/mpd.conf I had:
audio_output {
        type            "fifo"
        name            "my_fifo"
        path            "/tmp/audmpd.fifo"
}

mpd streams playlists or directories into the fifo and odr-audioenc encodes them. I can confirm that this worked.

Regards
Peter

Abol

unread,
Jun 17, 2017, 3:36:40 AM6/17/17
to mmbtools
I'm trying to understand this command, if I was wrong please correct it:
1) options "-L --audio-resampler=speex_resampler -L --speex-resampler-quality=8 -g -3" are for vlc, I think not important for my test.

2) option "-i /tmp/audmpd.fifo -f raw -r 48000" tells to audioenc that raw data of audio is coming with rate 48000 of type raw from /tmp/audmpd.fifo. I think in this command no vlc is used, data stream for only 1 audio signal is fed in this way and this raw data should be a "NOT ENCODED" audio. is it true??


3) how u used /etc/mpd.conf? in this command there is no reference to it?

Peter Whisker

unread,
Jun 17, 2017, 3:41:14 AM6/17/17
to crc-mm...@googlegroups.com
You are completely correct. I had added the VLC resampling settings by mistake.

You need to use the mpd music player daemon. It is controlled by mpc. It streams playlists or files to ALSA/Pulseaudio or to a fifo in raw format. You should find documentation on mpd/mpc quite readily.

Peter

Peter Whisker

unread,
Jun 17, 2017, 3:48:40 AM6/17/17
to crc-mm...@googlegroups.com

Peter Whisker

unread,
Jun 17, 2017, 4:03:18 AM6/17/17
to crc-mm...@googlegroups.com
I have also piped ffmpeg or mpg123 or opusdec raw into odr-audioenc sometimes through sox to get the best resampling.

Abol

unread,
Jun 17, 2017, 7:09:08 AM6/17/17
to mmbtools

I'm trying to do this work in another way. I decided to use vlc out of odr-audioenc.
I created a fifo and send vlc output to it, that can be read by odr-audioenc. perhaps It works currectly but when using odr-dabmux some other problems come up.

let me explain:
creating and using of fifo by vlc is done by below command. the output of vlc is a 2 channel 48k wav file is writing to AudioOut.wav fifo

rm ./AudioOut.wav
mkfifo ./AudioOut.wav
cvlc -I dummy ./es1.aac --sout "#transcode{vcodec=none,acodec=s16l,ab=128,channels=2,samplerate=48000}:duplicate{dst=file{dst=./AudioOut.wav,no-overwrite},dst=display}"
I have a configuration file for odr-dabmux that reads from ZMQ and writes on ZMQ by throttle "simul://" uncommented.
then odr-dabmod can read from ZMQ and write on a IQ file.
in this step I run below command to start mux, enc and mod:

in other terminal:
odr-dabmux 1prog_zizo.mux

in a other terminal:
odr-audioenc -l -i ./AudioOut.wav -f wav  -r 48000 -c 2 -b 64 -o tcp://localhost:9000 &
odr-dabmod mod-zifo.ini


the output of mux terminal show warnings and decoding IQ by welle shows errors on decode data.
output of mux is as below:

a@a-pc:~/Desktop/dab/MyTest/Radio_ES_Logs$ odr-dabmux 1prog_zizo.mux
Welcome to ODR-DabMux v1.2.1, compiled at May 22 2017, 13:37:39

Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012
Her Majesty the Queen in Right of Canada
(Communications Research Centre Canada) All rights reserved.

Copyright (C) 2016 Matthias P. Braendli
http://opendigitalradio.org

Input URLs supported:
 prbs udp file zmq
Inputs format supported:
 raw mpeg packet epm
Output URLs supported:
 file fifo udp tcp simul

ERROR Could not set real-time priority for thread:1
      ODR-DabMux v1.2.1 starting up
ZMQ socket tcp://*:9100
      No announcements defined in ensemble
      because No such node (announcements)
      No announcements defined in service srv-p1
WARN  Service short label undefined, truncating label Prog1
WARN  Component short label undefined, truncating label Prog1
WARN  Primary component comp-p1 has label set. Since V2.1.1 of the specification, only secondary components are allowed to have labels.
      --- Multiplex configuration ---
      Ensemble
       id:          0x4fff (20479)
       ecc:         0xec (236)
       label:       mmbtools
       short label: mmbtools
       (0xff00)
       mode:        1
       lto:         4.5 hours
       intl. table. 1
       No announcement clusters defined
       Linkage Sets
      --- Subchannels list ---
      Subchannel   sub-p1
       input
         URI:     tcp://*:9000
       type:       audio
       id:         0x18 (24)
       bitrate:    64
       protection: EEP 3-A
        option:    0
        level:     2
       SAD:        0
       size (CU):  48
      --- Services list ---
      Service       srv-p1
       label:       Prog1
       short label: Prog1
       (0xff00)
       id:            0x33 (51)
       pty:           0x0 (0)
       language:      0x0 (0)
       announcements: 0x0
       clusters:
      --- Components list ---
      Component     comp-p1
       service id:             0x33 (51)
       subchannel id:          0x18 (24)
       label:                  Prog1
       short label:            Prog1
       (0xff00)
       service component type: 0x3f (63)
       No app type defined
      --- Output list ---
      Output      0
        URI: zmq: tcp://
      Output      1
        URI: simul://
      Start loop
      inputZMQ sub-p1 input pre-buffering complete
WARN  inputZMQ sub-p1 input empty, re-enabling pre-buffering
      inputZMQ sub-p1 input pre-buffering complete
WARN  inputZMQ sub-p1 input empty, re-enabling pre-buffering
      inputZMQ sub-p1 input pre-buffering complete
WARN  inputZMQ sub-p1 input empty, re-enabling pre-buffering
      inputZMQ sub-p1 input pre-buffering complete
WARN  inputZMQ sub-p1 input empty, re-enabling pre-buffering
      inputZMQ sub-p1 input pre-buffering complete
WARN  inputZMQ sub-p1 input empty, re-enabling pre-buffering
      inputZMQ sub-p1 input pre-buffering complete
WARN  inputZMQ sub-p1 input empty, re-enabling pre-buffering
      inputZMQ sub-p1 input pre-buffering complete
WARN  inputZMQ sub-p1 input empty, re-enabling pre-buffering

      Max number of ETI frames reached: 2000
      exiting...
      ...done
a@a-pc:~/Desktop/dab/MyTest/Radio_ES_Logs$ ^C


thanks guys! for your helps.
Reply all
Reply to author
Forward
0 new messages