For people who might have a similar problem, here is how I made it work
using Dan's solution:
import mlt
import sys
def get_audio_level(frame):
# get_waveform provides an easy way to make the audio fetched.
frame.get_waveform(160, 120)
return frame.get_double('meta.media.audio_level.0')
mlt.Factory.init()
profile = mlt.Profile( )
prod = mlt.Producer(profile, sys.argv[1])
profile.from_producer(prod)
filt = mlt.Filter(profile, "audiolevel")
filt.connect(prod)
#test
i = 172
prod.seek(i)
frame = filt.get_frame()
print get_audio_level(frame)
<http://timecodelab.com/>Pierre-Emmanuel Viau - Développeur • Software
developer
514-943-8053 • pierre-emman...@timecodelab.com
5333 av Casgrain #514, Montréal, Qc, H2T 1X3
<http://facebook.com/timecodelab> <http://vimeo.com/timecodelab>
On Fri, May 1, 2015 at 2:49 PM, Pierre-Emmanuel Viau <
pierre-emman...@timecodelab.com> wrote:
> That's great, thank you! I looked into fixing the bindings but I'm afraid
> that's a bit beyond my comprehension at this moment.
>
>
>
>
> On Fri, May 1, 2015 at 2:46 PM, Dan Dennedy <d...@dennedy.org> wrote:
>
>> Alternatively, here is Python snippet from a project I did where I needed
>> audio levels, but you have to use the level determined by this filter
>> instead of your own code. Here is docs on the filter:
>> http://www.mltframework.org/bin/view/MLT/FilterAudiolevel
>> This filter is used to drive the peak meter in Shotcut to give you some
>> frame-of-reference about its suitability for your task.
>>
>> mlt.mlt_log_set_level(0)
>> mlt.Factory.init()
>> profile = mlt.Profile(config.MLT_PROFILE)
>>
>> def mlt_open_file(filename):
>> global profile
>> producer = mlt.Producer(profile, filename)
>> producer.attach(mlt.Filter(profile, 'audiolevel'))
>> return producer
>>
>> def get_audio_level(frame):
>> # get_waveform provides an easy way to make the audio fetched.
>> frame.get_waveform(160, 120)
>> return frame.get_double('meta.media.audio_level.0')
>>
>> On Fri, May 1, 2015 at 11:28 AM Pierre-Emmanuel Viau <
>> pierre-emman...@timecodelab.com> wrote:
>>
>>> Hello, I am trying to write a simple test in order to get the audio
>>> level at a certain frame. So far I have:
>>>
>>>
>>> import mlt
>>> import sys
>>>
>>> mlt.Factory.init()
>>> profile = mlt.Profile( )
>>> prod = mlt.Producer(profile, sys.argv[1])
>>> profile.from_producer(prod)
>>>
>>> #test
>>> i = 172
>>> prod.seek(i)
>>> frame = prod.get_frame()
>>> print type(frame.get_audio(mlt.mlt_audio_float, 48000, 2, 1))
>>>
>>> This doesn't work, I get the following exception:
>>> TypeError: in method 'Frame_get_audio', argument 2 of type
>>> 'mlt_audio_format &'
>>>
>>> Do you have an idea of how to fix this?
>>> Thank you!
>>>
>>>
>
------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
Mlt-devel mailing list
Mlt-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlt-devel