惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

C
Check Point Blog
J
Java Code Geeks
H
Hackread – Cybersecurity News, Data Breaches, AI and More
D
Docker
腾讯CDC
The GitHub Blog
The GitHub Blog
大猫的无限游戏
大猫的无限游戏
Microsoft Security Blog
Microsoft Security Blog
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
博客园 - 司徒正美
T
The Blog of Author Tim Ferriss
Vercel News
Vercel News
P
Proofpoint News Feed
雷峰网
雷峰网
博客园_首页
B
Blog RSS Feed
Microsoft Azure Blog
Microsoft Azure Blog
爱范儿
爱范儿
V
V2EX
F
Fortinet All Blogs
酷 壳 – CoolShell
酷 壳 – CoolShell
MyScale Blog
MyScale Blog
S
SegmentFault 最新的问题

jdhao's digital space

Conversion between base64 and OpenCV or PIL Image 腾讯云对象存储博客图床开启 CDN 加速(不需要购买额外域名) Search and Replace in Multiple Files in Vim/Neovim Change Table Column Width in LaTeX Image or Table Side by Side in LaTeX LaTeX 并排显示图像或表格 Firenvim: Neovim inside Your Browser Content inside HTML tags missing in Latest Hugo? Creating Markdown Front Matter with Ultisnips Labelme JSON 标注格式转 voc XML 格式 Nifty Nvim Techniques That Make My Life Easier -- Series 6 macOS 下如何为视频制作字幕 Running Command Asynchronously inside Neovim Resolving Merge Conflict after Git Stash Pop Pylint: command not found? A Hands-on Experience with Neovim's Built-in LSP Support How to Convert PDF to Images with Imagemagick 互联网上常用缩略语集锦 File Backup in Neovim Converting PDF Pages to Images with Poppler Nifty Nvim Techniques That Make My Life Easier -- Series 5 Neovim Configuration for System-wide Use How to sort a list of tuple or list in Python -- lambda or itemgetter? Building A Vim Statusline from Scratch 人类第一颗原子弹爆炸始末 Distributed Training in PyTorch with Horovod Learning Expect Programming Essential Knowledge about SSH Nifty LaTeX Techniques -- Series 1 更改 Adsense 邮寄地址,重新寄送 PIN
Process video in a certain time range with FFmpeg?
2021-12-16 · via jdhao's digital space

When dealing with videos, we may want to process video in a specific time range, for example, to only process video from 50 seconds to 70 seconds. How do we specify the time range in ffmpeg?

To specify the start position, use -ss option. This option can be used as an input option (before -i) or output option (after -i). When used as an input option, ffmpeg will directly seek the video file to that position. When used as an output option, ffmpeg will still decode frames before that position, but discards those frames. So using -ss as an input option may accelerate the processing speed dramatically.

To specify the end position, we can use -to option1. Another way is to use -t to specify a time duration.

The format for time can be found here:

There are two accepted syntaxes for expressing time duration.

[-][HH:]MM:SS[.m...]

HH  expresses the number of hours,  MM  the number of minutes for a maximum of 2 digits, and  SS  the number of seconds for a maximum of 2 digits. The  m  at the end expresses decimal value for  SS.

_or_

[-]S+[.m...][s|ms|us]

S  expresses the number of seconds, with the optional decimal part  m. The optional literal suffixes ‘s’, ‘ms’ or ‘us’ indicate to interpret the value as seconds, milliseconds or microseconds, respectively.

In both expressions, the optional ‘-’ indicates negative duration.

So to extract frame from 50 seconds to 70 seconds, we can use either of the following commands:

ffmpeg -ss 00:00:50 -to 00:01:10 -i input.mp4 -r 1 out-%2d.jpg
ffmpeg -ss 00:00:50 -t 20 -i input.mp4 -r 1 out-%2d.jpg
ffmpeg -ss 50 -t 20 -i input.mp4 -r 1 out-%2d.jpg

References#