lossless-cut icon indicating copy to clipboard operation
lossless-cut copied to clipboard

[Feature Request] Extract all video frames to snapshots every n {frames|seconds}

Open Paperone80 opened this issue 2 years ago • 1 comments

Please first search for your feature request under Issues or Discussions, maybe someone else already suggested it.

Is your feature request related to a problem? Please describe. I've been looking for a reliable way to extract snapshots every n seconds or frames with human readable timestamps mm:hh:ss.ms like your snapshots, e.g. DJI_0067-00.03.05.069.png. You already have a single snapshot.

Describe the solution you'd like Would like to give technical people a tool to do it instead of a script. And maybe under Tools > "Extract images" > Dialog for every n frames|seconds and Image Quality settings.

Describe alternatives you've considered Currently I am using a bash script:

  • ffmpeg to extract the frames with ... -vf select="not(mod(n,X)-frame_pts true -r 1000 ...
  • regex to convert filenames with milliseconds from ffmpeg into mm:hh:ss.ms

FFMPEG settings which proved to be most reliable when comparing VLC, LosslessCut and these frames at 1s manually:

every_n_seconds=2

video_fps_frac=$(ffprobe  \
   -v 0  -of csv=p=0  -select_streams v:0  -show_entries stream=r_frame_rate \
   $vf)

video_fps=$(bc <<< "scale=8;$video_fps_frac")

every_n_frames=$(bc <<< "scale=2; ${video_fps}*${every_n_seconds}")

ffmpeg  \
   -an \
   -ss 00:00:00.0000
   -i <input> \
   -vsync vfr \
   -qmin 1 -qmax 1 -q:v 1 
   -vf select="not(mod(n\,round(${every_n_frames})))" \
   -frame_pts true -r 1000 \
   -f image2 \
   <output>-ms-%8d.png

then regex and conversion into for example DJI_0067-00.03.05.069.png

I looked at CLI with VLC and mplayer. Looked at online tools but couldn't find a way which is user friendly and reliably. Even FFMPG with -vf fps=1 would mess up the 00:00:00.000 timestamp by 500ms.

Thanks

Paperone80 avatar May 08 '22 05:05 Paperone80

note that lossless-cut uses ffmpeg underneath. So the solution would involve finangling ffmpeg commands and then potentially adding a hack to offset by 500ms if required.

alex-ong avatar Aug 04 '22 21:08 alex-ong

Not sure where the 500ms comes from. Is it constant, and why?

mifi avatar Jan 06 '23 12:01 mifi

have now implemented this. from my testing the timestamps are accurate

mifi avatar Jan 06 '23 15:01 mifi

I am trying to find this feature on Lossless. Could you please tell me where to find it?

Specifically, I am looking for this: Export ranges of video frames to images (every nth frame, second, by scene change, best thumbnails) Export only from a selected time range (segment)

easyspace avatar Jan 06 '24 19:01 easyspace

right click on a segment in the right segment list, then "extract frames as image files"

mifi avatar Jan 09 '24 08:01 mifi