'Flutter. Play raw h264 from WebSocket

I'm trying to display live video in flutter coming from video server. Video server sends raw h264 video through websocket. I know that this video can be played in browser by jmuxer library. For now I only get h264 frames, but I don't know posibility to display them. What I got:

void getFrames() async {
//some auth stuff
  HttpClientResponse response = await request.close();
  Socket socket = await response.detachSocket();
  WebSocket ws = WebSocket.fromUpgradedSocket(
    socket,
    serverSide: false,
  );
  ws.listen(
    (event) async {      
      print(parse(event)['data']);
    }
}
void main() {
  getFrames();
}

From that I got in console Uint8ArrayView's like:

[0, 0, 0, 1, 9, 240, 0, 0, 0, 1, 65, 154, 56, 18, 224, 163 ... ]
[0, 0, 0, 1, 9, 240, 0, 0, 0, 1, 65, 154, 84, 5, 184, 31, 114 ... ]
[0, 0, 0, 1, 9, 240, 0, 0, 0, 1, 103, 66, 192, 31, 217, 0, 180 ... ]

So question is - can I easily feed it to some flutter library to display video? If so, it would be nice to get some code example how to do it because I'm very-very new to dart/flutter and video processing. Thanks!

Update: I dumped this as binary data to file and then muxed it with ffmpeg like ffmpeg -f h264 -i input.raw -c copy out.mp4, so that file can be played by VLC. May be there is a way to do this 'on-fly' in flutter player with help of flutter_ffmpeg?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source