Video screenshots, batch

Posted by csckid on Thu, 09 Dec 2021 02:20:09 +0100

Insert the code slice here
import os
import sys
import cv2
input_path = "/Users/massanli/Downloads/K"
frame_interval = int(60)
filenames = os.listdir(input_path)
video_prefix = input_path.split(os.sep)[-1]
frame_path = '{}_frames'.format(input_path)
if not os.path.exists(frame_path):
    os.mkdir(frame_path)
cap = cv2.VideoCapture()    
for filename in filenames:
    filepath = os.sep.join([input_path, filename])
    
    # The VideoCapture::open function can obtain video from a file
    cap.open(filepath)
    
    # Get video frames
    n_frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))

    # Similarly, in order to avoid the low quality of the first few frames of the video, black screen or irrelevant, etc
    
    for i in range(n_frames):
        ret, frame = cap.read()
        
        # Every frame_ The screen capture operation is performed once for the interval frame
        if i % frame_interval == 0:
            imagename = '{}_{}_{:0>6d}.jpg'.format(video_prefix, filename.split('.')[0], i)
            imagepath = os.sep.join([frame_path, imagename])
            print('exported {}!'.format(imagepath))
            cv2.imwrite(imagepath, frame)
cap.release()


# Release resources after execution



# Welcome to the Markdown editor

Hello! This is your first use **Markdown editor ** Welcome page displayed. If you want to learn how to use Markdown editor , You can read this article carefully Markdown Basic grammar knowledge.

## New changes

We are right Markdown The editor has some function expansion and syntax support, in addition to the standard Markdown Editor function, we have added the following new functions to help you blog with it:
 1. **New interface design** ,Will bring a new writing experience;
 2. Set your favorite code highlighting style in the authoring center, Markdown **The code slice displays the selected highlight style** Display;
 3. Increased **Picture drag** Function, you can drag the local picture directly to the editing area for direct display;
 4. all-new **KaTeX mathematical formula ** Grammar;
 5. Added support**Gantt chart mermaid grammar[^1]** Function;
 6. Increased **Multi screen editing** Markdown Article function;
 7. Increased **Focus writing mode, preview mode, concise writing mode, left and right area synchronization wheel settings** The function button is located between the editing area and the preview area;
 8. Increased **Checklist** Function.
 [^1]: [mermaid Syntax description](https://mermaidjs.github.io/)

## Function shortcut

revoke:<kbd>Ctrl/Command</kbd> + <kbd>Z</kbd>
Redo:<kbd>Ctrl/Command</kbd> + <kbd>Y</kbd>
Bold:<kbd>Ctrl/Command</kbd> + <kbd>B</kbd>
Italics:<kbd>Ctrl/Command</kbd> + <kbd>I</kbd>
title:<kbd>Ctrl/Command</kbd> + <kbd>Shift</kbd> + <kbd>H</kbd>
Unordered list:<kbd>Ctrl/Command</kbd> + <kbd>Shift</kbd> + <kbd>U</kbd>
Ordered list:<kbd>Ctrl/Command</kbd> + <kbd>Shift</kbd> + <kbd>O</kbd>
Checklist:<kbd>Ctrl/Command</kbd> + <kbd>Shift</kbd> + <kbd>C</kbd>
Insert code:<kbd>Ctrl/Command</kbd> + <kbd>Shift</kbd> + <kbd>K</kbd>
Insert link:<kbd>Ctrl/Command</kbd> + <kbd>Shift</kbd> + <kbd>L</kbd>
Insert picture:<kbd>Ctrl/Command</kbd> + <kbd>Shift</kbd> + <kbd>G</kbd>
Find:<kbd>Ctrl/Command</kbd> + <kbd>F</kbd>
Replace:<kbd>Ctrl/Command</kbd> + <kbd>G</kbd>

## Creating a reasonable title is helpful to the generation of the directory

Direct input once<kbd>#< / KBD > and pressing < KBD > space < / KBD > will generate a level 1 title.
Enter twice<kbd>#< / KBD > and pressing < KBD > space < / KBD > will generate a level 2 title.
By analogy, we support level 6 titles. Help to use`TOC`Generate a perfect directory after syntax.

## How to change the style of text

*Emphasis text* _Emphasis text_

**Bold text** __Bold text__

==Tag text==

~~Delete text~~

> Reference text

H~2~O is It's liquid.

2^10^ The result is 1024.

## Insert links and pictures

link: [link](https://www.csdn.net/).

picture: ![Alt](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9hdmF0YXIuY3Nkbi5uZXQvNy83L0IvMV9yYWxmX2h4MTYzY29tLmpwZw)

Picture with size: ![Alt](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9hdmF0YXIuY3Nkbi5uZXQvNy83L0IvMV9yYWxmX2h4MTYzY29tLmpwZw =30x30)

Centered picture: ![Alt](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9hdmF0YXIuY3Nkbi5uZXQvNy83L0IvMV9yYWxmX2h4MTYzY29tLmpwZw#pic_center)

Centered and sized picture: ![Alt](https://imgconvert.csdnimg.cn/aHR0cHM6Ly9hdmF0YXIuY3Nkbi5uZXQvNy83L0IvMV9yYWxmX2h4MTYzY29tLmpwZw#pic_center =30x30)

Of course, in order to make users more convenient, we have added the image drag function.

## How to insert a beautiful piece of code

go[Blog settings](https://mp.csdn.net/console/configBlog) page, select a code slice highlighting style you like, and the same highlighted 'code slice' is shown below
```javascript
// An highlighted block
var foo = 'bar';

Generate a list that suits you

  • project
    • project
      • project
  1. Item 1
  2. Item 2
  3. Item 3
  • Planning tasks
  • Complete the task

Create a table

A simple table is created as follows:

projectValue
computer$1600
mobile phone$12
catheter$1

The setting content is centered, left and right

Use: ---------: Center
Use: --------- left
Usage -----------: right

First columnSecond columnThird column
First column text centeredThe text in the second column is on the rightThe text in the third column is left

SmartyPants

SmartyPants converts ASCII punctuation characters to "smart" printed punctuation HTML entities. For example:

TYPEASCIIHTML
Single backticks'Isn't this fun?''Isn't this fun?'
Quotes"Isn't this fun?""Isn't this fun?"
Dashes-- is en-dash, --- is em-dash– is en-dash, — is em-dash

Create a custom list

Markdown Text-to- HTML conversion tool Authors John Luke

How to create a footnote

A text with footnotes. 1

Annotations are also essential

Markdown converts text to HTML.

KaTeX mathematical formula

You can render LaTeX mathematical expressions using KaTeX:

Gamma formula display Γ ( n ) = ( n − 1 ) ! ∀ n ∈ N \Gamma(n) = (n-1)!\quad\forall n\in\mathbb N Γ (n)=(n−1)! ∀ N ∈ N is through Euler integral

Γ ( z ) = ∫ 0 ∞ t z − 1 e − t d t   . \Gamma(z) = \int_0^\infty t^{z-1}e^{-t}dt\,. Γ(z)=∫0∞​tz−1e−tdt.

You can find more information about LaTeX mathematical expressions here.

New Gantt chart features to enrich your articles

  • For Gantt chart syntax, refer to here,

UML diagram

UML diagrams can be used for rendering. Mermaid For example, a sequence diagram is generated as follows:

This will produce a flowchart.:

  • For Mermaid syntax, see here,

FLowchart

We will still support the flowchart of flowchart:

  • For Flowchart syntax, refer to here.

Export and import

export

If you want to try this editor, you can edit it at will in this article. When you have finished writing an article, find the article export in the upper toolbar and generate a. md file or. html file for local saving.

Import

If you want to load an. md file you have written, you can select the import function in the upper toolbar to import the file with the corresponding extension,
Continue your creation.

  1. Explanation of footnotes ↩︎