firefox does not support mkv format videos, need to convert video to mp4

am making a screen recorder app which recordrs your screen and u[pload video to s3 bucket. the video is mpk format. the mkv format is supported by chrome , edge but not by firefox. Firefox supports mp4 format. so how do i convert the video to mp4 format for firefox.

FFmpeg is a very widely used library for that sort of thing. Note that mkv and mp4 are different container formats, the video codec may or may not stay the same, depending on how you’re recording the video. If the codec is one supported by mp4, too, you should avoid reencoding while converting the container format for best quality.

here i want to upload my videofile in mp4 format. can you please tell how to implement ffmpreg.

handleUploadBlob = async () => {
this.isLoading = true;

this.videoData.isRecorded = true;

this.awsUploadService

  .getSignedUrlS3(this.videoData.videoName, "video/x-matroska")

  .subscribe(({ url, keyFile }) => {

    this.awsUploadService

      .uploadfileAWSS3(url, "video/x-matroska", this.videoData.videoFile)

      .subscribe(

        (data) => {

          if (data["type"] === 4) {

            this.videoData.awsUrl = `https://${environment.S3_BUCKET_NAME}.s3.${environment.S3_Region}.amazonaws.com/${keyFile}`;

            const videoDocument = {

              keyFile,

              userRef: this.userDetails["_id"],

              title: "Sample Video",

              videoUrl: this.videoData.awsUrl,

              videoName: this.videoData.videoName,

            };

            this.videosService.create(videoDocument).subscribe(

              (data) => {

                this.videoData.videoId = data["_id"];

                this.generateThumbnailVideo(keyFile);

              },

              (error) => {

                Swal({

                  type: "error",

                  title: `Oops... ${error.error.name}!`,

                  text: error.error.message,

                });

                this.isLoading = false;

                throw error;

              }

            );

          }

        },

        (error) => {

          Swal({

            type: "error",

            title: `Oops... ${error.error.name}!`,

            text: error.error.message,

          });

          this.isLoading = false;

          throw error;

        }

      );

    (error) => {

      Swal({

        type: "error",

        title: `Oops... ${error.error.name}!`,

        text: error.error.message,

      });

      this.isLoading = false;

      throw error;

    };

  });

};

I can’t give you a few lines of Javascript that’ll do it. FFmpeg provides C libraries and a command line tool, you’ll have to find some way to integrate either in your software stack. Considering you’re using AWS anyway, maybe you can use that to run a command for each uploaded file that converts it?