Skip to content

Instantly share code, notes, and snippets.

@benschw
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benschw/9762095 to your computer and use it in GitHub Desktop.
Save benschw/9762095 to your computer and use it in GitHub Desktop.

Player

Change audio / subtitles in mplayer

  • Press V to toggle the subs on and off
  • Press J to cycle languages
  • Press # to cycle the audio

Encoder

Join two avi files in mencoder

mencoder input-a.avi input-b.avi -forceidx -oac copy -ovc copy -o output.avi

Remove unused audio track

Since you can't remove a track, you must extract everything and then rebuild the file without it.

Inspect tracks in original file with mkvtools

$ mkvmerge -i 28DaysLater-original.mkv 
File '28DaysLater-original.mkv': container: Matroska
Track ID 1: video (V_MPEG4/ISO/AVC)
Track ID 2: audio (A_AC3)
Track ID 3: audio (A_DTS)
Chapters: 33 entries

compare with mplayer output

$ mplayer -vo null 28DaysLater-original.mkv 
...
Playing 28DaysLater-original.mkv.
libavformat file format detected.
[matroska,webm @ 0x98fa020] Estimating duration from bitrate, this may be inaccurate
[lavf] stream 0: video (h264), -vid 0
[lavf] stream 1: audio (ac3), -aid 0, -alang ger
[lavf] stream 2: audio (dca), -aid 1, -alang eng
VIDEO:  [H264]  1280x688  0bpp  23.976 fps    0.0 kbps ( 0.0 kbyte/s)
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
Selected video codec: [ffh264] vfm: ffmpeg (FFmpeg H.264)
...

Extract chapters

$ mkvextract chapters 28DaysLater-original.mkv > chapters.xml

Extract Audio & Video tracks

$ mkvextract tracks 28DaysLater-original.mkv 1:video.h264 2:gerAudio.ac3 3:engAudio.dts
Extracting track 1 with the CodecID 'V_MPEG4/ISO/AVC' to the file 'video.h264'. Container format: AVC/h.264 elementary stream
Extracting track 2 with the CodecID 'A_AC3' to the file 'gerAudio.ac3'. Container format: Dolby Digital (AC3)
Extracting track 3 with the CodecID 'A_DTS' to the file 'engAudio.dts'. Container format: Digital Theater System (DTS)
Progress: 100%

Join tracks we're keeping back in (use "-A" to omit audio from a given track)

$ mkvmerge -o 28DaysLater-final.mkv -A video.h264 engAudio.dts --chapters chapters.xml 

Notes:

  • Language is undefined in the output file, might want to specify that if including multiple languages
  • No default tracks are specified, might want to do that if multiple audio or video tracks are included
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment