<p>Ended up using a batch file to export the timings to a text file and then turncate the value as a set variable.</p>

<pre><code>ffprobe -i {filepath$} -show_entries format=duration -v quiet -of csv="p=0" &gt;&gt; duration.txt
setlocal enabledelayedexpansion
for /f "tokens=1,2,3,8 delims=\ " %%a in (duration.txt) do (
  for /f "tokens=1 delims=." %%i in ("%%a") do set _stime=%%i
)
</code></pre>

CC BY-SA 3.0
2017-08-23T01:56:11.583Z
You've gotta try powershell some time. You won't regret it.
stib
CC BY-SA 3.0
2017-08-22T22:11:16.330Z
2017-08-22T22:11:16.330Z
Arete
<p>If I use ffprobe to output the duration of a video file with:</p>

<pre><code>ffprobe -i input.mkv -show_entries format=duration -v quiet -of csv="p=0"
</code></pre>

<p>I will get something like</p>

<pre><code>3658.342000
</code></pre>

<p>How can I get the output in second only without the decimals? I do not mind if ffmpeg or Mediainfo has a better function for this. I just need to get the output in seconds.</p>

<p><em>I am using CMD in Win10.</em></p>

CC BY-SA 3.0
2017-08-20T17:27:49.787Z
I am unaware of an option within `ffprobe` to do what you want, but you can truncate or round the duration value using your preferred shell or scripting language.
llogan
CC BY-SA 3.0
2017-08-21T05:22:48.443Z
With cmd you have to write your own rounding function. https://stackoverflow.com/questions/23116014/batch-rounding-a-number Have you considered using Powershell? Then it's just `[math]::round(x)`. Note that you'll have to extract the number from ffprobe's output somehow.
stib
CC BY-SA 3.0
2017-08-22T08:46:57.260Z
`[math]::round((ffprobe 'input.mkv' -show_entries format=duration -v quiet -of csv="p=0"))` works in powershell. Note the double brackets.
stib
<ffmpeg>
Echo duration of video in seconds without decimals
Arete
# Echo duration of video in seconds without decimals

(Asked by: username_0 on 2017-08-20)

If I use ffprobe to output the duration of a video file with:
ffprobe -i input.mkv -show_entries format=duration -v quiet -of csv="p=0"

I will get something like
3658.342000

How can I get the output in second only without the decimals? I do not mind if ffmpeg or Mediainfo has a better function for this. I just need to get the output in seconds.
I am using CMD in Win10.

**Tags:** ffmpeg

> **Comments:**
> **username_1**: I am unaware of an option within `ffprobe` to do what you want, but you can truncate or round the duration value using your preferred shell or scripting language.  
> **username_2**: With cmd you have to write your own rounding function. https://stackoverflow.com/questions/23116014/batch-rounding-a-number Have you considered using Powershell? Then it's just `[math]::round(x)`. Note that you'll have to extract the number from ffprobe's output somehow.  
> **username_2**: `[math]::round((ffprobe 'input.mkv' -show_entries format=duration -v quiet -of csv="p=0"))` works in powershell. Note the double brackets.  

---

## 1 answers

### Answer by username_0 on 2017-08-22. Score: 0 | Accepted answer

Ended up using a batch file to export the timings to a text file and then turncate the value as a set variable.
ffprobe -i {filepath$} -show_entries format=duration -v quiet -of csv="p=0" >> duration.txt
setlocal enabledelayedexpansion
for /f "tokens=1,2,3,8 delims=\ " %%a in (duration.txt) do (
  for /f "tokens=1 delims=." %%i in ("%%a") do set _stime=%%i
)

> **Comments:**
> **username_2**: You've gotta try powershell some time. You won't regret it.  

---

