-
Notifications
You must be signed in to change notification settings - Fork 626
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
Question: How to cancel a session completely #33
Comments
Generally logs (console output) explains what |
Hmm, idk what other logs you mean, but the 2 snippets above are the last 2 or 3 lintes of the logs? I shortened them as the rest seems just normal working ffmpeg stdout. I can't see live whats going on but as soon as the session ends it gives me the |
Would you mind sharing them? I'm sure they are normal. But I need to understand what
You mean the |
This is my fork which i'm trying to move from mobile-ffmpeg to ffmpeg-kit..https://github.com/nooitaf/cordova-plugin-ffmpeg Excuse the chaotic state of the java file but my first priority was getting rtmp working. So essentially only exec and cancel work right now. Maybe the code helps to shed some light on things. I test it on my Android 9 device. with full-gpl 4.4 because i need the camera. But in that test i was just streaming a file, which works but never closes connection for some reason. I can post the stdout after i slept (didn't save it, sry). ffmpeg.exec("-re -i file:///storage/emulated/0/DCIM/test.mp4 -c:v copy -c:a aac -ar 44100 -f flv rtmp://10.0.0.237/live/android", (success) => console.log(success), (failure) => console.log(failure)); |
Oh wait i still had the terminal output which is a little verbose with date and time but i think the same as the console... |
As |
Ah, good to know,.. but i assume it won't force-kill still running connections i guess? Would it be possible to get the process-id of the ffmpeg process and sig-kill it that way? I remember having a similar issue with ffmpeg in nodejs, where i had to pause the piped stdin and sig-kill it, as it didn't want to listen to a normal term sometimes. |
I don't get exactly what you want to do there but I need to remind that And, the method that changes the history size does not know whether those sessions are still running or not. So, it won't take actions about them. |
I was wondering why the rtmp timeout on the server never triggers and looked at the tcp packages on the server. After i cancel the ffmpeg session the phone still responses with Server TCP dump
19:22:22.993690 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [S], seq 3994281749, win 65535, options [mss 1460,sackOK,TS val 138135443 ecr 0,nop,wscale 8], length 0
19:22:22.993718 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [S.], seq 4024949280, ack 3994281750, win 28960, options [mss 1460,sackOK,TS val 1490061515 ecr 138135443,nop,wscale 7], length 0
19:22:22.996801 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 1, win 343, options [nop,nop,TS val 138135446 ecr 1490061515], length 0
19:22:22.997345 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 1:1538, ack 1, win 343, options [nop,nop,TS val 138135446 ecr 1490061515], length 1537
19:22:22.997351 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 1538, win 251, options [nop,nop,TS val 1490061516 ecr 138135446], length 0
19:22:22.997605 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], seq 1:1449, ack 1538, win 251, options [nop,nop,TS val 1490061516 ecr 138135446], length 1448
19:22:22.997614 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], seq 1449:2897, ack 1538, win 251, options [nop,nop,TS val 1490061516 ecr 138135446], length 1448
19:22:22.997772 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 2897:3074, ack 1538, win 251, options [nop,nop,TS val 1490061516 ecr 138135446], length 177
19:22:22.999131 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 1449, win 354, options [nop,nop,TS val 138135447 ecr 1490061516], length 0
19:22:22.999680 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 2897, win 365, options [nop,nop,TS val 138135447 ecr 1490061516], length 0
19:22:22.999882 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3074, win 365, options [nop,nop,TS val 138135447 ecr 1490061516], length 0
19:22:23.000670 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 1538:3086, ack 3074, win 365, options [nop,nop,TS val 138135447 ecr 1490061516], length 1548
19:22:23.000688 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 3086, win 275, options [nop,nop,TS val 1490061517 ecr 138135447], length 0
19:22:23.002556 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 3086:3227, ack 3074, win 365, options [nop,nop,TS val 138135447 ecr 1490061517], length 141
19:22:23.003011 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3074:3090, ack 3227, win 298, options [nop,nop,TS val 1490061517 ecr 138135447], length 16
19:22:23.042481 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3090, win 365, options [nop,nop,TS val 138135458 ecr 1490061517], length 0
19:22:23.042495 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3090:3325, ack 3227, win 298, options [nop,nop,TS val 1490061527 ecr 138135458], length 235
19:22:23.043689 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3325, win 377, options [nop,nop,TS val 138135458 ecr 1490061527], length 0
19:22:23.043823 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 3227:3239, ack 3325, win 377, options [nop,nop,TS val 138135458 ecr 1490061527], length 12
19:22:23.083046 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 3239, win 298, options [nop,nop,TS val 1490061538 ecr 138135458], length 0
19:22:23.084608 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 3239:3360, ack 3325, win 377, options [nop,nop,TS val 138135468 ecr 1490061538], length 121
19:22:23.084638 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 3360, win 298, options [nop,nop,TS val 1490061538 ecr 138135468], length 0
19:22:23.084887 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3325:3366, ack 3360, win 298, options [nop,nop,TS val 1490061538 ecr 138135468], length 41
19:22:23.087125 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 3360:3372, ack 3366, win 377, options [nop,nop,TS val 138135469 ecr 1490061538], length 12
19:22:23.127042 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 3372, win 298, options [nop,nop,TS val 1490061549 ecr 138135469], length 0
19:22:23.128763 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 3372:3409, ack 3366, win 377, options [nop,nop,TS val 138135479 ecr 1490061549], length 37
19:22:23.128768 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 3409, win 298, options [nop,nop,TS val 1490061549 ecr 138135479], length 0
19:22:23.130958 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3366:3498, ack 3409, win 298, options [nop,nop,TS val 1490061549 ecr 138135479], length 132
19:22:23.149940 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 3409:3421, ack 3498, win 377, options [nop,nop,TS val 138135484 ecr 1490061549], length 12
19:22:23.187042 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 3421, win 298, options [nop,nop,TS val 1490061564 ecr 138135484], length 0
19:22:23.188612 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 3421:4132, ack 3498, win 377, options [nop,nop,TS val 138135494 ecr 1490061564], length 711
19:22:23.188617 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 4132, win 320, options [nop,nop,TS val 1490061564 ecr 138135494], length 0
19:22:23.209419 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 4132:4140, ack 3498, win 377, options [nop,nop,TS val 138135499 ecr 1490061564], length 8
19:22:23.209473 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 4140, win 320, options [nop,nop,TS val 1490061569 ecr 138135499], length 0
19:22:23.210010 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 4140:5588, ack 3498, win 377, options [nop,nop,TS val 138135499 ecr 1490061564], length 1448
19:22:23.210012 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 5588, win 343, options [nop,nop,TS val 1490061569 ecr 138135499], length 0
19:22:23.210243 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 5588:7036, ack 3498, win 377, options [nop,nop,TS val 138135499 ecr 1490061564], length 1448
19:22:23.210244 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 7036, win 365, options [nop,nop,TS val 1490061569 ecr 138135499], length 0
19:22:23.210505 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 7036:8484, ack 3498, win 377, options [nop,nop,TS val 138135499 ecr 1490061564], length 1448
19:22:23.210506 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 8484, win 388, options [nop,nop,TS val 1490061569 ecr 138135499], length 0
19:22:23.210723 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 8484:9932, ack 3498, win 377, options [nop,nop,TS val 138135499 ecr 1490061564], length 1448
19:22:23.210736 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 9932, win 411, options [nop,nop,TS val 1490061569 ecr 138135499], length 0
...
[ repeating stream packages ]
...
19:22:49.737053 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 145181819:145184715, ack 3498, win 377, options [nop,nop,TS val 138142131 ecr 1490068186], length 2896
19:22:49.737055 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 145184715, win 8178, options [nop,nop,TS val 1490068201 ecr 138142131], length 0
19:22:49.737286 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 145184715:145186163, ack 3498, win 377, options [nop,nop,TS val 138142131 ecr 1490068186], length 1448
19:22:49.737580 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 145186163:145189059, ack 3498, win 377, options [nop,nop,TS val 138142131 ecr 1490068186], length 2896
19:22:49.737582 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 145189059, win 8178, options [nop,nop,TS val 1490068201 ecr 138142131], length 0
19:22:49.737769 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 145189059:145190507, ack 3498, win 377, options [nop,nop,TS val 138142131 ecr 1490068186], length 1448
19:22:49.738064 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 145190507:145191955, ack 3498, win 377, options [nop,nop,TS val 138142131 ecr 1490068186], length 1448
19:22:49.738065 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 145191955, win 8178, options [nop,nop,TS val 1490068201 ecr 138142131], length 0
19:22:49.738322 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], seq 145191955:145193403, ack 3498, win 377, options [nop,nop,TS val 138142131 ecr 1490068186], length 1448
19:22:49.743725 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [P.], seq 145193403:145194010, ack 3498, win 377, options [nop,nop,TS val 138142132 ecr 1490068198], length 607
19:22:49.743737 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [.], ack 145194010, win 8178, options [nop,nop,TS val 1490068203 ecr 138142131], length 0
19:22:53.003095 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3498:3516, ack 145194010, win 8178, options [nop,nop,TS val 1490069018 ecr 138142131], length 18
19:22:53.206681 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3516, win 377, options [nop,nop,TS val 138142999 ecr 1490069018], length 0
19:23:23.002814 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3516:3534, ack 145194010, win 8178, options [nop,nop,TS val 1490076517 ecr 138142999], length 18
19:23:23.251041 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3516:3534, ack 145194010, win 8178, options [nop,nop,TS val 1490076580 ecr 138142999], length 18
19:23:23.274320 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3534, win 377, options [nop,nop,TS val 138150515 ecr 1490076517], length 0
19:23:23.274465 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3534, win 377, options [nop,nop,TS val 138150515 ecr 1490076580,nop,nop,sack 1 {3516:3534}], length 0
19:23:53.002750 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3534:3552, ack 145194010, win 8178, options [nop,nop,TS val 1490084017 ecr 138150515], length 18
...
[ repeating ]
...
19:28:23.004715 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3714, win 377, options [nop,nop,TS val 138225448 ecr 1490151518], length 0
19:28:53.003341 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3714:3732, ack 145194010, win 8178, options [nop,nop,TS val 1490159018 ecr 138225448], length 18
19:28:53.211337 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3732, win 377, options [nop,nop,TS val 138233000 ecr 1490159018], length 0
19:29:23.003671 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3732:3750, ack 145194010, win 8178, options [nop,nop,TS val 1490166518 ecr 138233000], length 18
19:29:23.112164 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [.], ack 3750, win 377, options [nop,nop,TS val 138240475 ecr 1490166518], length 0
19:29:53.004028 IP rtmpserver.local.1935 > 10.0.0.125.41234: Flags [P.], seq 3750:3768, ack 145194010, win 8178, options [nop,nop,TS val 1490174018 ecr 138240475], length 18
19:29:53.124211 IP 10.0.0.125.41234 > rtmpserver.local.1935: Flags [R], seq 4139475759, win 0, length 0
|
My tests confirm that But if you try to stream data to the same endpoint again it will fail. My rtmp server has a auto-clean feature, it cleans these hanging rtmp connections in 15 seconds. If I start another session on 16th second it doesn't receive any errors. That can be used as a temporary workaround. Most probably this is a bug in |
Fixed in |
Awesome! \o/ |
Hi friend, did you continue working on the implementation of ffmpeg-kit in Cordova? |
I had to put it on hold for a while so i removed the repo, but i can ping you when i recreate it. |
@tanersener Same issue. |
@DuyIoT I don't know the details of your case. Hard to say if it the expected behaviour or another symptom of the bug fixed in this thread. |
I would recommend to below steps to cancel a session
|
I'm trying to cancel a running rtmp session on android started with
FFprobeKit.executeAsync()
, but for some reason it doesn't completely close the connection even tho the session says it's completed. I get a callback and it seems like it ended, but it doesn't. Also canceled sessions seem to stick around after they get canceled. Is there a way to remove them?This is what i do to cancel all running sessions...
Also tried
FFmpegKit.cancel()
but i get the same resultFrom the first session (that doesn't stop) i get this when i cancel it which looks like its done..
Exiting normally, received signal 2. , state=COMPLETED, returnCode=255, failStackTrace='null'}
But my rtmp server still thinks there is a connection and when i try to start a new one i get this instantly..
[rtmp @ 0x7e2d0fcf80] Server error: Stream already publishing rtmp://10.0.0.200/live/android: Operation not permitted , state=COMPLETED, returnCode=1, failStackTrace='null'}
When i start multiple sessions i get all tries listed as sessions from
getSessions()
withcompleted
state and they never seem to go away.I'm very new to android and java so maybe i'm just missing something simple, or this is just normal, but it doesn't seem right.
Is there maybe another way to just force kill all ffmpeg processes?
The text was updated successfully, but these errors were encountered: