批次转换时间code至帧数 [英] Batch that convert TIMECODE to frame number

查看:265
本文介绍了批次转换时间code至帧数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个批处理有一个名为%的时间code%一envoroment变量,如果时间code存在和定义,输出这种类型的字符串:

  HH:MM:SS:FF

例如01:32:21:05

在PAL模式,25fps的,我想转换这个时候code在他的通讯员帧数,对于rxample在01的情况下:32:21:05 138530

所以转换处理应该输出138530

 另一个例子:00:00:00:00 ----------------> 0
00:00:00:01 ----------------> 1
........
00:00:00:24 ----------------> 24
00:00:01:00 ----------------> 25
00:00:01:01 ----------------> 26

和等
我该怎么办?


解决方案

 关闭@echo
    SETLOCAL ENABLEEXTENSIONS disabledelayedexpansion
    设置帧率= 25    设置时间code = 01:32:21:05    FOR / F令牌= 1-4 delims =%%一中(
        100%的时间code :: 0 =:%
    )并设置/帧=((%%一个%% 100)* 3600 +(%% B0)* 60/10 +(%% C0)/ 10)*%帧率%+(%% D0)/ 10     回声%框%

这code分割使用冒号作为分隔符时code变量的内容。为了说明零prefixed字段(八进制形式审议并的情况下,问题的 08 09 ) ,丢失或损坏格式的数据,一些招数被使用。

要纠正小时部分,输入数据与 pfixed $ P $ 100 键,该字段将被处理模100。

要处理问题零prefixed领域,一个冒号后面的输入数据的零被替换为同一冒号后面有一个空格。

要处理与失踪领域的问题,做所有提取的数据后缀零(10 mutiplying吧)Calcs(计算),并在这一领域运作的结果时,除以10

in a batch there is a envoroment variable called %timecode% that, if timecode exist and is defined, output a string of this type:

HH:MM:SS:FF

for example 01:32:21:05

In PAL mode, 25fps, I would like convert this timecode in his correspondant frame number, for rxample in the case of 01:32:21:05 is 138530

so the convert processing should output 138530

Another examples: 00:00:00:00 ----------------> 0
00:00:00:01 ----------------> 1
........
00:00:00:24 ----------------> 24
00:00:01:00 ----------------> 25
00:00:01:01 ----------------> 26

and so on How can I do?

解决方案

@echo off
    setlocal enableextensions disabledelayedexpansion
    set "frameRate=25"

    set "timecode=01:32:21:05"

    for /f "tokens=1-4 delims=:" %%a in (
        "100%timecode::0=: %"      
    ) do set /a "frame=((%%a %% 100)*3600 + (%%b0)*60/10 + (%%c0)/10) * %frameRate% + (%%d0)/10"

    echo %frame%

This code splits the timecode variable contents using the colons as delimiters. To account for zero prefixed fields (considered in octal form and problematic in the case of 08 or 09), missing or bad formatted data, some "tricks" are used.

To correct the hour part, the input data is prefixed with 100 and this field will be handled modulo 100.

To handle the problematic zero prefixed fields, a colon followed by a zero in the input data is replaced with the same colon followed by a space.

To handle problems with missing fields, when doing the calcs all extracted data is suffixed with a zero (mutiplying it by 10) and the the result of the operation in this field is divided by 10

这篇关于批次转换时间code至帧数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆