Skip to content

Instantly share code, notes, and snippets.

@popq
Last active August 29, 2015 13:58
Show Gist options
  • Save popq/10433289 to your computer and use it in GitHub Desktop.
Save popq/10433289 to your computer and use it in GitHub Desktop.
Useful command line hacks
MP4Box -add subtitle.srt:lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" movie.mp4
# Looping over a directory of similarily named movies and subtitle files, equal
# length of each filename.
# Adjust the cut -c for your setup
for i in `ls -l *.mp4 | cut -c 51-80`; do /Applications/Osmo4.app/Contents/MacOS/MP4Box -add $i.srt:lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" $i.mp4; done
# Looping as above, for filenames of different length, with no dots in filename before .mp4.
# Adjust cut -c for your setup.
for i in `ls -l *.mp4 | cut -c 51- | cut -f 1 -d.`; do /Applications/Osmo4.app/Contents/MacOS/MP4Box -add $i.srt:lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" $i.mp4; done
# Looping as above, for filenames of different length, with dots in filename before .mp4
# Adjust cut -c for your setup
# Adjust number of groups (cut -f 1-4) for your filename pattern (-f 1-4 = 4 groups = 3 dots before .mp4)
# Example a.b.c.d.mp4
for i in `ls -l *.mp4 | cut -c 51- | cut -f 1 -d.`; do /Applications/Osmo4.app/Contents/MacOS/MP4Box -add $i.srt:lang=eng:layout=0x60x0x-1:group=2:hdlr="sbtl:tx3g" $i.mp4; done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment