<p>On Windows, pressing the "Pause/Break" key (the top-right most key) will pause it.  Enter will resume.  </p>

<p>If it doesn't work, click on the command prompt window to give it focus.</p>

CC BY-SA 4.0
2018-08-06T13:14:40.197Z
This is the easiest and best answer for Windows (verified on Windows 10).
lidsinker
CC BY-SA 4.0
2021-01-29T17:58:03.333Z
@kite Applications that run in Windows terminals are called TSRs, Terminate and Stay Resident. They allocate pieces of available system memory to reside in. Removing them from that memory allocation effectively stops the application. The only way to "save" a running app is to wrap it in some sort of memory manager that proxies the actual memory allocation. So, short answer, yes you can but it's not easy or simple in any form of the word(s).
dsanchez
CC BY-SA 4.0
2022-06-03T11:56:38.853Z
@kite The native way to of transfering application memory to hard drive is to increase your virtual memory size. Windows will move allocated memory of inactive applications to swap file, effectively freeing up physical memory for other applications. If it's a common scenario for you, you can increase virtual memory size far beyond physical memory, but take in mind that in order to actually work without slowing down 10x, applications do need physical memory.
Athari
CC BY-SA 4.0
2024-06-16T06:50:30.093Z
Do note that "selecting/marking text on the command prompt window to pause ffmpeg" won't work on the new Windows Terminal, and works only on the old conhost.
Sreenikethan I
CC BY-SA 4.0
2019-01-04T18:45:53.237Z
This frees up the cpu completely but the ram is still bottlenecked. In my case I have 8gb ram and it's using almost all of it still while the operation is paused. Any fix for that? Can I transfer this to the hdd or something? I don't mind a bit of a windup for things to get going when i unpause.
kite
CC BY-SA 3.0
2017-02-01T14:31:03.103Z
2017-02-01T14:31:03.103Z
BuckLee
<p>It didn't seem possible as of <a href="https://trac.ffmpeg.org/ticket/4895" rel="noreferrer">Sep 30 2015</a>. I would suggest segmenting the source file, encoding the segments and then stitching the resultant files. </p>

<p>This isn't a true pause/resume facility but the piecemeal division will allow you to have a break from encoding.</p>

<p>A rough overview of the commands to issue:</p>

<h2>Break the fullfile into parts</h2>

<pre><code>ffmpeg -i recording.mp4 -c copy -flags +global_header -segment_time n -f segment file%03d.mp4
</code></pre>

<p>This should create file000.mp4, file001.mp4 and so on. Because of how the segmenter works - it only cuts at I-frames - these files won't be exactly <code>n</code> seconds long and the video part may not play properly, but the data's all there and you can convert each of the parts e.g.</p>

<pre><code>ffmpeg -i file001.mp4 -{filter/encoding parameters} -fflags +genpts file001-new.mp4
</code></pre>

<h2>Rejoin the encoded parts</h2>

<p>Create a text file and put in the name of each rendered file like this</p>

<pre><code>file 'file000-new.mp4'
file 'file001-new.mp4'
.... 
file 'filelast-new.mp4'
</code></pre>

<p>And run</p>

<pre><code>ffmpeg -f concat -i textfile -c copy -fflags +genpts recording-encoded.mp4
</code></pre>

CC BY-SA 4.0
2018-12-22T06:04:35.497Z
Having only 6GB memory, and an estimated time of 12h to enconde from x264 to x265 and having no no-break (desktop), I cant use the VM trick, but this sounds great! I just expect the rejoining step is fast, but as there  will have no encoding on it, I think it will be. Have to try it, thx vm!
Aquarius Power
CC BY-SA 4.0
2018-12-24T00:16:31.123Z
it creates a warning when joining: "Codec for stream 0 does not use global headers but container format requires global headers" but the final result is a usable video, I saw no problems at all
Aquarius Power
CC BY-SA 3.0
2015-12-04T13:16:47.220Z
2015-12-04T13:16:47.220Z
Gyan
<p>I sugest instead of pausing, you give the encoding process the very least system priority (aka "<strong>renice</strong>"), so you can work daily comfortably and the encoding will take place in background with the unused system ressources. So your encoding will take place seamlessy 24/7 without interruptions, without conflicting with day work</p>

<p><em>as AFAIK OSX lacks the pidof command, you need to <a href="http://www.andrewhazelden.com/blog/2011/03/using-renice-to-control-cpu-usage/">know the ffmpeg process number</a> (PID)</em></p>

<p>then you can <strong>renice</strong> the process to idle background with</p>

<pre><code>sudo renice 20 yourPID
</code></pre>

<p>if needed you can also renice the process to more agressive foreground priority</p>

<pre><code>sudo renice -10 yourPID
</code></pre>

CC BY-SA 3.0
2017-01-29T12:01:14.457Z
Hi! Good suggestion. Will have to try it.
P A N
CC BY-SA 4.0
2022-04-14T11:08:30.647Z
Much easier to just start the process with `nice -19 ffmpeg ...` to begin with, rather than renicing it later. I find this allows you to browse and perform other tasks nicely. And when your machine isn't doing anything else, encoding proceeds with no visible impact on performance/speed.
kontextify
CC BY-SA 3.0
2017-01-29T11:52:56.517Z
2017-01-29T11:52:56.517Z
John Qube
<p>Suspending the Thread works on Windows too, not with <kbd>ctrl</kbd> + <kbd>Z</kbd>, but in the resource manager, you can also resume it there.</p>

CC BY-SA 4.0
2016-03-01T07:16:27.657Z
2019-12-20T18:12:24.453Z
2019-12-20T18:12:24.453Z
Jan Christian Grünhage
<p>(This for Linux) </p>

<p>As you all probably know, pressing 'q' ends the recording file.</p>

<p>ffplay has the 'p'-possibility. Why doesn't ffmpeg have the same thing?
Maybe because it can lead to desync between video and audio?...</p>

<p>I just ffmpeg-encode to x264-aac-mkv with crf (23) and always with the same video conditions, 
'quit' (q) the recordings and join all the segments in a specific dir, where this script resides,
 to 1 file in streamcopy mode with this bash-script:</p>

<pre><code>#!/bin/bash

# FFMPEG MERGE

# File path must be absolutely absolute...

ffmpeg -f concat -safe 0 -i &lt;(printf "file '%s'\n" /home/me/Videos/FFmpeg/FFmpeg_Merge/*.mkv) -c copy merged.mkv

exit 
</code></pre>

<p>After that I check the resulting merged video and paste it to another dir.
The segments are removed from the merge dir.</p>

<p>But, a hasslefree 'Pause &amp; Resume' button would be welcome indeed;)</p>

CC BY-SA 3.0
2018-03-18T12:50:23.773Z
2018-03-18T12:50:23.773Z
xinu
<p>Places windows in hibernate will pause the job if you need to shut down your machine for awhile.</p>

CC BY-SA 4.0
2020-09-30T12:49:19.633Z
2020-09-30T12:49:19.633Z
John Sohn
<p>In Windows...
Just click and drag to select some text from the CMD terminal, then you can see that the process has been &quot;paused&quot;, so no CPU usage is registered until you hit &quot;enter&quot; on the terminal (that unpause the process)</p>

CC BY-SA 4.0
2022-03-07T20:13:28.620Z
2022-03-08T03:17:29.270Z
2022-03-08T03:17:29.270Z
RobertVolley
<p>This is just an idea, but if you have some budget, it'd be a good idea to upgrade either the processor (to 8th gen Intel) or even better, the video card (to NVIDIA GTX 1050 or above) so you can encode h.265/HEVC with hardware acceleration instead of CPU-intensive <code>x265</code>. Your video encoding will be finished in much less than 20 hours, saving you electricity costs too.</p>

CC BY-SA 4.0
2022-01-30T08:51:42.807Z
ffmpeg page on hwaccel says the quality of output from gpu may not be the same. just a warning
qwr
CC BY-SA 4.0
2018-07-20T12:39:24.300Z
2018-07-20T12:39:24.300Z
Hendy Irawan
<h1>Suspend</h1>

<p>A simple method is to suspend it with <kbd>ctrl</kbd>+<kbd>z</kbd>. Or you could get the PID with <code>pgrep ffmpeg</code> then use <code>kill -s SIGSTOP &lt;PID&gt;</code> to suspend.</p>

<p>Then resume with <code>fg</code> command or <code>kill -s SIGCONT &lt;PID&gt;</code>.</p>

<p>Unfortunately this will not survive a reboot.</p>

<h1>VM</h1>

<p>If you use a virtual machine, with something like VirtualBox, you could perform your encoding in a guest VM. It will allow you to "save the machine state" at any time which can survive a reboot. It can also allow you to assign max CPU resources for the guest so your host will always have available resources.</p>

<p>Possibly overkill, but if you're familiar with VMs or using one already it is a possible solution.</p>

CC BY-SA 3.0
2017-02-01T17:56:38.370Z
I love that VM solution, however, unless you're already using one it's a pretty big hassle.
user3643
CC BY-SA 4.0
2019-04-01T06:39:28.820Z
The VirtualBox way didn't work for me. Tried just to save the state in mid-encoding, and tried to suspend by [Ctrl]+[z] and then save the state. After restoring the state and trying to resume, `ffmpeg` stops with an error (`decode_band_types: Input buffer exhausted before END element found` or `Invalid NAL unit size` and `Error writing trailer` / `Protocol error`). Maybe it's related to the jump in time, I don't know.
Jānis Elmeris
CC BY-SA 4.0
2019-04-01T17:07:16.507Z
@JānisElmeris I can't seem to duplicate that issue. I tried it on Ubuntu 18.04 VM and it worked.
llogan
CC BY-SA 4.0
2019-04-02T11:34:32.173Z
OK, I'm probably not lucky enough. :) Tried with a fresh Linux Mint 19.1 (based on Ubuntu 18.04) VirtualBox VM.
Jānis Elmeris
CC BY-SA 4.0
2019-07-16T08:00:32.143Z
my ffmpeg has many threds and as many PID. Do I have to SIGSTOP and SIGCONT each of them? is there a timely constraint?
wuppi
CC BY-SA 3.0
2015-12-05T00:35:32.183Z
2017-06-02T13:35:40.847Z
2017-06-02T13:35:40.847Z
llogan
<p>I record a few hours of video footage every day, which I set in queue for encoding with <code>ffmpeg</code>. I use the <code>veryslow</code> preset with <code>x265</code>, so a single hour of video may take up to 20 hours or more to encode.</p>

<p>Since my computer is working day and night, I'm wondering if <code>ffmpeg</code> has a way to <strong>pause and resume</strong> encoding? I'm using <code>Terminal</code> for OS X.</p>

<p>If so, can I also continue encoding even after shutting down Terminal and rebooting the computer? I think the Terminal session is restored when you log in again in OS X, at least the Terminal history is.</p>

<ffmpeg><osx>
Is there a way to pause and resume FFmpeg encoding?
P A N
# Is there a way to pause and resume FFmpeg encoding?

(Asked by: username_0 on 2015-12-04)

I record a few hours of video footage every day, which I set in queue for encoding with `ffmpeg`. I use the `veryslow` preset with `x265`, so a single hour of video may take up to 20 hours or more to encode.

Since my computer is working day and night, I'm wondering if `ffmpeg` has a way to **pause and resume** encoding? I'm using `Terminal` for OS X.

If so, can I also continue encoding even after shutting down Terminal and rebooting the computer? I think the Terminal session is restored when you log in again in OS X, at least the Terminal history is.

**Tags:** ffmpeg, osx


---

## 9 answers

### Answer by username_17 on 2015-12-05. Score: 34 | Accepted answer

# Suspend

A simple method is to suspend it with `ctrl`+`z`. Or you could get the PID with `pgrep ffmpeg` then use `kill -s SIGSTOP`  to suspend.

Then resume with `fg` command or `kill -s SIGCONT` .

Unfortunately this will not survive a reboot.

# VM

If you use a virtual machine, with something like VirtualBox, you could perform your encoding in a guest VM. It will allow you to "save the machine state" at any time which can survive a reboot. It can also allow you to assign max CPU resources for the guest so your host will always have available resources.

Possibly overkill, but if you're familiar with VMs or using one already it is a possible solution.

> **Comments:**
> **username_18**: I love that VM solution, however, unless you're already using one it's a pretty big hassle.  
> **username_19**: The VirtualBox way didn't work for me. Tried just to save the state in mid-encoding, and tried to suspend by [Ctrl]+[z] and then save the state. After restoring the state and trying to resume, `ffmpeg` stops with an error (`decode_band_types: Input buffer exhausted before END element found` or `Invalid NAL unit size` and `Error writing trailer` / `Protocol error`). Maybe it's related to the jump in time, I don't know.  
> **username_17**: @JānisElmeris I can't seem to duplicate that issue. I tried it on Ubuntu 18.04 VM and it worked.  
> **username_19**: OK, I'm probably not lucky enough. :) Tried with a fresh Linux Mint 19.1 (based on Ubuntu 18.04) VirtualBox VM.  
> **username_20**: my ffmpeg has many threds and as many PID. Do I have to SIGSTOP and SIGCONT each of them? is there a timely constraint?  

---

### Answer by username_1 on 2017-02-01. Score: 23

On Windows, pressing the "Pause/Break" key (the top-right most key) will pause it. Enter will resume.

If it doesn't work, click on the command prompt window to give it focus.

> **Comments:**
> **username_2**: This is the easiest and best answer for Windows (verified on Windows 10).  
> **username_6**: This frees up the cpu completely but the ram is still bottlenecked. In my case I have 8gb ram and it's using almost all of it still while the operation is paused. Any fix for that? Can I transfer this to the hdd or something? I don't mind a bit of a windup for things to get going when i unpause.  
> **username_3**: @username_6 Applications that run in Windows terminals are called TSRs, Terminate and Stay Resident. They allocate pieces of available system memory to reside in. Removing them from that memory allocation effectively stops the application. The only way to "save" a running app is to wrap it in some sort of memory manager that proxies the actual memory allocation. So, short answer, yes you can but it's not easy or simple in any form of the word(s).  
> **username_4**: @username_6 The native way to of transfering application memory to hard drive is to increase your virtual memory size. Windows will move allocated memory of inactive applications to swap file, effectively freeing up physical memory for other applications. If it's a common scenario for you, you can increase virtual memory size far beyond physical memory, but take in mind that in order to actually work without slowing down 10x, applications do need physical memory.  
> **username_5**: Do note that "selecting/marking text on the command prompt window to pause ffmpeg" won't work on the new Windows Terminal, and works only on the old conhost.  

---

### Answer by username_7 on 2015-12-04. Score: 17

It didn't seem possible as of Sep 30 2015. I would suggest segmenting the source file, encoding the segments and then stitching the resultant files. 
This isn't a true pause/resume facility but the piecemeal division will allow you to have a break from encoding.
A rough overview of the commands to issue:
Break the fullfile into parts
ffmpeg -i recording.mp4 -c copy -flags +global_header -segment_time n -f segment file%03d.mp4

This should create file000.mp4, file001.mp4 and so on. Because of how the segmenter works - it only cuts at I-frames - these files won't be exactly n seconds long and the video part may not play properly, but the data's all there and you can convert each of the parts e.g.
ffmpeg -i file001.mp4 -{filter/encoding parameters} -fflags +genpts file001-new.mp4

Rejoin the encoded parts
Create a text file and put in the name of each rendered file like this
file 'file000-new.mp4'
file 'file001-new.mp4'
.... 
file 'filelast-new.mp4'

And run
ffmpeg -f concat -i textfile -c copy -fflags +genpts recording-encoded.mp4

> **Comments:**
> **username_8**: Having only 6GB memory, and an estimated time of 12h to enconde from x264 to x265 and having no no-break (desktop), I cant use the VM trick, but this sounds great! I just expect the rejoining step is fast, but as there  will have no encoding on it, I think it will be. Have to try it, thx vm!  
> **username_8**: it creates a warning when joining: "Codec for stream 0 does not use global headers but container format requires global headers" but the final result is a usable video, I saw no problems at all  

---

### Answer by username_9 on 2017-01-29. Score: 9

I sugest instead of pausing, you give the encoding process the very least system priority (aka "renice"), so you can work daily comfortably and the encoding will take place in background with the unused system ressources. So your encoding will take place seamlessy 24/7 without interruptions, without conflicting with day work
as AFAIK OSX lacks the pidof command, you need to know the ffmpeg process number (PID)
then you can renice the process to idle background with
sudo renice 20 yourPID

if needed you can also renice the process to more agressive foreground priority
sudo renice -10 yourPID

> **Comments:**
> **username_0**: Hi! Good suggestion. Will have to try it.  
> **username_10**: Much easier to just start the process with `nice -19 ffmpeg ...` to begin with, rather than renicing it later. I find this allows you to browse and perform other tasks nicely. And when your machine isn't doing anything else, encoding proceeds with no visible impact on performance/speed.  

---

### Answer by username_11 on 2016-03-01. Score: 6

Suspending the Thread works on Windows too, not with `ctrl` + `Z`, but in the resource manager, you can also resume it there.


---

### Answer by username_12 on 2018-03-18. Score: 1

(This for Linux) 
As you all probably know, pressing 'q' ends the recording file.
ffplay has the 'p'-possibility. Why doesn't ffmpeg have the same thing?
Maybe because it can lead to desync between video and audio?...
I just ffmpeg-encode to x264-aac-mkv with crf (23) and always with the same video conditions, 
'quit' (q) the recordings and join all the segments in a specific dir, where this script resides,
 to 1 file in streamcopy mode with this bash-script:
#!/bin/bash

# FFMPEG MERGE

# File path must be absolutely absolute...

ffmpeg -f concat -safe 0 -i <(printf "file '%s'\n" /home/me/Videos/FFmpeg/FFmpeg_Merge/*.mkv) -c copy merged.mkv

exit 

After that I check the resulting merged video and paste it to another dir.
The segments are removed from the merge dir.
But, a hasslefree 'Pause & Resume' button would be welcome indeed;)


---

### Answer by username_13 on 2020-09-30. Score: 1

Places windows in hibernate will pause the job if you need to shut down your machine for awhile.


---

### Answer by username_14 on 2022-03-07. Score: 1

In Windows...
Just click and drag to select some text from the CMD terminal, then you can see that the process has been "paused", so no CPU usage is registered until you hit "enter" on the terminal (that unpause the process)


---

### Answer by username_15 on 2018-07-20. Score: 0

This is just an idea, but if you have some budget, it'd be a good idea to upgrade either the processor (to 8th gen Intel) or even better, the video card (to NVIDIA GTX 1050 or above) so you can encode h.265/HEVC with hardware acceleration instead of CPU-intensive `x265`. Your video encoding will be finished in much less than 20 hours, saving you electricity costs too.

> **Comments:**
> **username_16**: ffmpeg page on hwaccel says the quality of output from gpu may not be the same. just a warning  

---

