#!/bin/sh


#Input #0, avi, from 'Metalocalypse.S01E01.The.Curse.Of.Dethklok.DVDRip.XviD-KYR.avi':
#  Duration: 00:11:31.16, start: 0.000000, bitrate: 1367 kb/s
#    Stream #0:0: Video: mpeg4 (Simple Profile) (XVID / 0x44495658), yuv420p, 640x360 [SAR 1:1 DAR 16:9], 1230 kb/s, 23.98 fps, 23.98 tbr, 23.98 tbn, 23.99 tbc
#    Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, s16p, 128 kb/s
#Input #1, vobsub, from 'Metalocalypse.S01E01.The.Curse.Of.Dethklok.DVDRip.XviD-KYR.idx':
#  Duration: N/A, bitrate: N/A
#    Stream #1:0[0x0](en): Subtitle: dvd_subtitle, 720x480 (default)
#    Stream #1:1[0x1](fr): Subtitle: dvd_subtitle, 720x480
#    Stream #1:2[0x2](es): Subtitle: dvd_subtitle, 720x480
#Input #2, mpeg, from 'Metalocalypse.S01E01.The.Curse.Of.Dethklok.DVDRip.XviD-KYR.sub':
#  Duration: 00:11:05.40, start: 14.928600, bitrate: 28 kb/s
#    Stream #2:0[0x20]: Subtitle: dvd_subtitle
#    Stream #2:1[0x21]: Subtitle: dvd_subtitle
#    Stream #2:2[0x22]: Subtitle: dvd_subtitle

ffmpeg -fflags +genpts -i $1.avi -i $1.idx -i $1.sub \
-map 0:0 \
-map 0:1 \
-map 1:0 \
-c:v libx264 \
-c:a copy \
-c:s dvd_subtitle \
-metadata:s:1 language=eng -flags global_header $1.mkv
