Skip to content

Batch Processing Videos with FFMPEG

As you may or may not know, I run couple of YouTube channels. One of the channels I post dash cam video of trips and bad driving. The other channel I post #" target="_blank">handyman and tech projects that I complete.

One of the most difficult parts of content cretaion is the editing process. Before trying to automate things, I would use Kdenlive to edit, place graphics, and produce my videos. I occasionally still use it now, but far less than before I decided to utilize automation.

Why Automate?

Automation frees your time up to do other things. When it comes to my handyman work, it allows me to take on more jobs and thus have more content to produce. It in theory is a neverending cycle, and in this case that is a good thing.

Automating the video process also meant making videos follow a consistent pattern. Reason being is that the more variations that exist in the videos, the more scenarioes that would have to be coded, which means the more complex the automation. Now having complex automations is not always a bad thing, but for me I was going for simple, repeatable, and consistent.

Simple, Repeatable, and Consistent

When you watch some TV shows, the way that they are structured is the same every episode. For example, "Wheel of Fortune". The way the show is set up, there are multiple rounds of puzzles to be solved. The Final Spin is always done 10 minutes before the show goes off. There's a commerical break between every other puzzle. Every episode is 30 minutes. The list goes on.

With the dash cam videos, what I decided to do was to remove the video intro, and go straight into the video. Information about the video, such as distance travelled and major routes taken, are displayed as graphics in the lower third of the video.

With the handyman and tech videos, I have an opening segment, followed by show video clip, followed by the rest of the video. The video clips are named in alphabetical order that they should be rendered in. Then when the script creates the input file for ffmpeg, it can list them in alphabetical order using the ls command.

When it comes to archiving the video footage, incease it needs to be recreated in the future, the automated solution can package and move the files to the archive destination. I have designed my script so that it follows a similar data warehousing application that I used to support. The way that application worked was that tar files were received to an incoming directory. Then when the script ran, it would extract the contents to a working directory. From there the data was processed and loaded into the database. Then the file was moved from the incoming directory to the archive directory. Then the process would repeat.

This script is similar in nature in that each file is packaged by me by hand, then moved to the directory that the script is monitoring. Then the script does the rest. The difference is that there is an Upload directory, where the file that is ready to be uploaded is placed and is separated from the tar file which is placed into the Archive directory.

Conclusion

Automating tasks frees you to do other work. Even if you are only able to automate some of the task, that is better than having no automation at all of the task. As time goes on, I will work on extending this automation or building new automations that will be able to perform finding keywords for the videos based on the title and automatically saving those. that will further reduce amount of effort to publish online content.


Last update: 2022-09-16
video processing, ffmpeg, youtube, video automation