1

I want to use a subtitle API. It requires a md5 hash of first and last 64kb of the video file. I know how to do the md5 part just want to know how will I achieve to get the 128kb of data.

An example of API is given in Python but sadly I do not understand it.

    #this hash function receives the name of the file and returns the hash code
def get_hash(name):
    readsize = 64 * 1024
    with open(name, 'rb') as f:
        size = os.path.getsize(name)
        data = f.read(readsize)
        f.seek(-readsize, os.SEEK_END)
        data += f.read(readsize)
    return hashlib.md5(data).hexdigest()

http://thesubdb.com/api/

Any help would be appreciated.

1 Answers1

1

try something like this

    FileInputStream in = new FileInputStream("d:/1.avi");
    byte[] a = new byte[64 * 1024];
    in.read(a);   //head
    long p = in.getChannel().size() - 64 * 1024;
    in.getChannel().position(p);
    in.read(a);   //tail
Evgeniy Dorofeev
  • 133,369
  • 30
  • 199
  • 275