From 3fc55826cad90c650787e31c1726d5fc49b83892 Mon Sep 17 00:00:00 2001 From: Tim Redfern Date: Thu, 31 Oct 2013 14:05:48 +0000 Subject: audio thumbnails --- rotord/src/graph.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'rotord/src/graph.h') diff --git a/rotord/src/graph.h b/rotord/src/graph.h index 2f8843d..70a7e3a 100644 --- a/rotord/src/graph.h +++ b/rotord/src/graph.h @@ -144,6 +144,40 @@ namespace Rotor { return true; } } + //fall back to audio + libav::audio_decoder loader; + if (loader.open(inputfilename)) { + Audio_thumbnailer at; + at.width=w; + at.height=h; + int rate = loader.get_sample_rate(); + int samples = loader.get_number_samples(); + int channels= loader.get_number_channels(); + int bits = loader.get_bit_depth(); + at.init(channels,bits,samples,rate); + bool finished=false; + uint16_t *audio=new uint16_t[1024*loader.get_number_channels()]; + uint64_t sample=0; + while (loader.get_samples(audio,sample,1024)) { + at.process_frame((uint8_t*)audio,1024); + sample+=1024; + } + cv::Mat co=cv::Mat(h,w,CV_8UC3); + uchar op; + for (int i=0;iabs(((float)i-h/2)/(h/2))) op=0xFF; + else op=0x00; + r[j*3]=op/4; + r[j*3+1]=op; + r[j*3+2]=op/4; + } + } + cv::imwrite(outputfilename.c_str(),co); + return true; + } return false; } private: -- cgit v1.2.3