iknow4x / Android-Video-Trimmer

The Android-Video-Trimmer project implements the selection of clips for long and short videos. It uses MediaMetadataRetriever to obtain video frames, and uses ffmpeg for video cropping and video compression.
Apache License 2.0
1.09k stars 262 forks source link

长视频裁剪出来的时间不是想要的时间 #19

Closed gyymz1993 closed 6 years ago

gyymz1993 commented 6 years ago

长视频裁剪出来的时间不是想要的时间

iknow4x commented 6 years ago

@gyymz1993 裁剪后的视频时间与选择的时间段不符么?你的视频长度是多少?

gyymz1993 commented 6 years ago

image

选择一个十秒的视频 我菜三秒 结果出来的是6秒

gyymz1993 commented 6 years ago

image

iknow4x commented 6 years ago

@gyymz1993 你在文件管理器中,Storage->data->com.iknow.android->Cache目录下面,查看最新裁剪出来的视频compress.mp4 看看是多少秒

gyymz1993 commented 6 years ago

image 裁剪出来的是6秒

gyymz1993 commented 6 years ago

而且我发现一个问题 你如果改变endTime问题不大 不改变startTime的话就会出现这个问题

gyymz1993 commented 6 years ago

会不会因为视频源 我选择的这个视频是我们加了滤镜处理后的视频

iknow4x commented 6 years ago

你试试其他视频源么?

发自我的 iPhone

在 2018年7月20日,下午6:44,Yangshao notifications@github.com 写道:

会不会因为视频源 我选择的这个视频是我们加了滤镜处理后的视频

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

gyymz1993 commented 6 years ago

我看了下 播放的时长只有三秒 实际显示时长为6秒 我看到有人提到这个问题 但我按照那样加命令就不能裁剪了 应该是什么样的命令呢

gyymz1993 commented 6 years ago

而且没有失败的回调 可能会一直卡在剪切不动 没见走过异常的 如果裁剪不了就一直卡着

iknow4x commented 6 years ago

你所说的实际时间在哪看到的?

发自我的 iPhone

在 2018年7月20日,下午6:58,Yangshao notifications@github.com 写道:

我看了下 播放的时长只有三秒 实际显示时长为6秒 我看到有人提到这个问题 但我按照那样加命令就不能裁剪了 应该是什么样的命令呢

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

gyymz1993 commented 6 years ago

用手机播放器看的确还是6秒 image 用播放器播放到3秒就停了
image 我记得有人给你提过这个问题 不知道应该怎么改

iknow4x commented 6 years ago

其他人提的问题跟你现在所说的这个问题不同。 你可以把你十秒视频发给我么?

发自我的 iPhone

在 2018年7月20日,下午7:19,Yangshao notifications@github.com 写道:

用手机播放器看的确还是6秒

用播放器播放到3秒就停了

我记得有人给你提过这个问题 不知道应该怎么改

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

gyymz1993 commented 6 years ago

https://pan.baidu.com/s/1y9SmnXO3KcaM8onImefcNQ

gyymz1993 commented 6 years ago

这是裁剪的视频

gyymz1993 commented 6 years ago

https://pan.baidu.com/s/1FN86sU5BXXlCoBffrDCGFQ 这个是十秒的原视频 https://pan.baidu.com/s/1y9SmnXO3KcaM8onImefcNQ 这个是裁剪3秒后的出现的6秒的不正常视频

iknow4x commented 6 years ago

好的,谢谢!

发自我的 iPhone

在 2018年7月20日,下午7:40,Yangshao notifications@github.com 写道:

https://pan.baidu.com/s/1FN86sU5BXXlCoBffrDCGFQ 这个是十秒的原视频 https://pan.baidu.com/s/1y9SmnXO3KcaM8onImefcNQ 这个是裁剪3秒后的出现的6秒的不正常视频

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

1242128273wangpeng commented 6 years ago

我发现用ffmpeg命令行裁剪的视频长度不精准,我用ffmpeg在windows上运行命令裁剪视频,像-i -ss -t -to 挪前挪后都试过,还很容易出现黑屏或者是卡帧的情况,但是一些成熟的app就没有这种情况,会不会是jni实现的呢?作者若解决 望告知一下

iknow4x commented 6 years ago

@1242128273wangpeng 你的这个问题是因为你的命令-i -ss -t -to 需要优化成-ss -t -i 之后应该不会出现 黑屏或者是卡帧。但是裁剪视频不精准很可能与视频的关键帧有关系。

gyymz1993 commented 6 years ago

我们的就是做小视频制作 剪切都需要很精确 你这个demo是以秒为单位裁剪 我们是以毫秒裁剪的

gyymz1993 commented 6 years ago

而且这个demo有些问题 你退出后台再进的话下面的recycleview会重复 那个初始化的地方不能方式视频里面

iknow4x commented 6 years ago

嗯,现在基本都是用秒做单位的

发自我的 iPhone

在 2018年7月23日,上午10:06,Yangshao notifications@github.com 写道:

我们的就是做小视频制作 剪切都需要很精确 你这个demo是以秒为单位裁剪 我们是以毫秒裁剪的

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

gyymz1993 commented 6 years ago

我这个问题有解吗 用原生的裁剪对于那种加速的视频或者处理过的视频也会出现这种情况

iknow4x commented 6 years ago

这个问题,可以尝试从新编码后做裁剪,但是从新编码会导致裁剪很慢。

On 23 Jul 2018, at 10:16 AM, Yangshao notifications@github.com wrote:

我这个问题有解吗 用原生的裁剪对于那种加速的视频或者处理过的视频也会出现这种情况

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/iknow4/Android-Video-Trimmer/issues/19#issuecomment-406919770, or mute the thread https://github.com/notifications/unsubscribe-auth/AHDI1cjn7h7TH2vUnaF9tVLOnA78fT9sks5uJTHmgaJpZM4VV3Z6.

1242128273wangpeng commented 6 years ago

对,我试了重新编码,确实确实比之前的精确。 这篇文章有介绍:https://superuser.com/questions/499380/accurate-cutting-of-video-audio-with-ffmpeg

gyymz1993 commented 6 years ago

具体怎么用呢

gyymz1993 commented 6 years ago

String cmd = "-ss " + start + " -i " + inputFile + " -ss 0" + " -t " + duration + " -c copy -map 0 " + outputFile; 这个命令剪切出来的还可以 不过我在测试测试

iknow4x commented 6 years ago

时间对么?

gyymz1993 commented 6 years ago

有一定的误差 我还在查 image 这是我切的以前那个视频 3秒时间切出来是2949

gyymz1993 commented 6 years ago

大兄弟 虽然时间是对的 裁剪出来的视频是有问题的 还是有坑啊啊

iknow4x commented 6 years ago

@gyymz1993 说说你的问题

iknow4x commented 6 years ago

@gyymz1993 你好,请问这个问题有进展么?

gyymz1993 commented 6 years ago

嗯 找到了一个国外的大神的命令解决了这个问题 那个seekbar是你写的吗 我现在还要在上面加左右移动事件

iknow4x commented 6 years ago

嗯,你可以自己加的。

amber-yi commented 6 years ago

@gyymz1993 能告诉我你说的那个命令是什么吗