Introduction
In this article, we will explore the possibility of using FFmpeg to export Davinci Resolve clips without re-encoding. The main video for example is 60 seconds long, and the objective is to cut the clips from the main video and export them without compromising the original video quality.
Prerequisites
To follow this article, make sure you have the following installed:
- A recent version of Davinci Resolve (we used version 17 for this article).
- The latest FFmpeg build for your operating system.
Workflow Overview
Here's a brief overview of the process:
- Perform rough cuts in Davinci Resolve, marking In and Out points for the desired clips.
- Export the timeline from Davinci Resolve as an XML file.
- Create individual MP4 files for each clip using the XML file and FFmpeg, all without re-encoding the original video.
Step 1: Prepare Clips in Davinci Resolve
Start by importing your video into Davinci Resolve. Perform any needed edits, and set In and Out points for the sections you want to export.
Step 2: Export XML File from Davinci Resolve
Next, you need to:
- Switch to the "Cut" page in Davinci Resolve.
- Select the Timeline dropdown list > "Export Timeline" > "XML">.
- Specify a location for your XML file.
Step 3: Export Clips with FFmpeg
Now, you will use FFmpeg to:
- Create a clip list file containing the In and Out times from the XML file.
- Segment the original video according to the clip list, saving each clip as a separate MP4 file.
3.1 Clip List File
Use an XML parser like Python's xml.etree.ElementTree to extract the In and Out points from the XML file and format them for FFmpeg.
3.2 Segment the Original Video
With the clip list ready, use the following FFmpeg command:
ffmpeg -i input.mp4 -f concat -sseof -5 -i clip_list.txt -c copy output_%03d.mp4Here,:
input.mp4: original video.clip_list.txt: clip list file.output_%03d.mp4: sequential MP4 filenames (with 3-digit padding, e.g., output\_001.mp4).
Summary
You can cut the clips from a main video in Davinci Resolve without re-encoding them, by exporting an XML file with In and Out points for each clip. Utilizing Python and FFmpeg, you can leverage these XML data to create individual MP4 files for each clip, all without re-encoding the original video.