I have a segment of a webm file with an incomplete header, I want to cut this segment down to 10 seconds by trimming x seconds off the front of the file, however I am unable to use the -sseof
tag because the end of the file isn't defined. I have discovered that if I ask ffmpeg to pull out the audio or video from the file it responds with some data long the lines of size=212kB time=00:00:13.32 bitrate= 130.2kbits/s speed=1.79e+03x video:0kB audio:210kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.991311%
Showing that there is 13.32 seconds of data in the file, however if I use ffprobe for the file length it replies with N/A
. Is there a way to get that 13.32 value by itself without encoding the webm file?
Asked
Active
Viewed 557 times
-1

Neil Hutcheon
- 19
- 3
3 Answers
0
You could use python and opencv to get the details of the video then pass them to:
import cv2
file = os.path.basename(filename)
video_file = filename
cap = cv2.VideoCapture(video_file)
# get video details
framespersecond= int(cap.get(cv2.CAP_PROP_FPS))
video_total_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
duration = video_total_frames/framespersecond
end_time = duration - 10
# Something like this to clip with ffmpeg.
ffmpeg_extract_subclip(file, start_time, end_time, targetname="test.mp4")

Pullmyleg
- 21
- 4
0
Try
ffprobe -hide_banner -loglevel quiet \
-of default=nk=1:nw=1 -show_entries format=duration INPUT_FILE
This command just prints the total duration in seconds.

kesh
- 4,515
- 2
- 12
- 20
-
This is the command I used that returns ```N/A``` – Neil Hutcheon Aug 18 '22 at 15:37
-
1@NeilHutcheon - Yeah, some format/codec do not store duration, but if it does, this is a simpler and faster option. – kesh Aug 18 '22 at 16:10
0
I was informed that:
ffprobe -v 0 -hide_banner -of compact=p=0:nk=1 -show_entries packet=pts_time -read_intervals 99999%+#1000 input.webm | tail -1
will return the timestamp of the last packet of data. This is what I was looking for.

Jeremy Caney
- 7,102
- 69
- 48
- 77

Neil Hutcheon
- 19
- 3