Question: Following is a code I implemented to create a bar chart using chart js in React app. Here it creates a bar chart with all the data in an array. But, I want to change this code only to give the output in the x-axis - destination, y-axis - no. of occurrence of this destination since it has many repeated destinations.
I searched methods to this but I couldn't get a correct solution.
Can anyone help me to do this?

```
const dataArrayY4 = [];
res.data.map(item => {
  dataArrayY4.push(item.time)
})
const dataArrayX4 = []
res.data.map(item => {
  dataArrayX4.push(item.destination)
})
this.setState({
  data4: dataArrayY4,
  labels4: dataArrayX4,
});

```

Answer: 
You need to remove the VideoTrack from your MediaStream:

```js
const input = document.querySelector("video");
const stop_btn = document.querySelector("button");
input.onplaying = (evt) => {
  input.onplaying = null;
  console.clear();
  const stream = input.captureStream ? input.captureStream() : input.mozCaptureStream();
  // get all video tracks (usually a single one)
  stream.getVideoTracks().forEach( (track) => {
    track.stop(); // stop that track, so the browser doesn't feed it for nothing
    stream.removeTrack( track ); // remove it from the MediaStream
  } );
  const data = [];
  const recorder = new MediaRecorder( stream, { mimeType: "audio/webm" } );
  recorder.ondataavailable = (evt) => data.push( evt.data );
  recorder.onstop = (evt) => exportFile( new Blob( data ) );

  stop_btn.onclick = (evt) => recorder.stop();
  stop_btn.disabled = false;
  recorder.start();  
};
console.log( "play the video to start recording" );

function exportFile( blob ) {
  stop_btn.remove();
  input.src = URL.createObjectURL( blob );
  console.log( "video element now playing recoded file" );
}
```

```css
video { max-height: 150px; }
```

```html
<video src="https://upload.wikimedia.org/wikipedia/commons/2/22/Volcano_Lava_Sample.webm" controls crossorigin></video>
<button disabled>stop recording</button>
```

And since StackOverflow's null origined iframes don't allow for safe download links, [here is a fiddle](https://jsfiddle.net/t4rdpas2/) with a download link.
You need to set the `mimeType` of the `MediaRecorder`. Otherwise the browser will pick whatever format it likes best to encode the media.

```
let mediaRecorder = new MediaRecorder(stream, { mimeType: 'my/mimetype' });

```

To be sure that the browser can actually encode the format you want you could use `isTypeSupported()`.

```
console.log(MediaRecorder.isTypeSupported('my/mimetype'));

```

Chrome for example doesn't support `"audio/ogg; codecs=opus"` but supports `"audio/webm; codecs=opus"`. Firefox supports both. Safari none of them.

Once you've configured the `MediaRecorder` you can use its `mimeType` when creating the blob.

```
recording = new Blob(chunks, { 'type' : mediaRecorder.mimeType });

```