-
-
Notifications
You must be signed in to change notification settings - Fork 776
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
ClosedWriteChannelException: The channel was closed #1601
Comments
Hello, According with the logs, the videoinfo is setted multiple times doing that video packet is reset and maybe produce this error. To avoid it I did a fix for it: implementation 'com.github.pedroSG94.RootEncoder:library:c62693873d' |
I was able to reproduce the error. I'm working on it |
Thank you so much. I am looking forward to your good news. |
For now, I detected that this is a bug in Ktor library because using java.io socket it is working fine. |
Fixed here: The problem was related with the soTimeout using a tls socket. I think it is a bug in the ktor library but I was able to solve it using withtimeout in read/write methods manually |
Thank you so much, I will test it and let you know |
Thank you for the fix. However, another issue still seems unresolved. I am trying to stream using the local file I attached, but after a second, it stops. Please check the log. Log: The video used for streaming: Thanks. |
Hello, I don't understand that logs. It is a json |
Hi, Please see the new attached log. Yes, I can reproduce the issue on other devices (Android 12 & 14). It's the same error with this video (some videos still work): Video link. |
Ok, I was able to reproduce the error. The audio is working but the video decoder stopped |
Hello, I was debugging the error with that file and seems that MediaExtractor class of Android is not working properly with that file. Only can extract 3 video frames producing that the video freeze. For now, I'm looking an alternative to MediaExtractor or a way to fix it. |
Thank you for your confirmation. I am looking forward to your good news. |
After multiple tests I can confirm that it is not a bug in the library code, it is a bug in the MediaExtractor class. MediaExtractor is not able to extract video frames from that video for some reason (audio is working). If you re encode the video using ffmpeg it is wofking fine so it is not a problem in the video config. The only solution will be implement a new extractor without MediaExtractor class but the only viable alternative is use the extractor of ExoPlayer project. The problem is that ExoPlayer need min API version 19 but this project have min API version 16 so I have plan to do a full refactor to decoders that will allow change the extractor allowing set a extractor based on ExoPlayer and add that extractor to extra-sources module which use min API 21. I will do this new feature for version 2.5.3 because this is a big change and I want avoid change more code in this version. |
Other alternative is use MediaPlayer class to get video frames and MediaExtractor for audio but I'm not sure if this solution is a good idea. What do you think about it?. I tested this but it produce others limitations |
Thank you for confirming. I also believe that using ExoPlayer is the best solution. I will wait for version 2.5.3 and test it once it's available. |
Hi @pedroSG94 , After updating to version 2.5.4, the problem persists, and there are additional issues. The audio is distorted and plays slowly. Here is the link to the video I streamed: YouTube Live Video. Here is the original video: Original Video. Additionally, this video cannot be streamed; it says it is not supported: Best regards, |
Hello, Thank you for the report. I will check it. I'm developing an Extractor using Exoplayer extractor instead of MediaExtractor from Android but it is not ready yet so all should be working like in the version 2.5.2 (the video that freeze is not working yet video2) I will check the new issues maybe related with the new decoder implementation and fix it. For now, use version 2.5.2 |
Hello, I checked the first file but the error related with slowly audio is present in previous versions before the change so It is not a problem only in the last version but maybe it is fixeable (still checking it). About the not supported error, it is because I added an additional check in the decoder that force the video used to have duration that I think is the problem because the video is freeze. If the duration can't be extracted, the video extraction fail in prepareVideo before start decoding to avoid reproduce video that will be invalid and freeze. I will check the first video but the second and third video should be fixed using the new extractor instead the current extractor. I think that report a fail is better than let the user reproduce it and produce a freeze. |
I discovered the reason about the first video fail. When you extract audio info from the first video using MediaExtractor or even with MediaMetadataRetriever the samplerate is 24000 but the real samplerate is 48000. This produce the slowly audio effect because the encoder is configured based on the decoder extracted value. If you hardcode the samplerate value all is working fine. This seem that it is not a problem in the decoder code but more a problem in MediaExtractor class of Android. I'm looking if I can find a way to fix it |
I added a commit that implement a Media3Extractor using the exoplayer project dependency that improve a bit this problem but still produce problems: |
Thank you! I’ll test it and report back to you. |
This new Extractor solve the problem with the first file but still have few problems using the second and third file (mostly with the second file). genericFromFile.setAudioExtractor(Media3Extractor(this))
genericFromFile.setVideoExtractor(Media3Extractor(this)) |
Hi @pedroSG94, I am using the following dependencies: implementation 'com.github.pedroSG94.RootEncoder:library:2.5.4'
implementation ('com.github.pedroSG94.RootEncoder:extra-sources:2.5.4') {
exclude module: 'UVCAndroid'
} When I implement version 2.5.4 and try to import Do you know how to resolve this issue? Thank you! |
Hello, It isn't in the last release. Use this for now: implementation 'com.github.pedroSG94.RootEncoder:library:73b7c9d43e'
implementation 'com.github.pedroSG94.RootEncoder:extra-sources:73b7c9d43e'
|
Hi @pedroSG94 ,
We are encountering an issue during screen broadcasting on Facebook, where an error appears after about a minute. This problem only occurs on Facebook; streaming to YouTube works fine. This error didn’t appear before, but it has started showing up recently, possibly after a recent update.
Branch: Master
Screen broadcast settings: 720x1280, 30fps, bitrate: 500*1000
Platform: Facebook
I’ve attached the full log. Could you please provide any suggestions to help resolve this issue?
OPPO-CPH2473-Android-14_2024-10-12_093032.txt.txt
The text was updated successfully, but these errors were encountered: