Skip to content

igor-silveira/video-encoder

Repository files navigation

Video Encoder Microservice

Environment Setup

To run in development mode, follow these steps:

  • Duplicate the .env.example file to .env
  • Run docker-compose up -d
  • Access the RabbitMQ management interface and create an exchange of type fannout. This will be a Dead Letter Exchange to receive messages that were not processed.
  • Create a Dead Letter Queue and bind it to the Dead Letter Exchange you just created. There is no need for a routing_key.
  • In the .env file, specify the name of the Dead Letter Exchange in the parameter: RABBITMQ_DLX
  • Create a service account in GCP with permission to write to Google Cloud Storage. Download the JSON file with the credentials and save it in the project root with the exact name: bucket-credential.json

Running

To run the encoder, execute the make server command directly in the container. Example:

docker exec encoder-new2_app_1 make server

Where microsservico-enconder_app_1 is the name of the container generated by docker-compose.

Message Format for Sending to the Encoder

For a message to be parsed by the encoder system, it must be in the following JSON format:

{
  "resource_id": "my-resource-id-can-be-a-uuid-type",
  "file_path": "convite.mp4"
}
  • resource_id: Represents the ID of the video you want to convert. It is a string.
  • file_path: The full path of the mp4 video within the bucket.

Message Format for Encoder Response

Successful Processing

For each processed video, the encoder will send the processing result to an exchange (to be configured in .env).

If the processing was successful, the JSON response format will be:

{
    "id":"bbbdd123-ad05-4dc8-a74c-d63a0a2423d5",
    "output_bucket_path":"codeeducationtest",
    "status":"COMPLETED",
    "video":{
        "encoded_video_folder":"b3f2d41e-2c0a-4830-bd65-68227e97764f",
        "resource_id":"aadc5ff9-0b0d-13ab-4a40-a11b2eaa148c",
        "file_path":"convite.mp4"
    },
    "Error":"",
    "created_at":"2020-05-27T19:43:34.850479-04:00",
    "updated_at":"2020-05-27T19:43:38.081754-04:00"
}

Where encoded_video_folder is the folder containing the converted video.

Processing Error

If there was an error during processing, the JSON response format will be:

{
    "message": {
        "resource_id": "aadc5ff9-010d-a3ab-4a40-a11b2eaa148c",
        "file_path": "convite.mp4"
    },
    "error":"Reason for the error"
}

Additionally, the encoder will send the original message that encountered a problem during processing to a dead letter exchange. Simply configure the desired DLX in the .env file under the parameter: RABBITMQ_DLX.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published