pinkfish / flutter_rtmppublisher

Publisher to rtmp using the camera plugin as a basis to do all the basic camera/record management.
BSD 3-Clause "New" or "Revised" License
95 stars 121 forks source link

Video preview turns dark when video streaming starts. #27

Open baitsaikiransudhir opened 3 years ago

baitsaikiransudhir commented 3 years ago

I'm using the youtube live stream api for streaming live videos. Whenever i start to the live stream, my video becomes dark.

It happens after i enable androidUseOpenGL property. Cannot disable because it leads to video freeze on stream start.

This is how my controller is initialized. `void getCameraDescription() async{ var cameras = await availableCameras(); cameraDescription = cameras.length > 1 ? cameras[1] : cameras[0];

cameraController = CameraController(cameraDescription, ResolutionPreset.medium, enableAudio: true, androidUseOpenGL: true);

cameraController.initialize().then((value){
  if(!mounted)
    return;
  setState(() {

  });
});

}`

Live stream start code. `Future startVideoStreaming() async{ if(cameraController == null){ return null; } if(!cameraController.value.isInitialized){ return null; } String myUrl = "rtmp://a.rtmp.youtube.com/live2/";

try{
  await cameraController.startVideoStreaming(myUrl);
}
catch(e){
  print(e);
  return null;
}

return myUrl;

}`