video player that shows milliseconds

8

2

I need to play MP4 files on my win7 which apart from minutes and seconds, should display the milliseconds.

I currently have GOM, VLC and MPC-HC. (Note that I want to use a regular lightweight video player and not having to load the file in a video editing program such as sony vegas etc).

The closest I could get at is by using MPC-HC, adding a dummy srt (subs) file for the video and enabling the Subresync option (as shown at https://trac.mpc-hc.org/ticket/3700). This shows the desired format of mm:ss.SSS. But creating a dummy srt (which should contain at least 1 subtitle entry in order for the Subresync option to be enabled) is cumbersome.

Is there another solution?

cherouvim

Posted 2015-08-30T07:49:33.547

Reputation: 819

Answers

11

You nearly had it. Media Player Classic (MPC-HC) has this option already build in. Right click on the time stamp at the bottom right and choose High precision

enter image description here

Other Players like VLC, SMPlayer, Mplayer, KMPlayer don't have this option. Despite the fact that KMPlayer has literally a thousand configuration options

But the subtitle workaround works with any player. Here demonstrated for VLC

nixda

Posted 2015-08-30T07:49:33.547

Reputation: 23 233

2

Here is the code (in python) to generate the subtitle file for subtitle workaround:

def generateSRTFile(fileName, duration):
    """ 
    Generate SRT (subtitle) file for micro second display in video 

    fileName: "Movie1.srt"
    duration: "00:12:54"

    NOTE: ignored seconds to make the program more simplified
    """
    # get the hours, min, sec from duration
    time_split = duration.split(':')
    hours = int(time_split[0])
    minutes = int(time_split[1])
    seconds = 59 # int(time_split[2])
    millisecs = [x*10 for x in range(0,100)]

    # open a file to write
    f = open(name=fileName, mode='w', buffering=1)

    # iterate to print to file
    blockNo = 1
    for h in range(hours+1):
        for m in range(minutes+1):
            for s in range(seconds+1):
                for ms in millisecs:
                    f.write(subtitle(h, m, s, ms, blockNo))
                    blockNo += 1
    # close the file
    return f.close()

def subtitle(h, m, s, ms, bn):
    """
    Returns the subtitle block for the given parametes
    h: hours, m: minutes, s: seconds, ms: milli seconds, bn: block number
    """
    block = ""
    block += formatToString(bn) + "\n"
    time_line = formatToString(h)+":"+formatToString(m)+":"+formatToString(s)+","
    block += time_line+formatToString(ms, 3) + " --> " + time_line + \
        formatToString(ms+10 if ms!=990 else 999, 3) + "\n"
    block += "time " + time_line + formatToString(ms ,3) + "\n\n"
    return block

def formatToString(num, length=2):
    """
    Format given number to given length. 
    i.e num = 5 and length = 2. Result = "05" 
    """
    # number of digits in num
    digits = len(str(num))

    # mathematical equivalent for finding digits
    #n = num
    #digits = 0
    #if n==0:
        #digits = 1
    #else:
        #while n:
            #n = n/10
            #digits += 1

    # find how much shorter is num than length
    if digits >= length:
        strNum = str(num)
    else:
        diff = length-digits
        strNum = ""
        for i in range(diff):
            strNum += "0"
        strNum += str(num)
    # return
    return strNum

if __name__=="__main__":
    generateSRTFile(fileName='/home/inblueswithu/Downloads/default.srt', duration="00:05:56")

inblueswithu

Posted 2015-08-30T07:49:33.547

Reputation: 121