Comments (17)
Fixed in development
.
from ffmpeg-kit.
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 ffmpeg-kit
or ffmpeg
doesn't have their own process id. There is only process there, the process that runs your application. Killing that process means killing your application.
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.
from ffmpeg-kit.
My tests confirm that cancel
method doesn't close rtmp
connections properly. I'm not sure whether it must send an rtmp termination message or tcp connection must be closed to stop it. Details must be analysed.
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 ffmpeg-kit
s cancel
mechanism. But a more detailed investigation is still necessary to understand where exactly this comes from.
from ffmpeg-kit.
Generally logs (console output) explains what ffmpeg
is doing. Have you checked them?
from ffmpeg-kit.
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 FFmpegKitConfig.getLastCompletedSession()
string which is very similar to what happens on linux stdout. Would Log.d
in the apply give me live updates? I assumed it would also just call apply once.
from ffmpeg-kit.
I shortened them as the rest seems just normal working ffmpeg stdout.
Would you mind sharing them? I'm sure they are normal. But I need to understand what ffmpeg
is doing in order to make a comment about your issue.
Would Log.d in the apply give me live updates?
You mean the apply
method of one of the callbacks?
from ffmpeg-kit.
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).
This is the command i use in chrome console to start on the phone.
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));
from ffmpeg-kit.
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...
https://pastebin.com/PMPrvGtr
from ffmpeg-kit.
Also canceled sessions seem to stick around after they get canceled.
As Javadoc
says, getSessions
returns sessions in the history. If you don't need them you can decrease the size of session history using setSessionHistorySize
.
from ffmpeg-kit.
As
Javadoc
says,getSessions
returns sessions in the history. If you don't need them you can decrease the size of session history usingsetSessionHistorySize
.
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.
from ffmpeg-kit.
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 ack
on the port it used for the connection before. If i disable Wifi
and re-enable it, the phone responses properly with reset
and the server stops immediatly. At this point i can start another session with ffmpeg and it works again.
Server TCP dump
- Starting streaming...
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
-
FFmpeg on phone canceled, or video ended
-
Server pings phone:
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
- Wifi diabled and re-enabled
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
- Server stops it's rtmp session
from ffmpeg-kit.
Awesome! \o/
from ffmpeg-kit.
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).
This is the command i use in chrome console to start on the phone.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));
Hi friend, did you continue working on the implementation of ffmpeg-kit in Cordova?
from ffmpeg-kit.
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.
from ffmpeg-kit.
@tanersener Same issue.
I using ffmpeg kit merge 2 videos, and when i cancel(use ffmpegkit.cancel), the file in progress still generate the ts file and return state failed.
It's a feature or bug?
from ffmpeg-kit.
@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.
from ffmpeg-kit.
I would recommend to below steps to cancel a session
-
use your own executor service like below
ExecutorService executorService = Executors.newFixedThreadPool(10);
-
Instead of using session created by
FFmpegKit.executeAsync
create your ownFFmpegSession
using the required constructor. -
Create your own execution task by extending
AsyncFFmpegExecuteTask
. Override therun
method as below
public void run() { try { if (Thread.currentThread().isInterrupted()) { return; } else { super.run(); } } catch (Exception ex) {} }
-
Create new object of your execution task and submit it in your
executorService
. This will create a new object ofFuture
. Preserve this object. -
Now calling
cancel()
method on yourFuture
object will cancel your session completely.
from ffmpeg-kit.
Related Issues (20)
- crash on android 15
- iOS 18:When synthesizing Chinese subtitles on iOS 18, there may be garbled characters, and those below 18 are normal HOT 2
- FfmpegKit as LibVLC replacement especially on native Android for playing files and live streams
- Can this support Jetpack Compose Multiplatfrom?
- Podfile configuration issue
- Corrupted trim video
- react-native iOS: undefined returnCode / failStackTrace 2 HOT 1
- FFprobeKit.getMediaInformationAsync Unexpected end of file around line 206, column 0. HOT 1
- FFprobeKit.getMediaInformationAsync 获取视频信息,width和height出现错误的对调赋值
- Android No match for targetSdk 34
- Can not set libx264 encoder Settings will report error other encoders no problem HOT 1
- Feature Request: Support --speed flag in ffmpeg_kit_flutter
- Draw Text HOT 1
- Android | Thumbnail generation for HLS video stream
- Apple | Not able to build project
- Are there any plans to adapt to HarmonyOS?
- Flutter License Compliance
- FFmpegKit initialization throws error: FFmpegKit failed to start on brand: HOT 3
- FFMpeg subtitles Korean language Garbled code,Unable to find supported fonts
- Remove x86 and x86_64 from .apk file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ffmpeg-kit.