MicroDVD

From MultimediaWiki
Jump to navigation Jump to search
  • Extensions: .txt, .sub


MicroDVD is a very simple subtitle format based on frame numbers instead of time codes. The format for every line is:

{START_FRAME}{END_FRAME}Dialog line|Second line of dialog

Note that the vertical bar separator and Second line of dialog are optional. Single line cooments

Example

{25}{125}-First line|-Second line
{25}{125}Just one line

Conversion

The following gawk script will convert MicroDVD to SubRip format

BEGIN {	FpS=23.976 ; NL="\n" }
function timestamp(f,  s) {
	s=int(f/FpS)
	return sprintf("%02d:%02d:%02d,%03d", int(s/3600), int(s%3600/60), int(s%60), int((f-s*FpS)*1000/FpS))
}
{	if ( match($0, /^\{([0-9]+)\}\{([0-9]+)\}(.+)/, Frame) == 0 || gsub(/\|/,NL,Frame[3])>1 )
		{ print "Rejecting:" $0 > "/dev/stderr" ; next }
	print NR NL timestamp(Frame[1]) " --> " timestamp(Frame[2]) NL Frame[3] NL
}