Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

statistics.getTime() returns always total time of input file in milli seconds during the process #958

Open
HamzaBula opened this issue Apr 10, 2024 · 16 comments
Labels
all-platforms ffmpeg-bug Something isn't right in ffmpeg source code library Affects the library v4.4 Affects v4.4 release v4.5.1 Affects v4.5.1 release v5.1 Affects v5.1 release v6.0

Comments

@HamzaBula
Copy link

HamzaBula commented Apr 10, 2024

Description
In 6.0-2 android how can i get the percentage because statistics.getTime() returns always total time of input file in milli seconds during the process but it was working proper in previous version 4.4.LTS because in that version it was returning the time based on how much process has complete.

Expected behavior
The time value should have to increase with ongoing video processing.

Current behavior
It is returning total time of input file every time.

Screenshots
Here is the screenshot for 4.4.LTS (frame and time both are perfect here)
Screenshot (31)

Here is the screenshot for 6.0-2 (frame is perfect but time is not)
Screenshot (30)

Logs
Here is the log for 4.4.LTS
12:15:07.980 E frame= 2 fps=1.2 q=2.0 size= 0kB time=00:00:00.04 bitrate= 8.8kbits/s speed=0.0244x
12:15:08.498 D frame: 27, time: 1040
12:15:08.505 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=13 outputFps=14 renderFps=0, discardFps=1
12:15:08.506 D mPausedTimes=0
12:15:08.506 D mPausedTimes mEDRDelayTime=0 pauseTimes=1
12:15:08.507 D [notifyStatusToSF:L31] hdrtype is 0
12:15:08.508 E frame= 27 fps= 13 q=8.1 size= 512kB time=00:00:01.04 bitrate=4033.0kbits/s speed=0.485x
12:15:08.554 D [0xb400007399f24ac0] pipelineFull: too many frames in pipeline (6)
12:15:08.555 D [0xb400007399f24ac0] pipelineFull: too many frames in pipeline (6)
12:15:08.596 D getStreamVolume packageName=com.kli.inappdemo, index=0, streamType=3
12:15:08.710 D getStreamVolume packageName=com.kli.inappdemo, index=0, streamType=3
12:15:08.858 I 0xb4000074a3419f00 c2.android.mpeg4.decoder 540x960 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:08.858 D mPausedTimes=3
12:15:08.858 D mPausedTimes mEDRDelayTime=0 pauseTimes=4
12:15:08.858 D [notifyStatusToSF:L31] hdrtype is 0
12:15:08.995 D frame: 53, time: 2080
12:15:08.996 E frame= 53 fps= 20 q=9.8 size= 768kB time=00:00:02.08 bitrate=3024.8kbits/s speed=0.782x
12:15:09.507 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=4 outputFps=4 renderFps=0, discardFps=0
12:15:09.508 D mPausedTimes=1
12:15:09.508 D mPausedTimes mEDRDelayTime=0 pauseTimes=2
12:15:09.508 D [notifyStatusToSF:L31] hdrtype is 0
12:15:09.523 D frame: 79, time: 3120
12:15:09.535 E frame= 79 fps= 25 q=8.2 size= 1024kB time=00:00:03.12 bitrate=2688.7kbits/s speed=0.983x
12:15:09.563 D [0xb400007399f24ac0] pipelineFull: too many frames in pipeline (6)
12:15:09.564 D [0xb400007399f24ac0] pipelineFull: too many frames in pipeline (6)
12:15:09.860 I 0xb4000074a3419f00 c2.android.mpeg4.decoder 540x960 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:09.860 D mPausedTimes=4
12:15:09.860 D mPausedTimes mEDRDelayTime=0 pauseTimes=5
12:15:09.860 D [notifyStatusToSF:L31] hdrtype is 0
12:15:10.006 D frame: 105, time: 4160
12:15:10.008 E frame= 105 fps= 29 q=6.8 size= 1280kB time=00:00:04.16 bitrate=2520.7kbits/s speed=1.13x
12:15:10.232 D getStreamVolume packageName=com.kli.inappdemo, index=0, streamType=3
12:15:10.508 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=4 outputFps=4 renderFps=0, discardFps=0
12:15:10.509 D mPausedTimes=2
12:15:10.509 D mPausedTimes mEDRDelayTime=0 pauseTimes=3
12:15:10.509 D [notifyStatusToSF:L31] hdrtype is 0
12:15:10.531 D frame: 133, time: 5280
12:15:10.537 E frame= 133 fps= 32 q=8.0 size= 1536kB time=00:00:05.28 bitrate=2383.2kbits/s speed=1.26x
12:15:10.812 D getStreamVolume packageName=com.kli.inappdemo, index=0, streamType=3
12:15:10.849 D bufferpool2 0xb400007341be1028 : 4(8388608 size) total buffers - 4(8388608 size) used buffers - 19/24 (recycle/alloc) - 6/38 (fetch/transfer)
12:15:10.849 D bufferpool2 0xb40000733709f628 : 0(0 size) total buffers - 0(0 size) used buffers - 19/24 (recycle/alloc) - 6/23 (fetch/transfer)
12:15:10.849 D evictor expired: 2, evicted: 2
12:15:10.861 I 0xb4000074a3419f00 c2.android.mpeg4.decoder 540x960 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:10.862 D mPausedTimes=5
12:15:10.862 D mPausedTimes mEDRDelayTime=0 pauseTimes=6
12:15:10.862 D [notifyStatusToSF:L31] hdrtype is 0
12:15:11.049 D frame: 155, time: 6160
12:15:11.051 E frame= 155 fps= 33 q=8.3 size= 1792kB time=00:00:06.16 bitrate=2383.2kbits/s speed=1.31x
12:15:11.510 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=4 outputFps=0 renderFps=0, discardFps=0
12:15:11.510 D mPausedTimes=3
12:15:11.510 D mPausedTimes mEDRDelayTime=0 pauseTimes=4
12:15:11.510 D [notifyStatusToSF:L31] hdrtype is 0
12:15:11.572 D frame: 184, time: 7320
12:15:11.578 E frame= 184 fps= 35 q=7.4 size= 2304kB time=00:00:07.32 bitrate=2578.5kbits/s speed= 1.4x
12:15:11.863 I 0xb4000074a3419f00 c2.android.mpeg4.decoder 540x960 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:11.863 D mPausedTimes=6
12:15:11.863 D mPausedTimes mEDRDelayTime=0 pauseTimes=7
12:15:11.863 D [notifyStatusToSF:L31] hdrtype is 0
12:15:11.863 I send video stutter message MM_FB_EventID#11002#ClientPid#28182#Key#-5476376645927330048#Component#c2.android.mpeg4.decoder#VideoInputFps#0#VideoOutputFps#0#VideoRenderFps#0#VideoHeight#960#VideoWidth#540#IsMediaPlayer#0#LogLevel#3#FpsArray#2/0/0/0/0/0#ModifiedVersion#5
12:15:11.863 D setEvent event:atlas_event_video_stutter
12:15:12.080 D frame: 210, time: 8360
12:15:12.095 E frame= 210 fps= 37 q=6.6 size= 2560kB time=00:00:08.36 bitrate=2508.6kbits/s speed=1.46x
12:15:12.511 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:12.511 D mPausedTimes=4
12:15:12.511 D mPausedTimes mEDRDelayTime=0 pauseTimes=5
12:15:12.511 D [notifyStatusToSF:L31] hdrtype is 0
12:15:12.613 D frame: 237, time: 9440
12:15:12.621 E frame= 237 fps= 38 q=8.0 size= 2816kB time=00:00:09.44 bitrate=2443.7kbits/s speed=1.51x
12:15:12.866 I 0xb4000074a3419f00 c2.android.mpeg4.decoder 540x960 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:12.866 D mPausedTimes=7
12:15:12.866 D mPausedTimes mEDRDelayTime=0 pauseTimes=8
12:15:12.866 D [notifyStatusToSF:L31] hdrtype is 0
12:15:13.130 D frame: 263, time: 10480
12:15:13.138 E frame= 263 fps= 39 q=7.9 size= 3072kB time=00:00:10.48 bitrate=2401.3kbits/s speed=1.55x
12:15:13.511 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:13.511 D mPausedTimes=5
12:15:13.511 D mPausedTimes mEDRDelayTime=0 pauseTimes=6
12:15:13.511 D [notifyStatusToSF:L31] hdrtype is 0
12:15:13.636 D frame: 289, time: 11520
12:15:13.643 E frame= 289 fps= 40 q=6.8 size= 3584kB time=00:00:11.52 bitrate=2548.6kbits/s speed=1.58x
12:15:13.866 I 0xb4000074a3419f00 c2.android.mpeg4.decoder 540x960 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:13.867 D mPausedTimes=8
12:15:13.867 D mPausedTimes mEDRDelayTime=0 pauseTimes=9
12:15:13.867 D [notifyStatusToSF:L31] hdrtype is 0
12:15:14.142 D frame: 319, time: 12720
12:15:14.144 E frame= 319 fps= 41 q=6.6 size= 3840kB time=00:00:12.72 bitrate=2473.1kbits/s speed=1.63x
12:15:14.513 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:14.513 D mPausedTimes=6
12:15:14.513 D mPausedTimes mEDRDelayTime=0 pauseTimes=7
12:15:14.513 D [notifyStatusToSF:L31] hdrtype is 0
12:15:14.671 D frame: 347, time: 13840
12:15:14.681 E frame= 347 fps= 42 q=7.1 size= 4096kB time=00:00:13.84 bitrate=2424.5kbits/s speed=1.66x
12:15:14.854 D bufferpool2 0xb400007306372a28 : 5(19599360 size) total buffers - 4(15679488 size) used buffers - 20/25 (recycle/alloc) - 7/26 (fetch/transfer)
12:15:14.854 D evictor expired: 1, evicted: 1
12:15:14.867 I 0xb4000074a3419f00 c2.android.mpeg4.decoder 540x960 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:14.867 D mPausedTimes=9
12:15:14.867 D mPausedTimes mEDRDelayTime=0 pauseTimes=10
12:15:14.867 D [notifyStatusToSF:L31] hdrtype is 0
12:15:15.197 D frame: 370, time: 14760
12:15:15.205 E frame= 370 fps= 42 q=7.3 size= 4608kB time=00:00:14.76 bitrate=2557.5kbits/s speed=1.67x
12:15:15.514 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:15.514 D mPausedTimes=7
12:15:15.514 D mPausedTimes mEDRDelayTime=0 pauseTimes=8
12:15:15.514 D [notifyStatusToSF:L31] hdrtype is 0
12:15:15.693 D frame: 395, time: 15760
12:15:15.706 E frame= 395 fps= 42 q=7.4 size= 4864kB time=00:00:15.76 bitrate=2528.3kbits/s speed=1.69x
12:15:15.854 D bufferpool2 0xb40000749f2ecc28 : 5(40960 size) total buffers - 0(0 size) used buffers - 21/27 (recycle/alloc) - 12/27 (fetch/transfer)
12:15:15.855 D evictor expired: 1, evicted: 1
12:15:15.868 I 0xb4000074a3419f00 c2.android.mpeg4.decoder 540x960 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:15.868 D mPausedTimes=10
12:15:15.868 D mPausedTimes mEDRDelayTime=0 pauseTimes=11
12:15:15.868 D [notifyStatusToSF:L31] hdrtype is 0
12:15:16.199 D frame: 418, time: 16680
12:15:16.201 E frame= 418 fps= 42 q=6.6 size= 5120kB time=00:00:16.68 bitrate=2514.6kbits/s speed=1.69x
12:15:16.514 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:16.514 D mPausedTimes=8
12:15:16.514 D mPausedTimes mEDRDelayTime=0 pauseTimes=9
12:15:16.514 D [notifyStatusToSF:L31] hdrtype is 0
12:15:16.514 I send video stutter message MM_FB_EventID#11002#ClientPid#28182#Key#-5476376645927160832#Component#c2.qti.vp9.decoder#VideoInputFps#0#VideoOutputFps#0#VideoRenderFps#0#VideoHeight#360#VideoWidth#640#IsMediaPlayer#0#LogLevel#3#FpsArray#4/0/0/0/0/0#ModifiedVersion#5
12:15:16.515 D setEvent event:atlas_event_video_stutter
12:15:16.719 D frame: 443, time: 17680
12:15:16.730 E frame= 443 fps= 43 q=8.3 size= 5376kB time=00:00:17.68 bitrate=2491.0kbits/s speed= 1.7x
12:15:16.868 I [sendFPSInfo:L700] input/output/render 0fps over 10s, reduce print fps log
12:15:16.868 D mPausedTimes=11
12:15:16.868 D mPausedTimes mEDRDelayTime=0 pauseTimes=12
12:15:16.868 D [notifyStatusToSF:L31] hdrtype is 0
12:15:17.232 D frame: 469, time: 18720
12:15:17.235 E frame= 469 fps= 43 q=4.9 size= 5632kB time=00:00:18.72 bitrate=2464.6kbits/s speed=1.72x
12:15:17.516 I 0xb4000074a3443400 c2.qti.vp9.decoder 640x360 inputFps=0 outputFps=0 renderFps=0, discardFps=0
12:15:17.517 D mPausedTimes=9
12:15:17.517 D mPausedTimes mEDRDelayTime=0 pauseTimes=10
12:15:17.518 D [notifyStatusToSF:L31] hdrtype is 0
12:15:17.733 D frame: 494, time: 19720
12:15:17.741 E frame= 494 fps= 43 q=7.3 size= 6144kB time=00:00:19.72 bitrate=2552.3kbits/s speed=1.73x

Here is the log for 6.0-2
12:30:53.886 I Loading ffmpeg-kit.
12:30:53.937 D Async callback block started.
12:30:53.992 I Loaded ffmpeg-kit-full-arm64-v8a-6.0-20230913.
12:30:53.995 I Skipped: false 11 cost 188.89098 refreshRate 16666666 bit true processName com.example.reversedemo3
12:30:56.314 D Installing profile for com.example.reversedemo3
12:31:01.294 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=1, videoFps=0.14173989, videoQuality=0.0, size=262188, time=31741.678, bitrate=66.08043846957304, speed=4.4990617595096545}
12:31:01.295 I statistics.getTime().........31741.678
12:31:01.295 I percentage......99.56612
12:31:01.713 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=20, videoFps=2.6395106, videoQuality=0.0, size=1048620, time=31741.678, bitrate=264.28848531574164, speed=4.189125015956492}
12:31:01.713 I statistics.getTime().........31741.678
12:31:01.714 I percentage......99.56612
12:31:02.221 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=52, videoFps=6.4249177, videoQuality=0.0, size=1572908, time=31741.678, bitrate=396.4271832131874, speed=3.9218783398712187}
12:31:02.222 I statistics.getTime().........31741.678
12:31:02.222 I percentage......99.56612
12:31:02.736 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=80, videoFps=9.299583, videoQuality=0.0, size=2097196, time=31741.678, bitrate=528.5658811106332, speed=3.689804640932516}
12:31:02.737 I statistics.getTime().........31741.678
12:31:02.737 I percentage......99.56612
12:31:03.250 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=104, videoFps=11.411305, videoQuality=0.0, size=2359340, time=31741.678, bitrate=594.635230059356, speed=3.48282686024089}
12:31:03.250 I statistics.getTime().........31741.678
12:31:03.251 I percentage......99.56612
12:31:03.749 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=131, videoFps=13.60462, videoQuality=0.0, size=2883628, time=31741.678, bitrate=726.7739279568018, speed=3.296438736629261}
12:31:03.750 I statistics.getTime().........31741.678
12:31:03.750 I percentage......99.56612
12:31:04.260 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=197, videoFps=19.432343, videoQuality=0.0, size=3932204, time=31741.678, bitrate=991.0513237516933, speed=3.1310413907530714}
12:31:04.260 I statistics.getTime().........31741.678
12:31:04.261 I percentage......99.56612
12:31:04.770 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=239, videoFps=22.456802, videoQuality=0.0, size=4456492, time=31741.678, bitrate=1123.190021649139, speed=2.9824960866121675}
12:31:04.771 I statistics.getTime().........31741.678
12:31:04.771 I percentage......99.56612
12:31:05.282 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=274, videoFps=24.566032, videoQuality=0.0, size=5242924, time=31741.678, bitrate=1321.3980684953076, speed=2.8458653224237542}
12:31:05.283 I statistics.getTime().........31741.678
12:31:05.283 I percentage......99.56612
12:31:05.795 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=302, videoFps=25.903013, videoQuality=0.0, size=5767212, time=31741.678, bitrate=1453.5367663927534, speed=2.722533411924549}
12:31:05.801 I statistics.getTime().........31741.678
12:31:05.802 I percentage......99.56612
12:31:06.292 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=325, videoFps=26.72783, videoQuality=0.0, size=6029356, time=31741.678, bitrate=1519.6061153414762, speed=2.6104191282562925}
12:31:06.293 I statistics.getTime().........31741.678
12:31:06.294 I percentage......99.56612
12:31:06.811 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=346, videoFps=27.30398, videoQuality=0.0, size=6291500, time=31741.678, bitrate=1585.6754642901992, speed=2.5048386264483407}
12:31:06.811 I statistics.getTime().........31741.678
12:31:06.811 I percentage......99.56612
12:31:07.328 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=367, videoFps=27.82078, videoQuality=0.0, size=6815788, time=31741.678, bitrate=1717.8141621876448, speed=2.406207651465732}
12:31:07.329 I statistics.getTime().........31741.678
12:31:07.330 I percentage......99.56612
12:31:07.834 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=393, videoFps=28.695143, videoQuality=0.0, size=7340076, time=31741.678, bitrate=1849.9528600850906, speed=2.317638611747109}
12:31:07.835 I statistics.getTime().........31741.678
12:31:07.836 I percentage......99.56612
12:31:08.334 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=413, videoFps=29.075562, videoQuality=0.0, size=7602220, time=31741.678, bitrate=1916.0222090338136, speed=2.234641955111062}
12:31:08.335 I statistics.getTime().........31741.678
12:31:08.335 I percentage......99.56612
12:31:08.854 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=440, videoFps=29.907671, videoQuality=0.0, size=8126508, time=31741.678, bitrate=2048.1609069312594, speed=2.1575446962315463}
12:31:08.856 I statistics.getTime().........31741.678
12:31:08.856 I percentage......99.56612
12:31:09.386 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=461, videoFps=30.248745, videoQuality=0.0, size=8388652, time=31741.678, bitrate=2114.230255879982, speed=2.0827459863420774}
12:31:09.386 I statistics.getTime().........31741.678
12:31:09.387 I percentage......99.56612
12:31:09.882 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=486, videoFps=30.852291, videoQuality=0.0, size=8912940, time=31741.678, bitrate=2246.368953777428, speed=2.015027771202341}
12:31:09.882 I statistics.getTime().........31741.678
12:31:09.882 I percentage......99.56612
12:31:10.387 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=514, videoFps=31.606014, videoQuality=0.0, size=9437228, time=31741.678, bitrate=2378.5076516748736, speed=1.9518052882943036}
12:31:10.388 I statistics.getTime().........31741.678
12:31:10.390 I percentage......99.56612
12:31:10.686 W type=1400 audit(0.0:59183): avc: denied { getopt } for path="/dev/socket/usap_pool_primary" scontext=u:r:untrusted_app:s0:c118,c257,c512,c768 tcontext=u:r:zygote:s0 tclass=unix_stream_socket permissive=0 app=com.example.reversedemo3
12:31:10.925 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=555, videoFps=33.083725, videoQuality=0.0, size=10223660, time=31741.678, bitrate=2576.715698521042, speed=1.892131493985394}
12:31:10.926 I statistics.getTime().........31741.678
12:31:10.926 I percentage......99.56612
12:31:11.413 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=609, videoFps=35.23476, videoQuality=0.0, size=11010092, time=31741.678, bitrate=2774.923745367211, speed=1.836470213551126}
12:31:11.413 I statistics.getTime().........31741.678
12:31:11.413 I percentage......99.56612
12:31:11.920 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=640, videoFps=35.977856, videoQuality=0.0, size=11534380, time=31741.678, bitrate=2907.062443264657, speed=1.784371189613326}
12:31:11.920 I statistics.getTime().........31741.678
12:31:11.920 I percentage......99.56612
12:31:12.447 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=656, videoFps=35.83233, videoQuality=0.0, size=11796524, time=31741.678, bitrate=2973.1317922133794, speed=1.7338083510469509}
12:31:12.448 I statistics.getTime().........31741.678
12:31:12.449 I percentage......99.56612
12:31:13.000 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=671, videoFps=35.617123, videoQuality=0.0, size=12058668, time=31741.678, bitrate=3039.2011411621024, speed=1.6848692933705667}
12:31:13.000 I statistics.getTime().........31741.678
12:31:13.002 I percentage......99.56612
12:31:13.498 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=685, videoFps=35.397675, videoQuality=0.0, size=12320812, time=31741.678, bitrate=3105.2704901108254, speed=1.6402651539268467}
12:31:13.499 I statistics.getTime().........31741.678
12:31:13.499 I percentage......99.56612
12:31:14.017 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=697, videoFps=35.078625, videoQuality=0.0, size=12582956, time=31741.678, bitrate=3171.339839059548, speed=1.5974955865041043}
12:31:14.018 I statistics.getTime().........31741.678
12:31:14.018 I percentage......99.56612
12:31:14.553 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=712, videoFps=34.924328, videoQuality=0.0, size=12845100, time=31741.678, bitrate=3237.409188008271, speed=1.5569618052147962}
12:31:14.553 I statistics.getTime().........31741.678
12:31:14.554 I percentage......99.56612
12:31:15.034 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=725, videoFps=34.700897, videoQuality=0.0, size=12845100, time=31741.678, bitrate=3237.409188008271, speed=1.519261644388586}
12:31:15.034 I statistics.getTime().........31741.678
12:31:15.034 I percentage......99.56612
12:31:15.594 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=741, videoFps=34.57266, videoQuality=0.0, size=13107244, time=31741.678, bitrate=3303.478536956994, speed=1.4809638971153483}
12:31:15.595 I statistics.getTime().........31741.678
12:31:15.596 I percentage......99.56612
12:31:16.100 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=753, videoFps=34.31189, videoQuality=0.0, size=13369388, time=31741.678, bitrate=3369.5478859057166, speed=1.4463704614674344}
12:31:16.101 I statistics.getTime().........31741.678
12:31:16.101 I percentage......99.56612
12:31:16.640 I statistics.toString().........Statistics{sessionId=1, videoFrameNumber=765, videoFps=34.029778, videoQuality=0.0, size=13631532, time=31741.678, bitrate=3435.6172348544396, speed=1.411976853461565}
12:31:16.641 I statistics.getTime().........31741.678
12:31:16.641 I percentage......99.56612

Environment

  • Platform: Android
  • Version: 6.0-2
  • Device: Realme 12pro & oneplus nord3
  • Device version : 14
  • Android Studio version: Android Studio Hedgehog | 2023.1.1 Patch 2
@tanersener
Copy link
Collaborator

We don't see a problem in the Statistics.getTime() method. If you provide a test application to reproduce this issue I can have a look.

@tanersener tanersener added needs-analysis We don't know that this is. It must be investigated further android Affect Android platform v6.0 library Affects the library labels Apr 10, 2024
@HamzaBula
Copy link
Author

HamzaBula commented Apr 11, 2024

Here is the link of my test application
https://github.com/HamzaBula/Reverse-Video-Demo

And here is my all code

  • build.gradle
    implementation 'com.arthenica:ffmpeg-kit-full:6.0-2'

  • MainActivity.java

package com.example.reversedemo3;

import static android.content.ContentValues.TAG;
import static android.os.Environment.DIRECTORY_MOVIES;

import androidx.activity.result.ActivityResultLauncher;
import androidx.activity.result.contract.ActivityResultContracts;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import android.annotation.SuppressLint;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.Toast;
import com.arthenica.ffmpegkit.FFmpegKit;
import com.arthenica.ffmpegkit.FFmpegKitConfig;
import com.arthenica.ffmpegkit.FFmpegSession;
import com.arthenica.ffmpegkit.FFmpegSessionCompleteCallback;
import com.arthenica.ffmpegkit.LogCallback;
import com.arthenica.ffmpegkit.ReturnCode;
import com.arthenica.ffmpegkit.SessionState;
import com.arthenica.ffmpegkit.Statistics;
import com.arthenica.ffmpegkit.StatisticsCallback;
import java.io.File;
import java.io.IOException;
import android.media.MediaMetadataRetriever;

public class MainActivity extends AppCompatActivity {

Button processBtn;
ProgressBar progressBar;
String inputPath,outputPath;
String randomString ="testing"+System.currentTimeMillis()/1000;
long inputFileDuration = 0;


@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    processBtn = findViewById(R.id.process_button);
    progressBar = findViewById(R.id.progressbar);

    processBtn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {

            requestStoragePermission();
        }
    });
}


@SuppressLint("ObsoleteSdkInt")
private void requestStoragePermission() {

    //permission code for android version 13 or above
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.TIRAMISU) {
        // only for TIRAMISU and newer versions

        if (ContextCompat.checkSelfPermission(this, android.Manifest.permission.READ_MEDIA_VIDEO) == PackageManager.PERMISSION_GRANTED) {

            System.out.println("permission already granted..............");
            startProcess();


        } else {
            System.out.println("request permission");
            request_permission_launcher_storage_videos.launch(android.Manifest.permission.READ_MEDIA_VIDEO);
        }
    }
}
private ActivityResultLauncher<String> request_permission_launcher_storage_videos =
        registerForActivityResult(new ActivityResultContracts.RequestPermission(),
                isGranted -> {

                    if (isGranted) {
                        startProcess();

                    }
                    else {

                        Toast.makeText(this, "Please grant us the necessary permission", Toast.LENGTH_SHORT).show();
                    }
        });


private void startProcess() {

    System.out.println("start process......");
    progressBar.setVisibility(View.VISIBLE);

    File fileParent = Environment.getExternalStoragePublicDirectory(DIRECTORY_MOVIES);
    File file = new File(fileParent, "Reverse_Demo_3");

    if(file.exists()) {
        System.out.println("file already exist......--->");
    }
    else {
        System.out.println("file not exist......--->");
        file.mkdir();
    }


    inputPath = Environment.getExternalStorageDirectory().getPath() + "/Movies/Testing_videos/myvideo1234.mp4";
    outputPath = Environment.getExternalStorageDirectory().getPath() + "/Movies/Reverse_Demo_3/"+randomString+".mp4";

    try {
        inputFileDuration = getVideoDuration(inputPath);
        System.out.println("inputFileDuration......."+inputFileDuration);
    } catch (IOException e) {
        System.out.println("e.toString()......"+e.toString());
        throw new RuntimeException(e);
    }
    ReverseMethod();
}




private void ReverseMethod(){

    System.out.println("partReverse called");
  
    FFmpegSession session = FFmpegKit.executeAsync("-i " + inputPath + " -filter_complex reverse " + outputPath, new FFmpegSessionCompleteCallback() {

        @Override
        public void apply(FFmpegSession session) {

            // CALLED WHEN SESSION IS EXECUTED
            progressBar.setVisibility(View.INVISIBLE);

            SessionState state = session.getState();
            ReturnCode returnCode = session.getReturnCode();

            if(returnCode.isValueSuccess()){
                System.out.println("success....");

            } else if (returnCode.isValueError()) {
                System.out.println("error.....");

            }else if(returnCode.isValueCancel()){
                System.out.println("cancel....");
            }
            else {
                System.out.println("fail.....");
            }
            Log.d(TAG, String.format("FFmpeg process exited with state %s and rc %s.%s", state, returnCode, session.getFailStackTrace()));
        }
    }, new LogCallback() {

        @Override
        public void apply(com.arthenica.ffmpegkit.Log log) {

            // CALLED WHEN SESSION PRINTS LOGS
            System.out.println("Log Call back = "+log.toString());
        }
    }, new StatisticsCallback() {

        @Override
        public void apply(Statistics statistics) {

            // CALLED WHEN SESSION GENERATES STATISTICS
            System.out.println("statistics.toString()........."+statistics.toString());
            System.out.println("statistics.getTime()........."+statistics.getTime());
            float percentage = ((float) (((statistics.getTime() * 100) /inputFileDuration)));
            System.out.println("percentage......"+percentage);
        }
    });
    System.out.println("session.getAllLogsAsString()......."+session.getAllLogsAsString());
    System.out.println("session.getOutput()......."+session.getOutput());
}

public long getVideoDuration(String videoPath) throws IOException {
    MediaMetadataRetriever retriever = new MediaMetadataRetriever();
    try {
        retriever.setDataSource(videoPath); // set the data source
        String time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
        long duration = Long.parseLong(time); // get duration in ms
        retriever.release();
        return duration;
    } catch (Exception e) {
        e.printStackTrace();
        retriever.release();
        return 0;
    }
}

}
Please have a look and thank you for your prompt response.

@tanersener
Copy link
Collaborator

Your test file is not included in the repo. Can you share it too?

@HamzaBula
Copy link
Author

Sure here is the updated code link of my test application pls have a look
https://github.com/HamzaBula/Reverse-Video-Demo

And check the log during the process i'm getting frame and fps perfect but not the time
(16:44:06.358 I Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame= 1 fps=0.5 q=6.3 size= 0kB time=00:00:11.54 bitrate= 0.0kbits/s speed=5.64x '})

@tanersener
Copy link
Collaborator

As far as I see, your updated repo doesn't include a sample file.

Let me repeat once more. We cannot reproduce the issue. We don't see a problem in getTime(). The files that we use all work fine. See logs below. If you need help, you need to find a way to demonstrate the problem to us. Without that we cannot help you.

statistics.getTime().........866.667
percentage......2.838925
statistics.getTime().........8960.0
percentage......29.350105
statistics.getTime().........26005.333
percentage......85.18518
statistics.getTime().........30506.667
percentage......99.93012

@krishnasen2401
Copy link

krishnasen2401 commented Apr 12, 2024

@tanersener @HamzaBula I am also facing the same issue in 6.0 LTS but not in 6.0-2 this my source URL https://g4fv.biananset.net/_v7/01818da9d88a5549e542b211afe2d6323c0f4b97ea1dab65ea1537efe6b1cf6d167afda2736e7ae77091bdf167c34d95d31f370b9bff51bb7dafc71961b8af745b52473a0bc309ecd4aec81ea9698ca528613a5043513d7bc7a897179908fa6963fed39d873150a4a6ed286da04f06d740ef7a16bba02774034c3e384028079e/index-f2-v1-a1.m3u8

and logcat is :52:00.235 D message frame=34627 fps=282 q=-1.0 size= 105472kB time=00:23:05.08 bitrate= 623.8kbits/s speed=11.3x level 32 23:52:00.998 D 1.766147432466691% 23:52:01.000 D time 25080.0 framenumber 35127 speed 11.35867482303902 size 109051952 23:52:01.000 D message frame=35127 fps=284 q=-1.0 size= 106496kB time=00:23:25.08 bitrate= 620.9kbits/s speed=11.4x level 32 23:52:01.145 D 2.824501281654038% 23:52:01.146 D time 40109.048 framenumber 35501 speed 11.466461953969558 size 111294667

I am also attaching the logcat file export for the above funtion
motorola-edge-2023-Android-14_2024-04-12_235441.zip

@tanersener
Copy link
Collaborator

@krishnasen2401 See #804 if your're using v6.0. This issue is reported for v6.0-2.

@krishnasen2401
Copy link

@HamzaBula check gradle if it's on 6.0 lts or 6.0-2

@tanersener
Copy link
Collaborator

@krishnasen2401 which gradle? you haven't shared any gradle files. You've said it is on 6.0. And I'm saying that there is a bug in v6.0.

@krishnasen2401
Copy link

krishnasen2401 commented Apr 12, 2024

@tanersener this is what I meant maven gradle
old ffmpegKitFullVersion = "6.0.LTS" new one ffmpegKitFullVersion = "6.0-2" tag
image

@tanersener
Copy link
Collaborator

@krishnasen2401 If you see a problem in v6.0-2, please share a simple app to reproduce your issue. And try to explain it in text as well. I don't see anything about time in the logcat file you shared.

@krishnasen2401
Copy link

krishnasen2401 commented Apr 12, 2024

Will check do @tanersener , I have exported the logcat directly from Android studio maybe it should be imported into logcat window

@HamzaBula
Copy link
Author

HamzaBula commented Apr 13, 2024

@tanersener i'm using ffmpeg-kit-full:6.0-2 in android and finally I found out what exactly is the confusion, I was trying to run a command for video reverse and in that process I was having a time problem, now I tried another command and the getTime() method is working perfectly, the problem is only after Happens when I run the command for video reverse.

Here is the command for video reverse please check this command for bug
"-i " + inputPath + " -filter_complex reverse " + outputPath

And you can also try this my demo project
https://github.com/HamzaBula/Reverse-Video-Demo

Here is the code I use for reverse video
FFmpegSession session = FFmpegKit.executeAsync("-i " + inputPath + " -filter_complex reverse " + outputPath, new FFmpegSessionCompleteCallback() {
@OverRide
public void apply(FFmpegSession session) {

            // CALLED WHEN SESSION IS EXECUTED
            progressBar.setVisibility(View.INVISIBLE);

            SessionState state = session.getState();
            ReturnCode returnCode = session.getReturnCode();

            if(returnCode.isValueSuccess()){

                Intent intent = new Intent(StartProcessActivity.this, ProcessedVideoActivity.class);
                intent.putExtra(FILEPATH, outputPath);
                startActivity(intent);

            } else if (returnCode.isValueError()) {
                Toast.makeText(StartProcessActivity.this, "There is some error", Toast.LENGTH_SHORT).show();

            }else if(returnCode.isValueCancel()){
                Toast.makeText(StartProcessActivity.this, "cancel", Toast.LENGTH_SHORT).show();
            }
            else {
                Toast.makeText(StartProcessActivity.this, "Fail", Toast.LENGTH_SHORT).show();
            }
            Log.d(TAG, String.format("FFmpeg process exited with state %s and rc %s.%s", state, returnCode, session.getFailStackTrace()));
        }
    }, new LogCallback() {

        @Override
        public void apply(com.arthenica.ffmpegkit.Log log) {

            // CALLED WHEN SESSION PRINTS LOGS
            System.out.println("Log Call back = "+log.toString());
        }
    }, new StatisticsCallback() {

        @Override
        public void apply(Statistics statistics) {

            // CALLED WHEN SESSION GENERATES STATISTICS
            System.out.println("statistics.toString()........."+statistics.toString());
            System.out.println("statistics.getTime()........."+statistics.getTime());
            float percentage = ((float) (((statistics.getTime() * 100) /inputFileDuration)));
            System.out.println("percentage......"+percentage);
        }
    }); 

@tanersener
Copy link
Collaborator

@HamzaBula Thanks. I see your issue now. I pasted the logs below.

In the logs, Log Call back shows the value calculated by FFmpeg, statistics.toString() shows the statistics generated by FFmpeKit. You can see that they are the same. This means FFmpegKit is forwarding what FFmpeg is calculating. So, I don't see a problem in FFmpegKit. Therefore, I'll mark this issue as an FFmpeg bug.

I tested old FFmpegKit versions and saw that it is there in v4.4, v4.5.1 and v5.1 as well.

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=0, videoFps=0.0, videoQuality=0.0, size=10081, time=30454.667, bitrate=2.6481327147658518, speed=76.54599647446771}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=    0 fps=0.0 q=-0.0 size=      10kB time=00:00:30.45 bitrate=   2.6kbits/s speed=76.5x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=99, videoFps=0.0, videoQuality=0.0, size=89385, time=30454.667, bitrate=23.480145095659722, speed=33.774272702928045}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=   99 fps=0.0 q=-0.0 size=      87kB time=00:00:30.45 bitrate=  23.5kbits/s speed=33.8x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=207, videoFps=147.62694, videoQuality=0.0, size=181358, time=30454.667, bitrate=47.64012031390788, speed=21.719465851723005}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=  207 fps=148 q=-0.0 size=     177kB time=00:00:30.45 bitrate=  47.6kbits/s speed=21.7x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=310, videoFps=155.44511, videoQuality=0.0, size=262144, time=30454.667, bitrate=68.86143263362557, speed=15.271062590032}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=  310 fps=155 q=-0.0 size=     256kB time=00:00:30.45 bitrate=  68.9kbits/s speed=15.3x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=418, videoFps=167.41449, videoQuality=0.0, size=262144, time=30454.667, bitrate=68.86143263362557, speed=12.197493815296431}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=  418 fps=167 q=-0.0 size=     256kB time=00:00:30.45 bitrate=  68.9kbits/s speed=12.2x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=526, videoFps=175.41222, videoQuality=0.0, size=262144, time=30454.667, bitrate=68.86143263362557, speed=10.156122442686456}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=  526 fps=175 q=-0.0 size=     256kB time=00:00:30.45 bitrate=  68.9kbits/s speed=10.2x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=634, videoFps=181.05637, videoQuality=0.0, size=524288, time=30454.667, bitrate=137.72286526725114, speed=8.69717858882118}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=  634 fps=181 q=-0.0 size=     512kB time=00:00:30.45 bitrate= 137.7kbits/s speed= 8.7x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=743, videoFps=185.64552, videoQuality=0.0, size=524288, time=30454.667, bitrate=137.72286526725114, speed=7.6093842870193695}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=  743 fps=186 q=-0.0 size=     512kB time=00:00:30.45 bitrate= 137.7kbits/s speed=7.61x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=852, videoFps=189.17519, videoQuality=0.0, size=524288, time=30454.667, bitrate=137.72286526725114, speed=6.762051051207757}
I  statistics.getTime().........30454.667
I  percentage......99.75978
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=  852 fps=189 q=-0.0 size=     512kB time=00:00:30.45 bitrate= 137.7kbits/s speed=6.76x    '}

I  statistics.toString().........Statistics{sessionId=1, videoFrameNumber=901, videoFps=190.25577, videoQuality=0.0, size=773553, time=30518.667, bitrate=202.77504256657082, speed=6.444342455483165}
I  statistics.getTime().........30518.667
I  percentage......99.96943
I  Log Call back = Log{sessionId=1, level=AV_LOG_INFO, message='frame=  901 fps=190 q=-0.0 Lsize=     755kB time=00:00:30.51 bitrate= 202.8kbits/s speed=6.44x

@tanersener tanersener added v4.4 Affects v4.4 release v4.5.1 Affects v4.5.1 release v5.1 Affects v5.1 release ffmpeg-bug Something isn't right in ffmpeg source code and removed needs-analysis We don't know that this is. It must be investigated further labels Apr 13, 2024
@HamzaBula
Copy link
Author

HamzaBula commented Apr 13, 2024

But it was working properly in 4.4.LTS, So is there any possible solution for reverse command in version 6.0-2?

@tanersener
Copy link
Collaborator

If I modify your app to work with FFmpegKit 4.4.LTS (It uses old API, app must be modified) I see the same bug.

Moreover, you can see that the bug exists on desktop FFmpeg as well. Why don't you run your tests on ffmpeg 4.x, 5.x, 6.x and share the results here?

@tanersener tanersener added all-platforms and removed android Affect Android platform labels Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
all-platforms ffmpeg-bug Something isn't right in ffmpeg source code library Affects the library v4.4 Affects v4.4 release v4.5.1 Affects v4.5.1 release v5.1 Affects v5.1 release v6.0
Projects
None yet
Development

No branches or pull requests

3 participants