0

I want to compress .MOV videos to 360p and 720p using aws transcorder but i'm getting following error while creating job for compressing video

4000 b17c3141-20d2-4168-bf7f-8fb8a5a5ca35: Amazon Elastic Transcoder could not interpret the media file.

I've tried following code and expecting to make it work that we can compress MOV videos using AWS Transcoder

import { S3, ElasticTranscoder } from "aws-sdk";
import { config } from "dotenv";

const awsConversionPresets = {
    360: "1351620000001-000040",
    720: "1351620000001-000010",
};
const region = "ap-southeast-2";

config();

const getVideos = async () => {
    const s3 = new S3({ region });

    const items = await s3
      .listObjectsV2({
        Bucket: "my-bucket-id",
      })
      .promise();

    if (items.Contents) {
      return items.Contents.map((content) => content.Key) as string[];
    }

    throw new Error("No contents");
};

const transcodeVideos = async (videosArr: string[]) => {
    const transcoder = new ElasticTranscoder({ region });

    for (const video of videosArr) {
      const job = await transcoder
        .createJob({
          PipelineId: "1684136955957-d86lw1",
          Input: {
            Key: video,
            Container: "auto",
            AspectRatio: "auto",
            Resolution: "auto",
            FrameRate: "auto",
            Interlaced: "auto",
          },
          Output: {
            Key: `test-output/${video}`,
            PresetId: "1351620000001-100180",
          },
        })
        .promise();
    }
};

const main = async () => {
    const videos = await getVideos();
    transcodeVideos(videos);
};

main();
Anonymous Coward
  • 1,096
  • 11
  • 22

0 Answers0