我花了几个星期的时间在这里测试了在Android上使用FFMPEG进行无损切割的所有答案。不管我怎么试,我总是迷路。在我们正在构建的应用程序中,我们需要精确到毫秒。
我已经尝试了许多命令的变体,其中很多都超过了半秒。这是用于复制和重新编码的。有了这个,我尝试了-ss之前和之后,以及在这两个位置,但我看不到任何区别。这是两个工作得最好的命令,但仍然不够接近:
//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"
是否有人使用过命令或其他库来提供更准确的结果?
发布于 2019-05-22 18:16:26
在寻找了几天之后,我在FFMPEG中最接近毫秒级的精确裁剪是使用以下命令:
"-ss $startCutTime -i $inputFilePath -ss 0 -c copy -to $endCutTime -avoid_negative_ts make_zero $outputFilePath"
此命令精确到30fps剪辑的20分之一毫秒,但这将完全取决于您的视频的帧率。我希望这能帮助其他人。下面是每个组件的功能说明:
/**
* 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
*/
https://stackoverflow.com/questions/56057725
复制相似问题