$str = "01:02:3.400";

function to_ms($s)
{
    $ms_t = explode('.', $s);
    $ms = next($ms_t);
    $s_t = explode(':', prev($ms_t));
    list($h, $m, $s) = $s_t;
    return $h * 60 * 60 * 1000 + $m * 60 * 1000 + $s * 1000 + $ms;
}

echo to_ms($str);
echo to_ti(to_ms($str));


function to_ti($str)
{

//    $day = $s / (24 * 60 * 60 * 1000);
    $hour = floor($str/(60 * 60 * 1000));
    $min = floor($str/(60 * 1000) - $hour * 60);
    $s = floor($str / 1000 - $hour * 60 * 60 - $min * 60);
    $ms = $str - $hour * 60 * 60 * 1000 - $min * 60 * 1000 - $s * 1000;
    return $hour . ":" . $min . ":" . $s . "." . $ms;
}

#!/usr/bin/env bash

function to_ts() {
  ((z = 60 * 60 * 1000, hour = $1 / z))
  ((z = 60 * 1000, min = $1 / z - $hour * 60))
  ((z = 60 * 60, s = $1 / 1000 - $hour * z - $min * 60))
  ((z = 60 * 60 * 1000, y = 60 * 1000, ms = $1 - $hour * z - $min * y - $s * 1000))
  echo "${hour}:${min}:${s}.${ms}"

}

function to_ms() {

    h="$(echo $1 | awk -F ":" '{print $1}')"
    m="$(echo $1 | awk -F ":" '{print $2}')"
    s="$(echo $1 | awk -F ":" '{print $3}' | awk -F "." '{print $1}')"
    ms="$(echo $1 | awk -F "." '{print $2}')"

   ((h = $h*60 * 60 * 1000));
   ((m = $m* 60 * 1000));
   ((s = $s* 1000));
   ((o = $h+$m+$s+$ms));
    echo  $o;

}
echo $(to_ms 1:2:3.400)
echo $(to_ts 3723400)

function to_ts() {
  ((z = 60 * 60 * 1000, hour = $1 / z))
  ((z = 60 * 1000, min = $1 / z - $hour * 60))
  ((z = 60 * 60, s = $1 / 1000 - $hour * z - $min * 60))
  ((z = 60 * 60 * 1000, y = 60 * 1000, ms = $1 - $hour * z - $min * y - $s * 1000))
  echo "${hour}:${min}:${s}.${ms}"

}

function to_ms() {

  h="$(echo $1 | awk -F ":" '{print $1}')"
  m="$(echo $1 | awk -F ":" '{print $2}')"
  s="$(echo $1 | awk -F ":" '{print $3}' | awk -F "." '{print $1}')"
  ms="$(echo $1 | awk -F "." '{print $2}')"

  ((h = $h * 60 * 60 * 1000))
  ((m = $m * 60 * 1000))
  ((s = $s * 1000))
  ((o = $h + $m + $s + $ms))
  echo $o

}

计算帧与毫秒

关键帧 7
视频帧 25
秒/毫秒 1000
(7/25)*1000

请联系我 商务合作、广告投放、题目勘误、侵权投诉

点赞(0)

Comment list 共有 0 条评论

暂无评论
立即
投稿
发表
评论
返回
顶部