2016-06-14 5 views
0

나는 30 분짜리 MP3로 오디오를 가져 와서 유닉스 타임 스탬프, 두 번째 긴 파일로 자르는 파이썬 스크립트를 썼다. 소스 오디오 파일은 192kbps, 441000Hz, 스테레오 mp3 파일입니다.Pydub 오디오 내보내기가 시작되면 소리가 나지 않습니까?

라디오 방송국 (내가 일하는 곳)에서 오디오를 보관하고 지정된 시작 시간과 종료 시간, 두 번째로 사용자에게 전달할 수있는 서비스를 원합니다. 유지 보수를 위해 한 시간 동안 서버를 종료했습니다 (시도하지는 않았지만 시도했습니다). 그리고 30 분짜리 청크를 저장 한 다른 컴퓨터를 사용하여 그 시간 동안 기록했습니다. 일반적으로이 보관 서버는 아무런 문제없이 두 번째 긴 청크 자체를 저장합니다.

30 분 입력 오디오 파일의 출력 청크를 저장하는 디렉토리에 주어진 변환을 수행하는 기능, 및 유닉스 타임 스탬프로 파일의 시작 시간 :

def slice_file(infile, workingdir, start): 
    #find the duration of the input clip in millliseconds 
    duration_in_milliseconds = len(infile) 

    print ("Converting " + working_file + " (", end="", flush=True) 

    song = infile 
    #grab each one second slice and save it from the first second to the last whole second in the file 
    for i in range(0,duration_in_milliseconds,1*one_second): 
     #get the folder where this second goes: 
     arr = datefolderfromtimestamp(int(start) + (int(i/1000))) 
     #print ("Second number: %s \n" % (int(i/1000))) 
     offset = (i + one_second) 
     current_second = song[i:offset] 
     ensure_dir(working_directory + "/" + arr[0] + "/" + arr[1] + "/" + arr[2] + "/") 
     filename = os.path.normpath(working_directory + "/" + arr[0] + "/" + arr[1] + "/" + arr[2] + "/" + str(int(start) + (int(i/1000))) + "-second.mp3") 
     current_second.export(filename, format="mp3") 

     #indicate some sort of progress is happening by printing a dot every three minutes processed 
     if(i % (3*60*one_second) == 0): 
      print ('.', end="", flush=True) 

    print (")") 

내 문제입니다 이 스크립트에 의해 변환 된 모든 두 번째 파일은 초당 평균 70 ms의 무음이 시작될 때보 다 긴 것처럼 보입니다. 내 아카이버 서버에서 파일을 다운로드하면 모든 파일이 함께 연결되므로 끔찍하고 이상하게 보입니다.

누군가 나를 도울 수 있습니까? 이 오류가 어디에서오고 있는지 확실하지 않습니다. 당신이 궁금하면

내 전체 스크립트를

http://pastebin.com/fy8EkVSz

+0

내 나쁜 오디오는 다음과 같습니다. 2 분 길이가되어야하지만 120 분 길이의 파일을 연결하기 때문에 모든 작은 침묵 때문에 2:07이됩니다. http://www.citr.ca/?attachment_id=69907 – Scott

답변