Home  >  Q&A  >  body text

java - Android如何快速获取视频每秒缩略图

  1. 最近项目想要像新版微信那样只能分享10s以内的视频,需要对超过10s的视频进行裁剪和获取视频每秒的缩略图,
    裁剪压缩功能都已经实现,主要是获取视频每秒的缩略图功能,利用ffmpeg获取比较慢,需要等待很长时间,无法像微信那样进入视频编辑页面就可以直接浏览视频每秒的缩略图

  2. 利用ffmpeg获取视频每秒缩略图(每秒输出一个图像)

    ffmpeg -i input.flv -vf fps=1 out%d.png
  3. 获取的时间较长,反编译微信发现微信里面也是利用ffmpeg,是否有更快速的命令获取?

  4. 也尝试过使用MediaMetadataRetriever.getFrameAtTime获取,获取时间更加漫长

  5. 大佬求教!!!

黄舟黄舟2742 days ago646

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-04-18 10:57:42

    ffmpeg supports outputting multiple formats at the same time. You can output screenshots while recording. For example, ffmpeg -i /path/to/stream/file -f rawvideo -pix_fmt nv21 -s 640x480 -r 15 video.mp4 -vf fps=1 out%d.png,其中 /path/to/stream/file 是Java方面创建的文件,把从摄像机获取的视频数据写进这个文件让ffmpeg读取。-f rawvideo -pix_fmt nv21 -s 640x480 -r 15are all parameters for configuring the video.

    reply
    0
  • Cancelreply