November 2015 Posts

How to Extract SRT (Subtitle File) From MKV Movie File on Windows

Ive just download a very good, and a highly recommended anime, Digimon Adventure Tri. It can play well on my laptop, but when i put it on my TV, somehow the subtitle is gone. I notice that it happen because the srt got burn inside the video file.

After browsing for a while, i found out that i can extract my srt using MKVToolNix tools. I downloaded it, and using one of its tools, mkvextract.exe, i can extract the subtitles i wanted from my mkv files.

But first, make sure you use mkvinfo.exe to check your mkv information.

C:\Program Files\MKVToolNix>mkvinfo.exe 
        "C:\Users\edw\Downloads\[HorribleSubs] Digimon Adventure tri - 01 [1080p].mkv"

And find track id for subtitles.

| + A track
|  + Track number: 3 (track ID for mkvmerge & mkvextract: 2)
|  + Track UID: 3
|  + Track type: subtitles
|  + Lacing flag: 0
|  + Codec ID: S_TEXT/ASS
|  + CodecPrivate, length 1934

In this scenario, my subtitle track id is 2 and subtitle format is .ass

Okay, whit that information, i can start to extracting my subtitle file.

C:\MKVToolNix>mkvextract tracks 
        "C:\Users\edw\Downloads\[HorribleSubs] Digimon Adventure tri - 01 [1080p].mkv" 
        2:"E:mysubtitle.ass"

It will extract subtitle from “Digimon Adventure tri – 04 [1080p].mkv” and put the subtitle on E:\ with named mysubtitle.ass. You can convert .ass file into .srt file easily using online converter tools.

Google+

[Java] How to Create a HTTP Get Request

Basically i use this class to mimic a json request to a different domain, to prevent CORS error. So this is my code, oh and i use Spring Framework, which explain the Service annotation .

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import org.springframework.stereotype.Service;

@Service
public class JsonService {

    public String get() {
        try {
            return getHTML("myurl");
        } catch (Exception e) {
            return "";
        }
    }
    
   private String getHTML(String urlToRead) throws Exception {
      StringBuilder result = new StringBuilder();
      URL url = new URL(urlToRead);
      HttpURLConnection conn = (HttpURLConnection) url.openConnection();
      conn.setRequestMethod("GET");
      BufferedReader rd = new BufferedReader(new InputStreamReader(conn.getInputStream()));
      String line;
      while ((line = rd.readLine()) != null) {
         result.append(line);
      }
      rd.close();
      return result.toString();
   }
}

Hope it can help others, cheers (B)

Google+