ffmpeg-kit
ffmpeg-kit copied to clipboard
Is there any way to pause and resume the conversion process?
I want to pause the process, and then resume it later. is it possible?? if possible then please suggest me how can I do that?
@fsmdeveloper Could you share the command with which you want to use this behaviour and the reason for doing so(optimisation,etc)?
While FFmpeg does not have built-in pause and resume functionality for encoding, you can achieve similar results by splitting the encoding process into parts and then concatenating the results, or by using segmented intermediate files. This approach requires some manual intervention and management but allows you to effectively pause and resume the encoding process.
Example Using Split Files
Step 1: Initial Encoding
Encode the video until a certain point and stop it:
ffmpeg -i input.mp4 -t 00:05:00 -c copy part1.mp4
This command stops encoding at 5 minutes (00:05:00).
Step 2: Encoding from Stopped Point
Start encoding from where you left off:
ffmpeg -ss 00:05:00 -i input.mp4 -c copy part2.mp4
This command starts encoding from 5 minutes onward.
Step 3: Concatenating the Parts
Concatenate the encoded parts to form a complete video:
ffmpeg -f concat -safe 0 -i <(echo "file 'part1.mp4'"; echo "file 'part2.mp4'") -c copy output.mp4
Example Using Intermediate Files (Segmenting) This method involves segmenting the output into smaller chunks that can be easily resumed.
Step 1: Start Encoding with Segmenting
ffmpeg -i input.mp4 -c copy -f segment -segment_time 300 -reset_timestamps 1 out%03d.mp4
This command segments the output into 5-minute chunks (segment_time 300).
Step 2: Stop and Resume
Stop the process when you want to pause and resume by running the command again. Ensure the output files continue from the last segment:
ffmpeg -ss <timestamp> -i input.mp4 -c copy -f segment -segment_time 300 -reset_timestamps 1 out%03d.mp4
You will need to determine the correct timestamp to resume from.
For encoding videos to different formats:
ffmpeg -ss <timestamp> -i input.mp4 -c:v libx264 -c:a aac -f segment -segment_time 300 -reset_timestamps 1 -g 30 -sc_threshold 0 out%03d.mp4
Replace timestamp with the appropriate start time.
-c:v libx264 specifies the video codec. -c:a aac specifies the audio codec. -f segment enables segmenting. -segment_time 300 sets the segment duration to 5 minutes. -reset_timestamps 1 resets timestamps for each segment. -g 30 sets the GOP (Group of Pictures) size, ensuring keyframes are aligned with segment boundaries. -sc_threshold 0 disables scene change detection to ensure segments are consistent.
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.
This issue was closed because it has been stalled for 7 days with no activity.