AWS Builder Center
Q-bits: Easy video editing with Kiro command line

Q-bits: Easy video editing with Kiro command line

This blog post explores how Amazon Q Developer or Kiro for command line can simplify working with CLI tools such as ffmpeg

Welcome to another installment of  Q-Bits , our regular series showcasing cool ways Amazon employees are leveraging Amazon Q Developer. Today, we're diving into how Q Developer can assist with a popular command line tool called ffmpeg.
You can use Amazon Q Developer to enable completions for many command line tools such as like git, docker, and aws. This week I had to upload a video recording to our wiki, but due to a dropped call, the video was in two segments. I decided to try Amazon Q Developer with a popular video editing tool called ffmpeg. In this blog post, I will show you how you can use NLP to carry out some common video editing tasks quickly. I will also show where you may need to rely on more specialized software beyond the command line.
Pre-requisites: I assume that you already have Q-Developer for command line installed. Make sure that you have already completed the authentication workflow using q login. Then use q chat to start your session. Fo each of the prompts below, Q Developer first describes what it will do, synthesizes the command, then executes it. You can use the use the  /tools trustall  (or /acceptall in the old version) command to bypass typing  y  every time - use carefully as it can make system or code changes.

Combining video file segments and splicing out portions

First I needed to combine the two parts, and cut out portions of the recording around the time the meeting dropped, and at the end of the recording when there was some silence.
Prompt: Merge the two mp4 recordings to into one mp4 file using ffmpeg.
Q Developer proceeded to first install ffmpeg on my Mac using brew ran a long ffmpeg command to combine the files.
plaintext
# Q Developer output snippet:

The merged recording is now available as merged_recording.mp4 in your current directory. The merge was done using the "copy" mode, which preserves the original quality without re-encoding the video.
Prompt: Splice and cut the following segment out from the merged file: 24:01 to 24:37. Show progress while the command runs.
With this prompt, it extracted the small segment as a separated file which is not what I intended. I revised my prompt as below, which produced the correct behavior. This highlights the interactive nature of working with Q Developer command line.
Revised prompt: I meant that remove the segment from the merged file. The final output should contain the entire video minus the above time slot.
plaintext
# Q Developer output snippet

The final output file final_without_segment.mp4 (282 MB) is now available in your current directory. It contains the entire original video minus the segment from 24:01 to 24:37, as requested.

The process was done using the "copy" mode, which preserves the original video quality without re-encoding.
Prompt: Now can you remove the portion 1:20:21 to the end of the final video?
It followed a similar process as the previous task:
plaintext
# Output snippet

Details of the final trimmed video:
• File size: 262 MB
• Duration: 1:20:21 (4821.05 seconds)
• The video now contains only the content from the beginning up to 1:20:21, with the segment from 24:01 to 24:37 also removed (as done in the previous step)

Blurring or masking parts of video frames

Prompt: I want to you to blur a portion of the directory path from a demo from 20:50 to 23:30.
Hiccup: Here Q developer acknowledged that this is a complex task and said it needs the coordinates and size of the box to blur. It extracted three sample frames from the specified segment that I can inspect in another tool (such as preview) to provide the information. I did supply the blurring coordinates and size of the box but the final ffmpeg command was stuck (or just taking a long time).
I switched to a visual video editing tool to blur multiple segments. However this process actually left the video file size quite large. I wanted to compress it for easier video upload and transcoding.

Speeding up demo segments and compressing

Prompt: In the trimmed video, I have a demo from 20:50 to 23:30. Can you remove some frames in this segment to make the demo go faster? Save the file under a new name
plaintext
# Output snippet

The final video maintains the same overall content but with the demo segment playing at double speed. This makes the demo go faster while keeping the audio synchronized (though it will sound higher-pitched due to the speed increase).
The 70% optimization was impressive. I opened the file and really could not tell much of a difference in the video, even in my large monitor! Finally, I used Q Developer command line to help me upload the video file to S3 using the AWS CLI.
In this post we reviewed a use-case for Q Developer to speed up tasks with a popular video editing command line tool called ffmpeg. Whether you are using tools within your SDLC, building an application, or have a one-off task such as video editing, Q developer can really help you save time and mental energy. You can use for other high-value tasks such as going for a walk.
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article