2007/Manual/Postproducción/recuperar audio stereo
De Hackmeeting
- abre esta pagina para editar y copia lo que hay despues de las instrucciones
- pegalo en un fichero de texto y guardalo como recover.py
- navega en unterminal hasta el directorio donde quieres salvar el fichero restaurado
- ejecuta el script # python /url_hasta_fichero/recover.py
- 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
- open the output file for the recovery
fp = open('recover.au','wb')
- write the whole first file because it has the header
dd = open(files[0],'rb').read() fp.write(dd)
- this is intented for recoverying stereo and the second file should be the
- first part of the second track, so write the whole file.
fpp = open('recover2.au','wb')
- write the whole second file because it has the header for track 2
dd = open(files[1],'rb').read() fpp.write(dd)
- it's stereo, so the .au files should alternate left & right channels, so files
- should be written to our two recovery files alternately starting with the 3rd file in our list
- count serves as a quick hack to let us alternate recovery files
count = 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
- 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
- close recovered sound files
fp.close() fpp.close()

