I am using this library to use FFmpeg with my Android application. I am extracting frames from a video and then adding them to a crop viewer. So each frame needs to represent some time frame within the video. Here is my current ffmpeg code to extract the frames:

我正在使用这个库在我的Android应用程序中使用FFmpeg。我从视频中提取帧,然后将它们添加到剪辑查看器中。所以每个帧都需要在视频中表示某个时间帧。下面是我目前提取帧的ffmpeg代码:

ffmpeg -i inputFile -f image2 -ss mySS -r myR frame-%05d.png

ffmpeg -i inputFile -f image2 -ss mySS -r myR框架-%05d.png

When using the above command how would I add a timestamp to each frame? So i know for example frame 5 is at 9s within the video.

当使用上述命令时,如何向每个帧添加时间戳?例如,我知道视频中的第五帧是9秒。

I dont know if the ffmpeg lib I am using has ffprobe from this link. I have also looked at other links on stackoverflow

我不知道我使用的ffmpeg库是否有来自这个链接的ffprobe。我还查看了stackoverflow上的其他链接

any help is appreciated

任何帮助都是赞赏

1 个解决方案

#1


1

To burn the timestamp in the video:

烧掉视频中的时间戳:

ffmpeg -i inputFile -vf drawtext=fontfile='/path/to/font':fontcolor=white:fontsize=25:x=(w-tw)/2:y=h-th-10:text='Source time: %{pts}' -ss mySS -r myR frame-%05d.png

If you have a > Nov 13 2017 build of FFmpeg, you can run

如果您有一个> 2017年11月13日构建的FFmpeg,您可以运行

ffmpeg -i inputFile -f image2 -vf select='gte(t,mySS)' -vsync 0 -frame_pts 1 frame-%05d.png

This will number the output frames with the source frame index.

这将使用源帧索引对输出帧进行编号。

If you can't upgrade FFmpeg, then there's a longer workaround.

如果您不能升级FFmpeg,那么还有一个更长的解决方案。

Run

运行

ffmpeg -i inputFile -f image2 -vf select='gte(t,mySS)',showinfo -vsync 0 frame-%05d.png 2> log.txt

This will redirect the console to a text file. In it, you will lines like this:

这将把控制台重定向到一个文本文件。在里面,你会看到这样的句子:

...
     Metadata:
      encoder         : Lavc58.1.100 wrapped_avframe
[Parsed_showinfo_1 @ 00000000056d9dc0] n:   0 pts:  38400 pts_time:3       pos:   105928 fmt:yuv420p sar:1/1 s:320x240 i:P iskey:0 type:B checksum:F6027584 plane_checksum:[FAA4D7FC 4748A9ED 4767F37D] mean:[123 129 126] stdev:[57.1 78.2 80.6]
[Parsed_showinfo_1 @ 00000000056d9dc0] n:   1 pts:  38912 pts_time:3.04    pos:   101527 fmt:yuv420p sar:1/1 s:320x240 i:P iskey:0 type:P checksum:ECBC791A plane_checksum:[4104BBD1 4805B985 542303B5] mean:[123 129 126] stdev:[57.1 78.1 80.5]
[Parsed_showinfo_1 @ 00000000056d9dc0] n:   2 pts:  39424 pts_time:3.08    pos:   108798 fmt:yuv420p sar:1/1 s:320x240 i:P iskey:0 type:B checksum:70B2AC23 plane_checksum:[EF78A2F1 946CDA4F 39B72ED4] mean:[123 129 127] stdev:[57.1 77.8 80.1]
...

You can parse and extract the pts_time values, which have a 1:1 correspondence with the produced images.

您可以解析和提取pts_time值,该值与生成的映像具有1:1的对应关系。

更多相关文章

  1. 王家林最受欢迎的一站式云计算大数据和移动互联网解决方案课程 V
  2. 使用mediaplayer + surfaceview来播放视频
  3. 在网页程序或Java程序中调用接口实现短信猫收发短信的解决方案
  4. 有没有做过java的jsp页面调用海康视频的sdk二次开发……
  5. java网上在线支付实战视频
  6. javascript(六)js事件绑定浏览器兼容解决方案 attachEvent addEve
  7. JAVA视频笔记(day5)
  8. java中多线程安全问题产生&解决方案——同步方法

随机推荐

  1. Android 使用grade实现Android 项目debug
  2. Android Geocoder(位置解析)
  3. Android Studio 使用小结
  4. android 线性布局几个属性
  5. Android 3D 编程:索引
  6. zbar android sdk源码编译
  7. 如何调试跟踪Android源代码
  8. android字体大小的设置
  9. 初涉Android蓝牙开发
  10. Android能够获取到唯一的设备ID吗?