FFMpeg命令行学习笔记(4)ffmpeg命令行截取音视频里的片段

测试笔记网上看到的其他方法(-ss为开始时间 -t为持续时间,与之不同的是选项-to。

ffmpeg -i takec.mp3 -ss 00:01:12 -t 00:01:42 output_mp3.mp3)

官方文档:(音频filter即af,视频filter即vf)
6.30 atrim
Trim the input so that the output contains one continuous subpart of the input.

It accepts the following parameters:

start
Timestamp (in seconds) of the start of the section to keep. I.e. the audio sample with the timestamp start will be the first sample in the output.

end
Specify time of the first audio sample that will be dropped, i.e. the audio sample immediately preceding the one with the timestamp end will be the last sample in the output.

start_pts
Same as start, except this option sets the start timestamp in samples instead of seconds.

end_pts
Same as end, except this option sets the end timestamp in samples instead of seconds.

duration
The maximum duration of the output in seconds.

start_sample
The number of the first sample that should be output.

end_sample
The number of the first sample that should be dropped.

start, end, and duration are expressed as time duration specifications; see (ffmpeg-utils)the Time duration section in the ffmpeg-utils(1) manual.

Note that the first two sets of the start/end options and the duration option look at the frame timestamp, while the _sample options simply count the samples that pass through the filter. So start/end_pts and start/end_sample will give different results when the timestamps are wrong, inexact or do not start at zero. Also note that this filter does not modify the timestamps. If you wish to have the output timestamps start at zero, insert the asetpts filter after the atrim filter.

If multiple start or end options are set, this filter tries to be greedy and keep all samples that match at least one of the specified constraints. To keep only the part that matches all the constraints at once, chain multiple atrim filters.

The defaults are such that all the input is kept. So it is possible to set e.g. just the end values to keep everything before the specified time.

Examples:

Drop everything except the second minute of input:

ffmpeg -i INPUT -af atrim=60:120

Keep only the first 1000 samples:

ffmpeg -i INPUT -af atrim=end_sample=1000
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 中午一个亲戚来到家里吃饭,大家一起陪着聊天,小喝了两口之后,就谈到自己家里的情况,他的儿媳妇不工作,每天只负责接送...
    一个诚字阅读 3,738评论 0 0
  • 犹记得那年初见,也是如今日一般阴雨绵绵,灰暗的下午,幽深的小巷,我几乎一眼就看中了你。然后你就这样被我带在了身边。...
    唐小包呼啦呼阅读 1,396评论 0 2
  • 基本数据类型 GLenum: 用于GL枚举的无符号整型。通常用于通知OpenGL由指针传递的存储于数组中数据的类型...
    星空雪雨阅读 5,182评论 0 0

友情链接更多精彩内容