Select Page

How To Pause and Resume FFMPEG

How to Pause and Resume FFMPEG

This is the story of how I learned how to pause and resume ffmpeg. I’m a pretty big multitasker when it comes to computing. I usually end up with a few hundred tabs open when I’m browsing and I always have a terminal open. Last week I was doing a job using Davinci Resolve.

In order for me to complete the job, I needed to convert about 60 or so .MTS files into Apple ProRes .MOV files. The entire project contained over 10 hours of content, and every file needed to be converted.

So I employed my fancy batch script to loop through all the .MTS files in a given folder, transcode them one at a time, and output them to another folder. Such an aweseome script, and I use it very often. But eventually, the way I was working through the project, I ran into a problem.

I needed to render a timeline out of Resolve, but my resources were already being used on this massive batch render. So how do I solve this problem?

TLDR; Here’s the Answer

It pretty much comes down to managing your Linux processes. If you’ve got a lot going on, and you need more control over which process gets the most resources, you have full control over that. And by the way, this trick can be used for ANY Linux process, not just FFMPEG!

Typically, if you have a running process in a terminal window, you can kill it using CTRL+C. That will kill the process, and you’ll have to start the whole command over again if you want to resume the task. So if I hit CTRL+C in the middle of my ffmpeg transcode… I’d end up with some finished files, a half-encoded file, and an incomplete batch. That sucks.

But there’s a different command that just stops the process instead of killing it. Basically pausing it in its current state, waiting for you to do something else. CTRL+Z is that magic command. This will pause a running process and send it to the background, and assigns that process a number. This will also return control of the terminal window back to you.

If you run a different task, then CTRL+Z, you’ll have multiple processes paused in the background, each with a number.

To see all the paused background jobs, you can simply run jobs to see a list of paused jobs.

Now that my running ffmpeg process is paused and in the background, I can render out that Davinci Resolve sequence without overloading my system. Awesome!

The fg Command

Okay, now my Davinci Resolve render is complete! I’ve delivered that sequence, but I need to continue my batch encode so I can finish the rest of the project. To bring that ffmpeg process back to the foreground and pick up where I left off, all I have to do is use the fg command.

The fg command can either take a job number as a parameter, or no parameter at all. If you don’t specify a job number, it will bring the default job [1] to the foreground and continue running that job.

That’s it!

The bg Command

If you have a running process that you want to keep running, but regain access to the terminal input, you can simply hit bg. That’ll keep the process going, but send it to the background. Just remember- CTRL+C doesn’t work on background processes. In order to kill it, you’ll need to bring it to the foreground with fg.

Check out more articles

How to Generate a Ranger Config File

ranger --copy-config=all This will copy all the default config files from /usr/local/lib so you can make edits without messing anything up. Huge shout out to https://dquinton.github.io/debian-install/config/ranger.html for explaining this and so much more. Took me a...

First Open Source Contribution

Surprise! I genuinely did not plan on making my first ever open source contribution today. In fact, I didn't plan on a lot of things happening this week at all. I recently got an awesome opportunity to work on a site that is being hosted on a platform called Pantheon,...

How to Exclude Specific Posts and Pages from WP_QUERY

For the sake of having something to work with, let's suppose we've got the following query:In this query, inside the $args array, there's a special parameter that allows you to exclude specific posts and pages from the query. This parameter is called post__not_in and...

Configure SSH For Password-less Connections

Preamble I'm slightly embarrassed to admit this, but it was a long time before I figured out how amazing this little file is and how exactly to put it to good use. The file I'm talking about is the SSH config file. By default, when you first connect to a server via...

WordPress Site Stuck in Maintenance Mode

Plugin Error Code 500 During Update While I was updating a WordPress plugin locally, something happened on my local server to trigger a 500 error code as the plugin was updating. On the frontend, I refreshed the page and was greeted with "Briefly Unavailable for...

Creating a WordPress Plugin Downloader

How it Started I was recently tasked with the challenge of creating a WordPress theme generator. The idea being, instead of writing your style.css file from scratch, you'd be able to just answer a few simple questions about how you'd like your theme set up, and those...

Fix Audio on XFCE Chromebook

The Problem After moving from GalliumOS to Xubuntu, I noticed that playing YouTube videos on both Firefox and Chromium would result in decent playback for a few minutes, but suddenly the audio would turn into a solid beeping tone while the YouTube video displayed the...

Adjust Trackpad Sensitivity XFCE

xinput set-prop "Elan Touchpad" "Synaptics Finger" 1 1 1 What are the values 1 1 1? This sets the sensitivity as close to the original ChromeOS as possible. Larger numbers will decrease sensitivity of various aspects. I never looked into which individual value...

Fireworks (Short Film)

https://vimeo.com/395077249 About the film Year: 2020 Director/DP: Tim Searfoss Writers: Matt Jones, Tim Searfoss Sound Mix: Matt Jones

Hosting Multiple Sites Using LocalWP

I've done a write-up on hosting local WordPress sites before, but I definitely prefer this method over the previous one. If you've never tried hosting multiple sites using LocalWP, then I'd encourage you to check it out. I've had really bad issues with it in the past,...