[FFmpeg-user] x-axis range of drawgraph picture mode

Dave Rice dave at dericed.com
Mon Apr 9 23:52:37 EEST 2018


> On Apr 9, 2018, at 4:12 PM, Dave Rice <dave at dericed.com> wrote:
> 
> Hi ffmpeg-user,
> 
> I’m using drawgraph with slide=picture in order to make some still images of audiovisual metrics upon a timeline. I’d like to use drawgraph and drawtext in order to overlay some x-axis markers and label the timeline; however I’m unclear how the x-axis is represented in this mode. For instance, the example below plots lavfi.astats.1.Min_level for a 60 second sample, but the resulting image appears to have a x-axis that represents more than 60 seconds. The result appears to roughly plot about 80 seconds with the 60-80 second range being blank. 
> 
> ffmpeg -f lavfi -i "aevalsrc=d=60:exprs=sin(PI*t):s=48000,aformat=sample_fmts=dbl,astats=metadata=1:reset=1,adrawgraph=m1=lavfi.astats.1.Min_level:max=1:min=-1:slide=picture:s=1920x240" -y test.png
> 
> Is there some math that I can use to determine the maximum value of the x-axis from the plotted image?

Responding to myself here, but the max of the x-axis in this drawgraph example is found via:

variables from the command:
sample_rate = 48000
duration = 60
number_of_sample_in_audio_frame = 2048
drawgraph_width = 1920

temp variables:
TILE_FLOOR=  floor   ( ( ( sample_rate * duration ) / number_of_sample_in_audio_frame ) / drawgraph_width )
TILE_MOD=    modulo  ( ( ( sample_rate * duration ) / number_of_sample_in_audio_frame ) / drawgraph_width , drawgraph_width)
TILE_CEILING=ceiling ( ( ( sample_rate * duration ) / number_of_sample_in_audio_frame ) / drawgraph_width )

result:
X-AXIS-MAX=duration / ( TILE_FLOOR * drawgraph_width + TILE_MOD ) / ( TILE_CEILING * drawgraph_width )

or 
TILE_FLOOR=0
TILE_MOD=1,406.25
TILE_CEILING=1

or
X-AXIS-MAX=81.9194174619 seconds

So my guess of 80 seconds was close.

Best Regards,
Dave Rice


More information about the ffmpeg-user mailing list