I have a small 30 second video that was taken from a long 10h video and processed. I am trying to find the position of the first frame from the 30 second video in the long 10h video. Because the small video has been processed, checksuming the frames doesn't work so I tried saving the first frame as an image,
ffmpeg -i clip.mp4 -qmin 1 -qscale:v 1 -vframes 1 -f image2 firstframe.jpg
and then using that image using that image to search it like this:
ffmpeg -i original_stream.ts -loop 1 -i firstframe.jpg -an -filter_complex "blend=difference:shortest=1,blackframe=99:32" -f null -
This sometimes works, but at times it returns more than 1 frame no matter what blackframe
I'm using.
Also, if I try to use -ss
to skip a part of the stream it doesn't return the precise time. For example,
- Without
-ss
:[Parsed_blackframe_1] frame:44250 pblack:99 pts:66375000 t:737.500000 type:P last_keyframe:44160
- With
-ss 735
:[Parsed_blackframe_1] frame:90 pblack:99 pts:227820 t:2.531333 type:P last_keyframe:0
- The times from the two examples above don't match up. Since
t
in example #1 is737.500000
, I would expectt
in example #2 to be2.500000
, not2.531333
:737.500000-735=2.500000
- Also,
735 x 90000 + 227820 ≠ 66375000
I think I can use the frame number as that seems to be the most accurate.
The whole reason I'm doing this is to extract the exact audio from the original stream that matches the 30 second clip so I need the exact position.