首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FFMPEG在Android中没有像预期的那样“剪切”

FFMPEG在Android中没有像预期的那样“剪切”
EN

Stack Overflow用户
提问于 2020-12-22 12:40:51
回答 1查看 135关注 0票数 0

我建议FFMPEG not "cutting" as expected将视频分成块,格式如下:

00:00:00 - 00:00:01

00:00:01 - 00:00:02

00:00:02 - 00:00:03

00:00:03 - 00:00:04

00:00:04 - 00:00:05

下面是我使用的命令:

代码语言:javascript
复制
String[] cmd1 = new String []{"-ss", "00:00:00.000", "-i", inputVideoUrl, "-t", "00:00:01.000", "-c:v", "libx264", "-strict", "-2", outputPath};

String[] cmd2 = new String []{"-ss", "00:00:01.000", "-i", inputVideoUrl, "-t", "00:00:02.000", "-c:v", "libx264", "-strict", "-2", outputPath};

String[] cmd3 = new String []{"-ss", "00:00:02.000", "-i", inputVideoUrl, "-t", "00:00:03.000", "-c:v", "libx264", "-strict", "-2", outputPath};

String[] cmd4 = new String []{"-ss", "00:00:03.000", "-i", inputVideoUrl, "-t", "00:00:04.000", "-c:v", "libx264", "-strict", "-2", outputPath};

String[] cmd5 = new String []{"-ss", "00:00:04.000", "-i", inputVideoUrl, "-t", "00:00:05.000", "-c:v", "libx264", "-strict", "-2", outputPath};

我使用的是这个库:https://github.com/teanersener/mobile-ffmpeg

代码语言:javascript
复制
implementation 'com.arthenica:mobile-ffmpeg-full-gpl:4.2.2.LTS'

当我执行的时候,我会一直得到从视频开头开始的持续时间。请建议我做错了什么,我搜索并尝试更改命令,但都不起作用。

00:00:00 - 00:00:01

00:00:00 - 00:00:02

00:00:00 - 00:00:03

00:00:00 - 00:00:04

00:00:00 - 00:00:05

让我分享另一个例子来解释我的要求: inputVideoUrl包含任何长度的视频(例如:5分钟)我想将它的用户选择的部分(例如第一个1分钟)剪切为5个分割视频的形式。

拆分1: 00秒-12.0秒

split 2: 12.1秒-24.0秒

拆分3: 24.1秒-36.0秒

split 4: 36.1秒-48.0秒

split 5: 48.1秒-60.0秒

稍后,我将把这些分割的视频提供给播放器播放列表。

EN

回答 1

Stack Overflow用户

发布于 2020-12-23 04:09:05

使用段复用器

您可以在segment muxer中使用一条命令执行所有操作

代码语言:javascript
复制
ffmpeg -i input -c:v libx264 -c:a aac -f segment -segment_time 1 -force_key_frames "expr:gte(t,n_forced*1)" -reset_timestamps 1 output_%03d.mp4

expr:gte(t,n_forced*1)中的数值应等于-segment_time值(在本例中为1 )。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/65403348

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档