2016-08-20 5 views
0

코드에 문제가없는 것은 아니지만 대상 위치에서 압축 파일의 크기를 확인할 때마다 파일 크기가 2 또는 3KB로만 줄어든 것을 볼 수 있습니다. 대용량 파일은 약 650MB로 확장됩니다.DeflaterOutputStream을 사용하여 큰 파일을 압축하는 방법은 무엇입니까?

public static void main(String[] args) throws Exception 
    { 
    FileInputStream fin = new FileInputStream("filetobecompressed.mp4"); 
    FileOutputStream fout = new FileOutputStream("compressedfile.mp4"); 
    DeflaterOutputStream dout = new DeflaterOutputStream(fout); 
    byte b[] = new byte[8192]; 
    int r; 
    float tracker = 0; 
    while((r=fin.read(b))!=-1) 
    { 
     dout.write(b,0,r); 
     dout.flush(); 
     tracker += (float)r/1000000f; 
     System.out.println(tracker + "MB compressed"); 
    } 
    dout.finish(); 
    fin.close(); 
    fout.close(); 
    dout.close(); 
    System.out.println("Compression successful"); 
} 

미리 감사드립니다.

+0

BTW 'flush()'를 호출 할 때마다 압축 파일과 함께 약간의 데이터를 추가합니다. 그것은 그 시점에서 작업하고있는 결론을 가져옵니다. –

답변

2

MP4 파일을 압축 할 수 없습니다. 일반적으로 MP4 파일 형식은 자체 압축을 수행하므로 일반 (무손실) 압축기가 제거 할 중복성이 없습니다.

명령 줄 압축 유틸리티를 사용하여 동일한 파일을 압축 해보십시오. 나는 당신이 거기에서도 최소한의 압축을 할 것이라고 예측한다.

(이미) 압축 된 오디오/비디오 파일에 대한 추가 압축을 얻는 유일한 방법은 해당 형식의 코덱을 사용하여 압축을 풀고 낮은 압축률로 다시 압축하는 것입니다. 분명히, 이렇게하면 오디오/비디오 품질이 희생됩니다.

관련 문제