2007/Manual/Postproducción/recuperar audio stereo

De Hackmeeting

  1. abre esta pagina para editar y copia lo que hay despues de las instrucciones
  2. pegalo en un fichero de texto y guardalo como recover.py
  3. navega en unterminal hasta el directorio donde quieres salvar el fichero restaurado
  4. ejecuta el script # python /url_hasta_fichero/recover.py
  5. escribe la ruta de la carpeta donde estan los ficheros au

# python script to recover audacity recording after crash
import os
directory = raw_input('Enter directory where temp data files are: ')
rawfiles = os.listdir(directory)  # grab directory listing
files = []           # only interested in .au files and
for i in rawfiles:   # prepend each with the directory name
  if i[-3:] == '.au': files.append(directory+'/'+i)
files.sort()  # sort files so the result will be in proper sequence
  1. open the output file for the recovery

fp = open('recover.au','wb')

  1. write the whole first file because it has the header

dd = open(files[0],'rb').read() fp.write(dd)

  1. this is intented for recoverying stereo and the second file should be the
  2. first part of the second track, so write the whole file.

fpp = open('recover2.au','wb')

  1. write the whole second file because it has the header for track 2

dd = open(files[1],'rb').read() fpp.write(dd)

  1. it's stereo, so the .au files should alternate left & right channels, so files
  2. should be written to our two recovery files alternately starting with the 3rd file in our list
  1. count serves as a quick hack to let us alternate recovery files

count = 1

  1. this is just to give a quick count so you can see if the two recovery files got the same number of files added to them

track_one_files = 1 track_two_files = 1

  1. for every other file, write from the data offset on

for i in files[2:]:

  	if count == 1:

#write to first recovery file

  		dd = open(i, 'rb').read()[12380:]
  		fp.write(dd)
  		count = 0

track_one_files = track_one_files + 1

  	else:

#write to second recovery file dd = open(i, 'rb').read()[12380:]

  		fpp.write(dd)

count = 1 track_two_files = track_two_files + 1

print "Files recovered for track 1:" print track_one_files print "Files recovered for track 2:" print track_two_files

  1. close recovered sound files

fp.close() fpp.close()

Herramientas personales
wiki-navigation
project-navigation