Etienne Charland
Etienne Charland

Reputation: 4024

FFmpeg Concat Corrupts Video

I'm using FFmpeg to encode video in several segments. For example, the user can encode 500 frames, close it, then resume to encode another 1300 frames, close it, and resume to encode another 700 frames.

At this point, I have 3 x265 streams in MKV files which I want to concatenate into a single file. I have no audio at this point.

I use this command to concatenate the 3 files into 1. However, the video file then plays with errors, skipping frames, changing speed or displaying artifacts at the junction points.

ffmpeg -y -f concat -fflags +genpts -async 1 -safe 0 -i "MergeList.txt" -c copy "Job5_Output.mp4"

What's the right way of concatenating my files?

The issue might be that I'm concatenating partial files (when the process was killed). I tried first muxing from MKV into MP4 to produce a valid file container, and then concatenating those MP4 files. The output has less corruption, but there are still visual glitches at the intersection points. The frame count is correct. The output file matches the frame count of all segments.

I just tried again with h264; the result is the same as with h265.

Upvotes: 0

Views: 1290

Answers (1)

Etienne Charland
Etienne Charland

Reputation: 4024

The problem is that killing FFmpeg didn't give it time to clean up its output file, resulting in corruption.

However, doing a soft kill on a hidden process in .NET is not easy.

After plenty of research, I found this solution that works. https://stackoverflow.com/a/29274238/3960200

Upvotes: 1

Related Questions