You Are Here:

Community: Developer Discussion Boards

#1 Old Problem when trying to record audio in MP4 format using Python (N80) - 2007-01-29, 17:56

Join Date: Feb 2006
Posts: 523
Location: Brazil
Send a message via MSN to alb3530
alb3530
Offline
Super Contributor
I got a script to record unlimited audio in my N80 and it works for WAV and AMR.But for MP4, the recording isn't perfect: when i try to play the recorded file, it's played very very fast.I had the same problem with 6681, but for WAV recordings when saved to MMC.Is there some way to slow down the recording speed?Below is the script (it was not created by me)

Code:
#audio recorder app 

import appuifw
import e32
import audio
print"                                                                                                                                                                                                                                                                                                                                                                                                                              "

# define filename

name = appuifw.query(u'Type file name', "text")
extension = appuifw.query(u"File type(wav/amr/mp4)", "text")
#Full path of the file
filename = 'e:\\sounds\\digital\\'+name+"."+extension
# record (extension should be supported by the device):
def recording():
    global S
    # open the sound file to be ready for recording and set an instance (S) of it
    S=audio.Sound.open(filename)
    # do the recording (has to be stopped by closing() function below)
    S.record()
    print "Recording "+filename+" ... Press Options-Stop to finish"

# define the playing part:
def playing():
    global S
    try:
        # open the sound file to be ready for playing by setting an instance (S) of it
        S=audio.Sound.open(filename)
        # play the sound file
        S.play()
        print "Playing"
    except:
        appuifw.note(u"A song must be recorded first", "error")

# stopping of recording / playing and closing of the sound file
def closing():
    global S
    S.stop()
    S.close()
    appuifw.note(u"Stopped", "conf")
    print u""
    print u"Stopped"
def exit_key_handler():
    script_lock.signal()
    appuifw.app.set_exit()
    

script_lock = e32.Ao_lock()

appuifw.app.title = u"audio recorder"

#menu
appuifw.app.menu = [(u"record audio", recording),
                    (u"play latest", playing),
                    (u"stop", closing)]

appuifw.app.exit_key_handler = exit_key_handler
script_lock.wait()
Thanks
Reply With Quote

#2 Old Re: Problem when trying to record audio in MP4 format using Python (N80) - 2007-02-06, 15:34

Join Date: Feb 2006
Posts: 523
Location: Brazil
Send a message via MSN to alb3530
alb3530
Offline
Super Contributor
i've uploaded a example of the audio recorded by the given script.It's found here.It's a normal song that was recorded, but due to a unknown reason, the speed is increased by 4 times or more during playback.Does someone have an idea of what's happening?

If at least there was a way to slow down the recording...Cause i suppose it's a bug in the audio module

Thanks
Last edited by alb3530 : 2007-02-06 at 15:53.
Reply With Quote

#3 Old Re: Problem when trying to record audio in MP4 format using Python (N80) - 2007-02-06, 16:02

Join Date: Dec 2006
Posts: 2,094
Sorcery-ltd's Avatar
Sorcery-ltd
Offline
Forum Nokia Champion
Hi,

It sounds like the sample rate is not set correctly in the file. It is set to 44.1kHz and it is almost certainly a lot less than that.

It's quite likely that the sample rate of the PCM recorded from the device is not being correctly specified to the encoder. I don't think there's anyway you can fix this in your script but I really don't know much about Python.

Sorcery
Reply With Quote

#4 Old Re: Problem when trying to record audio in MP4 format using Python (N80) - 2007-02-06, 16:26

Join Date: Feb 2006
Posts: 523
Location: Brazil
Send a message via MSN to alb3530
alb3530
Offline
Super Contributor
Quote:
Originally Posted by Sorcery-ltd
Hi,

It sounds like the sample rate is not set correctly in the file. It is set to 44.1kHz and it is almost certainly a lot less than that.

It's quite likely that the sample rate of the PCM recorded from the device is not being correctly specified to the encoder. I don't think there's anyway you can fix this in your script but I really don't know much about Python.

Sorcery
In a regular MP4 video recorded by the same device, the sample rate is 16kHZ.Maybe that should be the correct value....

As you said, i think it's not possible to revert the situation by editing the script only.

A pity, i thought i could finally be able to record only audio in MP4 rather than having to record a MP4 video and send the file to someone that have a pc, asking the person to edit the video and extract audio only.

Not even current C++ apps can record audio in MP4, i think.At least i don't know of any

Thanks for your reply
Reply With Quote

#5 Old Re: Problem when trying to record audio in MP4 format using Python (N80) - 2007-02-07, 08:50

Join Date: Sep 2003
Posts: 209
Location: Finland
otsov
Offline
Regular Contributor
Quote:
Originally Posted by alb3530
In a regular MP4 video recorded by the same device, the sample rate is 16kHZ.Maybe that should be the correct value....

As you said, i think it's not possible to revert the situation by editing the script only.
You might want to input a feature request for this one to SourceForge or try to implement this by yourself:

It seems that class "CMdaAudioRecorderUtility" (used internally in PyS60 extension "audio") has methods "GetSupportedSampleRates" and "SetDestinationSampleRateL()" which you could perhaps use to solve your problem.

A patch for this would be also nice.
Reply With Quote

#6 Old Re: Problem when trying to record audio in MP4 format using Python (N80) - 2007-02-07, 13:43

Join Date: Feb 2006
Posts: 523
Location: Brazil
Send a message via MSN to alb3530
alb3530
Offline
Super Contributor
Quote:
Originally Posted by otsov
You might want to input a feature request for this one to SourceForge or try to implement this by yourself:

It seems that class "CMdaAudioRecorderUtility" (used internally in PyS60 extension "audio") has methods "GetSupportedSampleRates" and "SetDestinationSampleRateL()" which you could perhaps use to solve your problem.

A patch for this would be also nice.
Wow, many thanks for your reply.You mean i could insert in the script
Code:
audio.SetDestinationSampleRateL(16000)
?

I'm afraid i can't do that, for i'm totally newbie in python scripting language...I mean, it should be effective only when user chooses MP4 recording.AMR, for example, would have a less sample rate.
Well, then i did a bad thing by reporting the problem related in this topic as being a bug at sourceforge...

I look forward for your advice.
Reply With Quote

#7 Old Re: Problem when trying to record audio in MP4 format using Python (N80) - 2007-02-07, 14:34

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Quote:
Originally Posted by alb3530
Wow, many thanks for your reply.You mean i could insert in the script
Code:
audio.SetDestinationSampleRateL(16000)
?
As Otsov said it's C++ code changes ! So you have to change source code with SetDestinationSampleRateL (c++ function L as LEAVE and not PyS60 function !)

Cyke64


pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Reply With Quote

#8 Old Re: Problem when trying to record audio in MP4 format using Python (N80) - 2007-02-07, 19:12

Join Date: Feb 2006
Posts: 523
Location: Brazil
Send a message via MSN to alb3530
alb3530
Offline
Super Contributor
Quote:
Originally Posted by cyke64
As Otsov said it's C++ code changes ! So you have to change source code with SetDestinationSampleRateL (c++ function L as LEAVE and not PyS60 function !)

Cyke64
I'm unable to do anything them.
Thanks for your reply
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Audio input streaming problem on Series 60 v2.6 phones (6680,6630) andrew.hayes Symbian Media (Graphics & Sounds) 1 2006-01-20 15:30
Common problem: wrong file format "exception" lukaszpl Mobile Java General 0 2005-12-05 18:09
Bluetooth Python Standalone APP problem wallace_nogueira Python 0 2005-05-03 20:25
audio capture from microphone in gsm format venable Mobile Java Media (Graphics & Sounds) 1 2004-01-07 12:10
3650 audio recording in GSM 6.10 format tctse General Symbian C++ 4 2003-06-20 10:25

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia