user12052: 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.

user21709: (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;)

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

user37822: 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)

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

user17893: 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


user1871: 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


user17928: 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.

user1760: 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 <PID> to suspend.
Then resume with fg command or kill -s SIGCONT <PID>.
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.

12052: <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>
 21709: <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>
 32384: <p>Places windows in hibernate will pause the job if you need to shut down your machine for awhile.</p>
 37822: <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>
 13957: <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>
 17893: <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>
 1871: <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>
 17928: <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>
 1760: <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>
