Skip to content

Commit becc4e8

Browse files
QimingQiming
authored andcommitted
Probe不抓帧时UI上清除之前展示的图片;确保抓帧时间点不超过duration
1 parent 454c182 commit becc4e8

2 files changed

Lines changed: 10 additions & 5 deletions

File tree

‎app/src/main/java/com/frank/ffmpeg/activity/ProbeFormatActivity.kt‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,8 @@ class ProbeFormatActivity : BaseActivity() {
5757
MSG_FINISH -> {
5858
progressProbe!!.visibility = View.GONE
5959
layoutProbe!!.visibility = View.VISIBLE
60-
val result = msg.obj?: msg.obj
61-
if (result != null) {
62-
val mediaInfo = JsonParseTool.stringFormat(result as MediaBean)
60+
if (msg.obj != null) {
61+
val mediaInfo = JsonParseTool.stringFormat(msg.obj as MediaBean)
6362
if (!mediaInfo.isNullOrEmpty() && txtProbeFormat != null) {
6463
txtProbeFormat!!.text = mediaInfo
6564
}
@@ -108,6 +107,7 @@ class ProbeFormatActivity : BaseActivity() {
108107

109108
when (view?.id) {
110109
R.id.btn_probe_format -> {
110+
findViewById<ImageView>(R.id.img_frame).setImageBitmap(null)
111111
doHandleProbe(filePath)
112112
}
113113
R.id.btn_retrieve_format -> {
@@ -188,7 +188,12 @@ class ProbeFormatActivity : BaseActivity() {
188188
mHandler.obtainMessage(MSG_INFO, resultBuilder.toString()).sendToTarget()
189189

190190
// Retrieve frame with timeUs
191-
val bitmap = retriever.getFrameAtTime(5 * 1000000)
191+
val frameTime = if (duration != null) {
192+
duration.toLong() / 3 * 1000
193+
} else {
194+
5 * 1000000
195+
}
196+
val bitmap = retriever.getFrameAtTime(frameTime)
192197
// Retrieve audio thumbnail, if it has embedded
193198
// val bitmap = retriever.audioThumbnail
194199
if (bitmap != null) {

‎app/src/main/java/com/frank/ffmpeg/metadata/FFmpegMediaRetriever.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class FFmpegMediaRetriever {
3131

3232
public FFmpegMediaRetriever() {
3333
native_init();
34-
native_setup();
34+
native_setup();
3535
}
3636

3737
public void setDataSource(String path) {

0 commit comments

Comments
 (0)