microshow / RxFFmpeg

🔥💥RxFFmpeg 是基于 ( FFmpeg 4.0 + X264 + mp3lame + fdk-aac + opencore-amr + openssl ) 编译的适用于 Android 平台的音视频编辑、视频剪辑的快速处理框架,包含以下功能:视频拼接,转码,压缩,裁剪,片头片尾,分离音视频,变速,添加静态贴纸和gif动态贴纸,添加字幕,添加滤镜,添加背景音乐,加速减速视频,倒放音视频,音频裁剪,变声,混音,图片合成视频,视频解码图片,抖音首页,视频播放器及支持 OpenSSL https 等主流特色功能

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

裁剪报错:因项目需要,裁剪要支持 0.1秒级别的裁剪

wuxinggege008 opened this issue · comments

命令行:-ss 00:00:00.7 -t 00:01:03.4 -accurate_seek -i input.mp4 -codec copy -avoid_negative_ts 1 output_clip.mp4

相关日志
2022-08-19 18:21:55.862 I/TAG_FFMPEG: Metadata:
2022-08-19 18:21:55.862 I/TAG_FFMPEG: creation_time :
2022-08-19 18:21:55.862 I/TAG_FFMPEG: 2022-08-18T02:19:08.000000Z
2022-08-19 18:21:55.862 I/TAG_FFMPEG:
2022-08-19 18:21:55.862 I/TAG_FFMPEG: handler_name :
2022-08-19 18:21:55.862 I/TAG_FFMPEG: VideoHandle
2022-08-19 18:21:55.862 I/TAG_FFMPEG:
2022-08-19 18:21:55.862 D/TAG_FFMPEG: Successfully opened the file.
2022-08-19 18:21:55.862 D/TAG_FFMPEG: Parsing a group of options: output url 00:00:00.7.
2022-08-19 18:21:55.862 D/TAG_FFMPEG: Successfully parsed a group of options.
2022-08-19 18:21:55.862 D/TAG_FFMPEG: Opening an output file: 00:00:00.7.
2022-08-19 18:21:55.862 E/TAG_FFMPEG: Unable to find a suitable output format for '00:00:00.7'
2022-08-19 18:21:55.862 E/TAG_FFMPEG: 00:00:00.7: Invalid argument
2022-08-19 18:21:55.862 D/TAG_FFMPEG: Statistics: 453336 bytes read, 3 seeks
2022-08-19 18:21:55.863 A/libc: Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x4a0 in tid 11258 (RxCachedThreadS), pid 11105

我也遇到了同样场景,经过尝试貌似解决了,目前没有遇到抛错了;首先得依赖完整包,然后构建命令:
new RxFFmpegCommandList()
.append("-ss")
.append(CommUtils.videoTimeCut(start))
.append("-to")
.append(CommUtils.videoTimeCut(end))
.append("-accurate_seek")
.append("-i")
.append(info.path)
.append("-c:v")
.append("libx264")
.append("-avoid_negative_ts")
.append("1")
.append(file.getAbsolutePath())

获取裁剪时间:
public static String videoTimeCut(long time) {
final int ms = (int) (time % 1000);
final int t = (int) (time / 1000);
final int s = t % 60;
final int m = t / 60 % 60;
final int h = t / 3600;
return new Formatter(new StringBuilder(), Locale.getDefault()).format("%02d:%02d:%02d.%03d", h, m, s, ms).toString();
}