Skip to content

Instantly share code, notes, and snippets.

@dannguyen
Last active June 9, 2016 18:47
Show Gist options
  • Save dannguyen/5632590 to your computer and use it in GitHub Desktop.
Save dannguyen/5632590 to your computer and use it in GitHub Desktop.
Reading subtitles

Given a MP4 file...

Use MP4Box to extract into VOB/SUB format

First, find the info: /Volumes/GPAC\ for\ OSX/Osmo4.app/Contents/MacOS/MP4Box -info ~/Desktop/MOVIEFILE.m4v

  * Movie Info *
    Timescale 90000 - Duration 00:22:36.981
  	4 track(s)
  	Fragmented File: no
  	File suitable for progressive download (moov before mdat)
  	File Brand mp42 - version 0
  	Created: GMT Thu May 16 02:02:19 2013
  
  File has root IOD (9 bytes)
  Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
  Visual PL: ISO Reserved Profile (0x7f)
  Audio PL: High Quality Audio Profile @ Level 2 (0x0f)
  No streams included in root OD
  
  iTunes Info:
  	Encoder Software: HandBrake 5454svn 2013051301
  
  Track # 1 Info - TrackID 1 - TimeScale 90000 - Media Duration 00:22:36.981
  Track has 1 edit lists: track duration is 00:22:36.981
  Media Info: Language "Undetermined" - Type "vide:avc1" - 32534 samples
  Visual Track layout: x=0 y=0 width=853 height=360
  MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
  AVC/H264 Video - Visual Size 720 x 360
  	AVC Info: 1 SPS - 1 PPS - Profile Main @ Level 4
  	NAL Unit length bits: 32
  	Pixel Aspect Ratio 32:27 - Indicated track size 853 x 360
  Self-synchronized
  
  Track # 2 Info - TrackID 2 - TimeScale 48000 - Media Duration 00:22:36.949
  Media Info: Language "French" - Type "soun:mp4a" - 63607 samples
  MPEG-4 Config: Audio Stream - ObjectTypeIndication 0x40
  MPEG-4 Audio AAC LC - 1 Channel(s) - SampleRate 48000
  Synchronized on stream 1
  
  Track # 3 Info - TrackID 3 - TimeScale 90000 - Media Duration 00:22:34.083
  Media Info: Language "French" - Type "subp:mp4s" - 492 samples
  MPEG-4 Config: NeroDigital Subpicture Stream - ObjectTypeIndication 0xe0
  Synchronized on stream 1
  
  Track # 4 Info - TrackID 4 - TimeScale 90000 - Media Duration 00:22:36.981
  Track has 1 edit lists: track duration is 00:22:36.981
  Track is disabled
  Media Info: Language "Undetermined" - Type "text:text" - 5 samples
  Timed Text - Size 0 x 0 - Translation X=0 Y=0 - Layer 0

/Volumes/GPAC\ for\ OSX/Osmo4.app/Contents/MacOS/MP4Box -raw 3 ~/Desktop/MOVIEFILE.m4v

Install Tesseract brew install tesseract

Download the French language pack for tesseract https://code.google.com/p/tesseract-ocr/downloads/list

Copy to: /usr/local/Cellar/tesseract/3.02.02/share/tessdata

Get Vobsub2srt

https://github.com/ruediger/VobSub2SRT

Download formula for vobsub2srt: brew install https://github.com/ruediger/VobSub2SRT/raw/master/packaging/vobsub2srt.rb

 brew install --HEAD vobsub2srt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment