Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save tomickigrzegorz/570ddb5c4d2d60f5f665a6e74ea53e67 to your computer and use it in GitHub Desktop.

Select an option

Save tomickigrzegorz/570ddb5c4d2d60f5f665a6e74ea53e67 to your computer and use it in GitHub Desktop.

Revisions

  1. @pavelbinar pavelbinar revised this gist Apr 28, 2020. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions subtitle-extract.md
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,18 @@
    # Extract Subtitles From `.mkv`

    This instructions whall work on any system (Mac OS X, Linux) supporting installation of `mkvtoolnix`
    These instructions shall work on Mac OS X and Linux.

    ## Install `mkvtoolnix`
    ## Install `mkvtoolnix` (Mac OS X)

    If you don't have [Homebrew](http://brew.sh/) installed, do it first, the continue with following command:
    Installation via [Homebrew](http://brew.sh/):

    brew install mkvtoolnix

    ## List content of the `.mkv` file

    mkvmerge -i myFile.mkv

    ### Example of file content
    ### Example of the file content

    File 'myFile.mkv': container: Matroska
    Track ID 1: video (V_MPEG4/ISO/AVC)
    @@ -33,7 +33,7 @@ Enjoy!

    ## Extract Multiple Files

    In case you need to this in batch for all files in a directory. Works only if all files have same subtitle Track IDs.
    In case you need this in batch for all files in a directory (works only if all files have the same subtitle Track IDs).

    Make sure you use correct file extension (`*.mkv`) and track-ids (`3`)

  2. @pavelbinar pavelbinar revised this gist Aug 16, 2019. 1 changed file with 18 additions and 1 deletion.
    19 changes: 18 additions & 1 deletion subtitle-extract.md
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,21 @@ Track ID 3 and 4 are subtitles.

    mkvextract tracks myFile.mkv 3:myFile1.srt 4:myFile2.srt

    Enjoy!
    Enjoy!

    ---

    ## Extract Multiple Files

    In case you need to this in batch for all files in a directory. Works only if all files have same subtitle Track IDs.

    Make sure you use correct file extension (`*.mkv`) and track-ids (`3`)

    Example:

    ```bash
    for file in *.mkv; do
    sub=$(echo $file | sed 's/\.mkv$/.srt/');
    mkvextract tracks "${file}" 3:"${sub}";
    done
    ```
  3. @pavelbinar pavelbinar revised this gist Oct 10, 2016. 2 changed files with 30 additions and 20 deletions.
    30 changes: 30 additions & 0 deletions subtitle-extract.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    # Extract Subtitles From `.mkv`

    This instructions whall work on any system (Mac OS X, Linux) supporting installation of `mkvtoolnix`

    ## Install `mkvtoolnix`

    If you don't have [Homebrew](http://brew.sh/) installed, do it first, the continue with following command:

    brew install mkvtoolnix

    ## List content of the `.mkv` file

    mkvmerge -i myFile.mkv

    ### Example of file content

    File 'myFile.mkv': container: Matroska
    Track ID 1: video (V_MPEG4/ISO/AVC)
    Track ID 2: audio (A_DTS)
    Track ID 3: subtitles (S_TEXT/UTF8)
    Track ID 4: subtitles (S_TEXT/UTF8)
    Chapters: 22 entries

    Track ID 3 and 4 are subtitles.

    ### Extract subtitles tracks into separate files

    mkvextract tracks myFile.mkv 3:myFile1.srt 4:myFile2.srt

    Enjoy!
    20 changes: 0 additions & 20 deletions subtitle-extract.txt
    Original file line number Diff line number Diff line change
    @@ -1,20 +0,0 @@
    lines with $ are commands

    ### install mkvtoolnix:

    $ brew install mkvtoolnix

    ### list content of the mkv-file:
    $ mkvmerge -i mymoviefile.mkv

    ### what will give you:
    File 'mymoviefiel.mkv': container: Matroska
    Track ID 1: video (V_MPEG4/ISO/AVC)
    Track ID 2: audio (A_DTS)
    Track ID 3: subtitles (S_TEXT/UTF8)
    Track ID 4: subtitles (S_TEXT/UTF8)
    Chapters: 22 entries

    ### so the subtitle-tracks are number 3 and 4.
    ### extract all subtitle-tracks into a seperate srt-file / lang
    $ mkvextract tracks mymoviefile.mkv 3:sub3.srt 4:sub4.srt
  4. @bmaeser bmaeser revised this gist Sep 2, 2011. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions subtitle-extract.txt
    Original file line number Diff line number Diff line change
    @@ -1,20 +1,20 @@
    lines with $ are commands

    # install mkvtoolnix:
    ### install mkvtoolnix:

    $ brew install mkvtoolnix

    # list content of the mkv-file:
    ### list content of the mkv-file:
    $ mkvmerge -i mymoviefile.mkv

    # what will give you:
    ### what will give you:
    File 'mymoviefiel.mkv': container: Matroska
    Track ID 1: video (V_MPEG4/ISO/AVC)
    Track ID 2: audio (A_DTS)
    Track ID 3: subtitles (S_TEXT/UTF8)
    Track ID 4: subtitles (S_TEXT/UTF8)
    Chapters: 22 entries

    # so the subtitle-tracks are number 3 and 4.
    # extract all subtitle-tracks into a seperate srt-file / lang
    ### so the subtitle-tracks are number 3 and 4.
    ### extract all subtitle-tracks into a seperate srt-file / lang
    $ mkvextract tracks mymoviefile.mkv 3:sub3.srt 4:sub4.srt
  5. @bmaeser bmaeser created this gist Sep 2, 2011.
    20 changes: 20 additions & 0 deletions subtitle-extract.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,20 @@
    lines with $ are commands

    # install mkvtoolnix:

    $ brew install mkvtoolnix

    # list content of the mkv-file:
    $ mkvmerge -i mymoviefile.mkv

    # what will give you:
    File 'mymoviefiel.mkv': container: Matroska
    Track ID 1: video (V_MPEG4/ISO/AVC)
    Track ID 2: audio (A_DTS)
    Track ID 3: subtitles (S_TEXT/UTF8)
    Track ID 4: subtitles (S_TEXT/UTF8)
    Chapters: 22 entries

    # so the subtitle-tracks are number 3 and 4.
    # extract all subtitle-tracks into a seperate srt-file / lang
    $ mkvextract tracks mymoviefile.mkv 3:sub3.srt 4:sub4.srt