Hi David,
Right now muxer object for most of the formats is not doing anything besides 
simple muxing. There are simple headers created for mp3 but not with the 
XING info or something. Just standard ID3 info.
For mp3 it is not required in oppose to the avi, asf or similar so I do not 
understand why some progs are looking for the info in mp3 file...
Dmitry/

----- Original Message ----- 
From: "David Fraser" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, June 02, 2006 8:18 AM
Subject: [Pymedia-users] MP3 files generated have no valid header


> Hi
>
> I've been trying to use pymedia to generate MP3 files (for screencasting
> with pyvnc2swf).
> Unfortunately I can't get the example code to produce valid MP3 files.
> pymedia itself can read them back, but they don't seem to have valid
> headers.
> MP2 files generated are fine.
>
> This is from looking at the files with mpginfo:
>
> [EMAIL PROTECTED] data]$ mpginfo test-pymedia-input.mp3
> Skipped 415 zeroes at start of file
> mmm, this file does not start with a pack, offset: 415
> use the desperate_mode switch as the first option -X to search for a
> header in the whole file!
> if you want to force the operation. May yield to an endless loop if no
> valid header is found!
> Does not even begin with a 00 00 01 xx sequence!
>
> No success at all.
> test-pymedia-input.mp3 is not a valid mpeg file
>
> Whereas .mp2 files work fine:
> [EMAIL PROTECTED] data]$ mpginfo test-mp2-input.mp2
> test-mp2-input.mp2
>  Audio : Mpeg 1 layer 2
>  Estimated Duration: 16.67s
>  128 kbps  44100 Hz
>  Frame size: 417 bytes
>  Mono,  No emphasis,  original
>
> Lame can then successfully recode the file (lame test-mp2-input.mp2
> test-mp2-input.mp3) and that gives a valid mp3 file:
> [EMAIL PROTECTED] data]$ mpginfo test-mp2-input.mp3
> test-mp2-input.mp3
>  Audio : Mpeg 1 layer 3
>  Estimated Duration: 16.74s
>  64 kbps  44100 Hz
>  Frame size: 208 bytes
>  Mono,  No emphasis,  original
>
> Lame can actually recover the mp3 file that pymedia produces in a
> similar way (lame test-pymedia-input.mp3 recoded.mp3), and seems to add
> header information
>
> I tried adding muxer encoding to the sample but it doesn't produce
> anything on start() or end()
> Attached is the record_sound program I am using (modified to use
> threads, pick up keyboard interrupts, and do muxing).
> This may be helpful as a sample anyway, but can anyone see what I am
> doing wrong? Or is this a library error?
>
> I'm running on Fedora Core 4 with the following versions:
> python-2.4.1-2
> pymedia-1.3.5.0-1 (built from source)
> lame-3.96.1-2.2.fc4
>
> Any help appreciated
>
> Regards
> David
>


--------------------------------------------------------------------------------


> import time, sys
> import pymedia.audio.sound as sound
> import pymedia.audio.acodec as acodec
> import pymedia.muxer as muxer
> import threading
>
> class voiceRecorder:
>  def __init__(self,  name ):
>    self.name = name
>    self.finished = False
>
>  def record(self):
>    self.snd.start()
>    while not self.finished:
>      s= self.snd.getData()
>      if s and len( s ):
>        for fr in self.ac.encode( s ):
>          # We definitely should use mux first, but for
>
>          # simplicity reasons this way it'll work also
>          block = self.mux.write( self.stream_index, fr )
>          if block is not None:
>            self.f.write( block )
>      else:
>        time.sleep( .003 )
>        # time.sleep( 0 )
>    self.snd.stop()
>
>  def run(self):
>    print "recording to", self.name
>    self.f= open( self.name, 'wb' )
>    # Minimum set of parameters we need to create Encoder
>
>    cparams= { 'id': acodec.getCodecID( 'mp2' ),
>               'bitrate': 128000,
>               'sample_rate': 44100,
>               'channels': 1 }
>    self.ac= acodec.Encoder( cparams )
>    self.snd= sound.Input( 44100, 1, sound.AFMT_S16_LE )
>    self.mux = muxer.Muxer("mp2")
>    self.stream_index = self.mux.addStream( muxer.CODEC_TYPE_AUDIO, 
> self.ac.getParams() )
>    block = self.mux.start()
>    if block:
>      self.f.write(block)
>    # Loop until Ctrl-C pressed or finished set from outside
>
>    self.finished = False
>    thread = threading.Thread(target=self.record)
>    thread.start()
>    try:
>      while not self.finished:
>        time.sleep( .003 )
>    except KeyboardInterrupt:
>      self.finished = True
>    print "finishing recording to", self.name
>    # Stop listening the incoming sound from the microphone or line in
>    thread.join()
>    footer = self.mux.end()
>    if footer is not None:
>      self.f.write(footer)
>    self.f.close()
>    print "finished recording to", self.name
>
> # 
> ----------------------------------------------------------------------------------
>
> # Record stereo sound from the line in or microphone and save it as mp3 
> file
>
> # Specify length and output file name
>
> # http://pymedia.org/
>
> if __name__ == "__main__":
>  if len( sys.argv )!= 2:
>    print 'Usage: %s <file_name>' % sys.argv[ 0 ]
>  else:
>    voiceRecorder( sys.argv[ 1 ]  ).run()
>
>


--------------------------------------------------------------------------------


>


--------------------------------------------------------------------------------


> _______________________________________________
> Pymedia-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/pymedia-users
> 



_______________________________________________
Pymedia-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pymedia-users

Reply via email to