Get length of a video using regex and ffmpeg

后端 未结 6 1440
太阳男子
太阳男子 2021-02-01 21:36

From the following ffmpeg -i output, how would I get the length (00:35)--

$ ffmpeg -i 1video.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from \'/Users/d         


        
6条回答
  •  青春惊慌失措
    2021-02-01 22:27

    for latest version :

    $cmd = "avconv -i input.mp4 2>&1 | grep Duration | awk '{print $2}' | tr -d ,";
    $output = exec($cmd);
    echo "\n\n==OUTPUT===|".$output."|=====\n\n";
    

    Now $output will hold your duration of video input.mp4

    format will be: hh:mm:ss.ms

    e.g 00:02:17.25

提交回复
热议问题