How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
Hi All ,

Could any one please let me know how could we know the "PERIOD-SIZE" for an alsasrc plugin.
"PERIOD-SIZE" would affect the "LATENCY"  ( along with affect "BUFFER-TIME" & "BUFFER-SIZE " )

This factor seems to be important when in case when we have problem of audio - video sync issue..
I have faced audio - video sync problem using VIDEOTESTSRC + ALSA +AVIMUX.
This problem i was able to improve , by some random trail and error methord along with some sample configuration.

My question is how to determine "PERIOD-SIZE"  so that we get proper latency value for alsa-src.


Thanks .

Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Nicolas Dufresne-3
Le lundi 18 janvier 2016 à 01:33 -0800, Ashish Kumar Mishra a écrit :

> Could any one please let me know how could we know the "PERIOD-SIZE"
> for an
> alsasrc plugin. 
> "PERIOD-SIZE" would affect the "LATENCY"  ( along with affect
> "BUFFER-TIME"
> & "BUFFER-SIZE " )
>
> This factor seems to be important when in case when we have problem
> of audio
> - video sync issue.. 
> I have faced audio - video sync problem using VIDEOTESTSRC + ALSA
> +AVIMUX. 
> This problem i was able to improve , by some random trail and error
> methord
> along with some sample configuration. 
>
> My question is how to determine "PERIOD-SIZE"  so that we get proper
> latency
> value for alsa-src.
I believe you are looking for "latency-time" property. It controls the
size of a buffer (in duration) and define the capture latency as you
need to capture for that amount of time before you have a complete
buffer you can push forward. "buffer-time" property controls the size
of the ringbuffer, hence should be larger then the "latency-time". It
controls how much time alsasrc can accumulate data while pushing
downstream. It's also that time the element can spend pushing data
before data start being lost. It's defined as the maximum latency in
GStreamer. Careful, since those same two properties don't mean exactly
the same thing in alsasink.

Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
Hi Nicolas ,

Thanks for replying.

Reading http://www.alsa-project.org/main/index.php/FramesPeriods , my understanding was:-
Period-size  ( This is decided first ) -----> Latency Time -----> Buffer Time
                                                        -----> Buffer-size .

Reading comment above , it seems the actual order is :-
Latency Time ( This is decided first ) -----> Buffer Time
                                                           -----> Period-size -----> Buffer-size.


Lets say i have an Alsasrc [ for audio ] and might use different plugin for video src
[ say Filesrc , Videotestsrc , Camera , DVI chip etc ] .

Case_1) How could we determine single value of latency for alsa plugin which could cater sync with any of above mentioned video src.
    or
Case_2) The latency of alsasrc needs to be calculated separatley considering individual videosrc being used
( This is what i think should be the approach )


Thanks ,
Ashish Kumar Mishra.

Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Nicolas Dufresne-3
Le lundi 18 janvier 2016 à 21:44 -0800, Ashish Kumar Mishra a écrit :

> Lets say i have an Alsasrc [ for audio ] and might use different
> plugin for
> video src 
> [ say Filesrc , Videotestsrc , Camera , DVI chip etc ] . 
>
> Case_1) How could we determine *single value of latency* for alsa
> plugin
> which could cater sync with any of above mentioned video src. 
>     or 
> Case_2) The latency of alsasrc needs to be calculated separatley
> considering
> individual videosrc being used 
> ( This is what i think should be the approach )

I don't really understand this talk I'm sorry. Maybe it would be easier
for us to explain what issue you are having with GStreamer in this
regard.

cheers,
Nicolas

p.s. the latency mechanism internal to gstreamer is explained here:
http://cgit.freedesktop.org/gstreamer/gstreamer/tree/docs/design/part-
latency.txt
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
This post was updated on .
Let me explain  

My pipeline is as mentioned below
filesrc ->  qtdemux -> avdec_h264  -> videoconvert -> timeoverlay ->  q1      
                                                                                                                     -> avimux -> filesink
                                                             audiotestsrc -> capsfilter -> q2

1) I am building an audio + video splitter . Currently using Filesrc as video source & Alsasrc for audio.
    When i play the recorded file in VLC. ( in seconds ) , below was the problem i faced
    1)  t=0  to t= 2
         The video is played back properly and VLC seek (BLUE seek )  bar is also progressing.
   
   2)  t=2 to t= 4/5
         No video is played rather its like FREEZED / PAUSE .
         The seek bar  ( Orange seek ) progress till t=4/5 . Please note that during this time VLC seek bar
         is ORANGE and is progressing. But the video is not played.
 
  3)  t=4/5
      The VLC orange seek bar re-positions itself to t=2. Seek bar turns BLUE and video & seek bar is played
      properly.
  This behavior continues for complete file.


2) Now to address this problem , some pointers i got was to look at the buffer time-stamp ( discussed as problem )
http://gstreamer-devel.966125.n4.nabble.com/quot-do-timestamp-quot-leds-to-no-moov-atom-within-the-first-10-MB-problem-in-pipeline-td4675118.html

3) It then i started looking for the buffer size & latency of alsasrc.
    With random trail and error i am able to improve the sync issue , hence wanted to understand the proper way of :-
        How to calculate the required value of "latency-time" parameter for alsasrc ?
        or
        How to calculate "period-size"of latency parameter for alsasrc ( as period-size will directly affect the latency-time ) ?

Please note that my aim is how to find value latency-time for alsasrc considering that the pipeline can have different video source ( like filesrc , camera  , dvi receiver etc)

Thanks ,
Ashish Kumar Mishra      
 
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
Sir ,
Could you pelase provide any pointers so that i could evaluate / debug more on same ..

Thanks ,
Ashish Kumar Mishra
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
Dear Nicolas / Group ,

Could you please provide some pointers on the same .

Thanks
Ashish Kumar Mishra
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
Hi All ,

1) Debugging further i could figure that the pipeline drops some samples.
    ERROR: from element /GstPipeline:pipeline/GstAlsaSrc:alsasrc0: Can't record audio fast enough
    Additional debug info:
    gstaudiobasesrc.c(863): gst_audio_base_src_create (): /GstPipeline:pipeline/GstAlsaSrc:alsasrc0:
    Dropped 896 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.

    ERROR: from element /GstPipeline:pipeline/GstAlsaSrc:alsasrc0: Can't record audio fast enough
    Additional debug info:
    gstaudiobasesrc.c(863): gst_audio_base_src_create (): /GstPipeline:pipeline/GstAlsaSrc:alsasrc0:
    Dropped 832 samples. This is most likely because downstream can't keep up and is consuming samples too slowly.

2) I even added "audiorate" plugin with its default value .
   

But the problem of sample drop still exist , could group members please provide any pointers by which i could figure the solution for the problem .


Thanks ,
Ashish Kumar Mishra
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Nicolas Dufresne-3
Le lundi 25 janvier 2016 à 00:53 -0800, Ashish Kumar Mishra a écrit :
> But the problem of sample drop still exist , could group members
> please
> provide any pointers by which i could figure the solution for the
> problem . 

Do you have a pipeline (in gst-launch-1.0 syntax) that we can run to
reproduce ?

Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
Dear Sir ,

1) I can share the code which could be compiled easily .
    The code is being build upon sample code from
https://github.com/sdroege/gst-snippets/blob/217ae015aaddfe3f7aa66ffc936ce93401fca04e/dynamic-filter.c

2) We are having an leave today here in India , i would share the same by tomorrow for sure
   

Thanks,
Ashish Kumar Mishra
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Nicolas Dufresne-3
Le mardi 26 janvier 2016 à 05:43 -0800, Ashish Kumar Mishra a écrit :
> 1) I can share the code which could be compiled easily . 
>     The code is being build upon sample code from 
> https://github.com/sdroege/gst-snippets/blob/217ae015aaddfe3f7aa66ffc
> 936ce93401fca04e/dynamic-filter.c
>
> 2) We are having an leave today here in India , i would share the
> same by
> tomorrow for sure

Are you sure this is the right one ? You asked a question about
alsasrc, and this program have no alsasrc in it's pipeline.

Nicolas
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

signature.asc (188 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
This post was updated on .
Dear Sir ,

Please find the sample code along with makefile to demonstrate the problem.

1) Generic inputs
main ()                         -> Creates elements ( Audio + Video ) and pipeline
gboolean bus_cb()       -> Handle the bus
timeout_cb                   -> Time out ffunction called every 30sec
video_pad_probe_cb   -> Video - Audio Probe function
audio_pad_probe_cb

eos_cb                        -> Function to cater EOS event.


2) make clean && make dynamic-filter
    ./dynamic-filter

Thanks ,
Ashish Kumar  Mishra.

dynamic-filter.cMakefile.Makefile



Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
Dear Sir ,

1) Any pointers / inputs as to how to solve this .

2) Keeping ALSASRC as constant to ( 44.1K + Stereo + 2bytes/sample ) with
below mentioned setting :-
    "buffer-time"   = 21769
    "latency-time" = 10884
    "blocksize"      = 4096
   
I did few more debugging by changing the video file being used as FILESRC [
"blocksize",2048] :-
      2935kbps_with_1920_1080_resolution.mp4  --> Drops 768 / 896/ 1088
sample's randomly
      3986kbps_with_1920_1080_resolution.mp4  --> Drops 589696 / 685056 /
99328 sample's randomly
      3986kbps_with_1920_1080_resolution.mp4  --> Drops 32832   / 1024 /
275392 sample's randomly.

This test help to derive an basic observation that keeping prorammable
parameters of ALSASRC + FILESRC
if we change the file's i.e having different video bit rate / resolution ,
the sync in pipeline is affected .

*This brings to actual question , as to how to determine parameters when we
would require to support different
video files.
*
Please do let me know if i am wrong or missing any point . I am falling
short of pointers to debug the zone which is affecting synchronization
between audio + video


Thanks,
Ashish Kumar Mishra





--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/How-to-determine-find-period-size-of-ALSASRC-LATENCY-of-alsasrc-tp4675332p4675553.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.
_______________________________________________
gstreamer-devel mailing list
[hidden email]
http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: How to determine / find "period_size" of ALSASRC (LATENCY of alsasrc)

Ashish Kumar Mishra
In reply to this post by Ashish Kumar Mishra
Dear Sir ,

1) Any pointers / inputs as to how to solve this .

2) Keeping ALSASRC as constant to ( 44.1K + Stereo + 2bytes/sample ) with below mentioned setting :-
    "buffer-time"   = 21769
    "latency-time" = 10884
    "blocksize"      = 4096
   
I did few more debugging by changing the video file being used as FILESRC [ "blocksize",2048] :-
              47kbps_with_640_480_resolution.mp4  --> Drops 768 / 896/ 1088 sample's randomly
      2935kbps_with_1920_1080_resolution.mp4  --> Drops 589696 / 685056 / 99328 sample's randomly
      3986kbps_with_1920_1080_resolution.mp4  --> Drops 32832   / 1024 / 275392 sample's randomly.

This test help to derive an basic observation that keeping prorammable parameters of ALSASRC + FILESRC
if we change the file's i.e having different video bit rate / resolution ,  the sync in pipeline is affected .

This brings to actual question , as to how to determine parameters when we would require to support different
video files.
 
Please do let me know if i am wrong or missing any point . I am falling short of pointers to debug the zone which is affecting synchronization  between audio + video


Thanks,
Ashish Kumar Mishra