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

Switching between Rtmp stream audio and video #1486

Open
liuming1989 opened this issue May 25, 2024 · 7 comments
Open

Switching between Rtmp stream audio and video #1486

liuming1989 opened this issue May 25, 2024 · 7 comments

Comments

@liuming1989
Copy link

I currently have a feature
When I open the program, I only push audio content. When I need it, I can push a video with sound by clicking a button. When I don't need it, I can close the video and only push audio content
Excuse me, how can this method be implemented using Java code?
I found that sdk has the "RtmpOnlyAudio" method, but calling this method will result in the inability to push videos

@liuming1989 liuming1989 changed the title Switching between Rtmp pure audio and video Switching between Rtmp stream audio and video May 25, 2024
@pedroSG94
Copy link
Owner

Hello,

I think that for your case you should stream normally using camera and microphone with RtmpCamera2 for example.
Then you can disable video/audio on fly using this methods:

        //enable disable video
        if (genericCamera1.glInterface.isVideoMuted) {
          genericCamera1.glInterface.unMuteVideo()  
        } else {
          genericCamera1.glInterface.muteVideo()  
        }
        //enable disable audio
        if (genericCamera1.isAudioMuted) {
          genericCamera1.enableAudio()
        } else {
          genericCamera1.disableAudio()
        }

@liuming1989
Copy link
Author

thinks Im try

@liuming1989
Copy link
Author

How can GenericCamera1 turn off and on videos? I am using GenericCamera1

@liuming1989
Copy link
Author

java.lang.RuntimeException: You can't do it. You are not using Opengl
at com.pedro.library.base.Camera1Base.getGlInterface(Camera1Base.java:876)
at com.yishitu.vr3dhegang.LiveEncoderPlayActivity1.onClick(LiveEncoderPlayActivity1.java:239)
at android.view.View.performClick(View.java:7317)
at android.view.View.performClickInternal(View.java:7291)
at android.view.View.access$3600(View.java:838)
at android.view.View$PerformClick.run(View.java:28247)
at android.os.Handler.handleCallback(Handler.java:900)
at android.os.Handler.dispatchMessage(Handler.java:103)
at android.os.Looper.loop(Looper.java:219)
at android.app.ActivityThread.main(ActivityThread.java:8668)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:513)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1109)

@pedroSG94
Copy link
Owner

Hello,

As you can see in the crash you need use OpenGlView as view to do that instead of SurfaceView or TextureView

@liuming1989
Copy link
Author

I wrote the project based on "oldApi" in the demo, and this method cannot control the display and hiding of the video?

@pedroSG94
Copy link
Owner

That method turns your preview screen and stream black.

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