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

insert black screen for streaming as video #1305

Closed
lchy12345 opened this issue Oct 13, 2023 · 13 comments
Closed

insert black screen for streaming as video #1305

lchy12345 opened this issue Oct 13, 2023 · 13 comments

Comments

@lchy12345
Copy link

hi pedro,

I am using display service and displayBase to capture the screen and send it out to rtsp server. However, I found that the phone get very hot. So i would like to replace with black screen whenever necessary to save battery and lower the temperature.

I learnt that there is a function muteVideo, but it use the same amount of battery and increase temperature.

May I know is there a way to insert black screen without using too much battery and generating too much heat?

Thanks in advance.

@pedroSG94
Copy link
Owner

pedroSG94 commented Oct 13, 2023

Maybe we can try with this:
https://github.com/pedroSG94/RootEncoder/blob/master/library/src/main/java/com/pedro/library/base/DisplayBase.java#L581
This way you can reduce fps when necessary and set normal fps back when you need it.
I think you can use a low value like 2 or 3 fps because you send black screen so you can't see the difference.

Other way could be remove set force render to false to avoid render screen if it is not updated (keep in mind that few servers need receive video and audio so this way maybe produce disconnection if the screen is not updated)

Also, if you have the device connected to the logcat or just connected charging. Disconnect it because this produce heat

@lchy12345
Copy link
Author

Thanks so much, but this is not suitable for me.

I can now insert the black screen by streaming a prepared black screen mp4.

However, is it possible to loop the mp4 when the mp4 is finished? I am now using RtspFromFile and FromFileBase to do the streaming.

Thanks in advance

@pedroSG94
Copy link
Owner

@lchy12345
Copy link
Author

hi pedro,

I have tried the setloopmode but the video seems did not loop.

I called rtspfromfile.prepareVideo and then call rtspfromfile.setLoopMode and then call rtspfromfile.startStream.

May I know if I have done anything wrong?

Thanks so much.

@pedroSG94
Copy link
Owner

Hello,

This should be solved now. Try with app sample adding loop mode and let me know if it is working

@lchy12345
Copy link
Author

Hi pedro,

Thank you so much. I have tried setting loop mode.

I found that the seekbar was able to loop if i preparevideo and prepareaudio, but only the audio loop but not the video.

But if I preparevideo only (as my file only contain video), both the seekbar and the video did not loop.

May I know what can I do so work with only video file for looping? Thanks

@pedroSG94
Copy link
Owner

Hello,

Do you have a file to test your cases?
It is working for me with a file that contain video and audio. I will try remove audio and test again

@lchy12345
Copy link
Author

Dear Pedro,

I am using this black.mp4. I got the problem. Thanks

black.mp4

@pedroSG94
Copy link
Owner

Hello,

Fixed here:
#1314

I tested with your video using rtmpfromfile example after add this fix and it is working fine. Remember add loop mode and setOnlyVideo:

    rtmpFromFile.setLoopMode(true);
    rtmpFromFile.getStreamClient().setOnlyVideo(true);

here:
https://github.com/pedroSG94/RootEncoder/blob/master/app/src/main/java/com/pedro/streamer/filestreamexample/RtmpFromFileActivity.java#L89

Also, I did a full black video but of 20s to test loop:

blackshort.mp4

And other video of 20s with a count that help you to know if loop work fine

output.mp4

@lchy12345
Copy link
Author

Hi pedro,

I found it works. thanks so much.

Now i put the code this way

if (prepare()) {
button.setText(R.string.stop_button);
rtspFromFile.setLoopMode(true);
rtspFromFile.getStreamClient().setOnlyVideo(true);
rtspFromFile.startStream(etUrl.getText().toString());
seekBar.setMax(Math.max((int) rtspFromFile.getVideoDuration(),
(int) rtspFromFile.getAudioDuration()));
updateProgress();
}

just wanna confirm the setLoopMode and setOnlyVideo should be put before or after prepare()?

But I want to ask is that a must to have prepareaudio even if the mp4 has no sound? coz if I preparevideo only the loop does not work.

Thanks

@pedroSG94
Copy link
Owner

pedroSG94 commented Oct 30, 2023

just wanna confirm the setLoopMode and setOnlyVideo should be put before or after prepare()?

This should works in both cases. You can call it anytime before startStream/startRecord

But I want to ask is that a must to have prepareaudio even if the mp4 has no sound? coz if I preparevideo only the loop does not work.

This shouldn't be necessary so I will check it

@pedroSG94
Copy link
Owner

But I want to ask is that a must to have prepareaudio even if the mp4 has no sound? coz if I preparevideo only the loop does not work.

I was testing this with your video and my videos and it is working fine. Do you have this error always? Can you reproduce the problem using my videos?

I only removed this line:
https://github.com/pedroSG94/RootEncoder/blob/master/app/src/main/java/com/pedro/streamer/filestreamexample/RtmpFromFileActivity.java#L243

And added this to the class:

rtmpFromFile.setLoopMode(true);
rtmpFromFile.getStreamClient().setOnlyVideo(true);

@lchy12345
Copy link
Author

i can work with my video and your video now. Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants