首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >使用FFMPEG实现毫秒级无损视频裁剪

使用FFMPEG实现毫秒级无损视频裁剪
EN

Stack Overflow用户
提问于 2019-05-09 18:48:19
回答 1查看 2.7K关注 0票数 1

我花了几个星期的时间在这里测试了在Android上使用FFMPEG进行无损切割的所有答案。不管我怎么试,我总是迷路。在我们正在构建的应用程序中,我们需要精确到毫秒。

我已经尝试了许多命令的变体,其中很多都超过了半秒。这是用于复制和重新编码的。有了这个,我尝试了-ss之前和之后,以及在这两个位置,但我看不到任何区别。这是两个工作得最好的命令,但仍然不够接近:

代码语言:javascript
复制
//copy
"-ss $startTime -t $endTime -i $input -f segment -c copy $output"

//encode
"-i $input -ss $startTime -c:v libx264 -crf 12 -preset ultrafast -t $endTime $output"

是否有人使用过命令或其他库来提供更准确的结果?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-05-22 18:16:26

在寻找了几天之后,我在FFMPEG中最接近毫秒级的精确裁剪是使用以下命令:

代码语言:javascript
复制
"-ss $startCutTime -i $inputFilePath -ss 0 -c copy -to $endCutTime -avoid_negative_ts make_zero $outputFilePath"

此命令精确到30fps剪辑的20分之一毫秒,但这将完全取决于您的视频的帧率。我希望这能帮助其他人。下面是每个组件的功能说明:

代码语言:javascript
复制
/**
     * FFMPEG Cmd Structure
     * -i: Input file
     * -ss: If this is placed before the input file it seeks to this position in the input file. If it's after the input it will split from that exact position.
     * -to: The position of where the command is going to cut to.
     * -c copy: This copies the video and audio codecs as they are for speed.
     * -avoid_negative_ts make_zero: Sets the first timestamp as 0
     * The times are passed in parsed eg 00:00:10.456
     * The output file is the last part of the command
     */
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56057725

复制
相关文章

相似问题

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