[FFmpeg-user] How to get video duration in a script using ffmpeg?

Bo Berglund bo.berglund at gmail.com
Wed Jan 19 19:49:37 EET 2022


On Wed, 19 Jan 2022 18:26:21 +0530, Gyan Doshi <ffmpeg at gyani.pro> wrote:

>
>
>On 2022-01-19 05:29 pm, Bo Berglund wrote:
>> On Wed, 19 Jan 2022 17:10:26 +0530, Gyan Doshi <ffmpeg at gyani.pro> wrote:
>>
>>>> What do I need to just get that output I want?
>>> The closest you can get is
>>>
>>>       ffprobe -v 0 -of compact=p=0:nk=1 -sexagesimal -show_entries
>>> format=duration INPUT
>> Thanks, this returns the following output:
>> 0:43:26.384000
>>
>> Can the duration be limited to only seconds resolution (no decimals)?
>>
>>
>
>
>ffprobe -v 0 -of compact=p=0:nk=1 -sexagesimal -show_entries
>format=duration INPUT | grep -oP "^[\d:]+"
>
Nope...

ffprobe -v 0 -of compact=p=0:nk=1 -sexagesimal -show_entries format=duration
test.mp4 | grep -oP "^[\d:]+"

did not work at all! It returned an empty string (nothing)
whereas this:

ffprobe -v 0 -of compact=p=0:nk=1 -sexagesimal -show_entries format=duration
test.mp4

returned this result:

1:08:00.002000

Seems like your grep construct does not work.


-- 
Bo Berglund
Developer in Sweden



More information about the ffmpeg-user mailing list