Sunday, January 7, 2024

ffmpeg - concatenation and edits

See also this post.

you are entering HELL if you want to join a few video clips

WHAT SHOULD BE THE SIMPLEST COMMAND IN LINUX VIDEO EDITING CAN ACTUALLY BARELY BE ACCOMPLISHED. MUCH WORSE THAN M3U ANNOYANCES. NO CLI OR GUI. MELT USUALLY FAILS WITH C LIBRARY DEFICITS. HAVE TO USE FFMPEG.

MUST CREATE A TEXT FILE WITH THE WORD "FILE" AND A HARD PATH FOR EVERY FILE TO BE JOINED IF THEY ARE NOT IN THE SAME DIRECTORY, PLACING THEM IN CONCATENATION ORDER. WANT TO TOY WITH ORDER? MAKE ANOTHER ENTIRE FILE. HOURS AND HOURS AND HOURS OF EXTRA WORK.

EVEN WORSE EVERY SINGLE VARIABLE INSIDE EVERY FILE MUST MATCH: BITRATE, PIXEL SIZE, ASPECT, CLOCK, EVERYTHING, MUST MATCH OR EVEN THIS POS METHOD WILL FAIL, WHICH IT MOST OFTEN DOES.

file '/home/foo/file1.mp4'
file '/home/foo/file2.mp4'
file '/home/foo/file3.mp4'

It's that bad. In fact the only thing this process is good for -- whenever it actually works -- is a person knows that each clip independently was fully prepped. So in case I wanted to edit them in some other order -- which happens a LOT for most ppl -- the clips might successfully bond in the new order.

The best results come from combine files with least number of renders. The best way to do this is to do your edits so you end up with a similar tbn, bitrate, and pixel size. There are other problems sometimes with fast concatenations, but the sign that all the edits are done right is that it only takes a list text file and a simple...

$ ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.mp4

Even if you cut these clips from a single larger file without recompiling -- ie, we *know* the DTS and PTS are correct -- you will get shitloads of DTS ("Decoding Time Stamp") errors. The system is absolute SHIT. To avoid the DTS erros, a person would have to re-render *every single clip* BEFORE joining them with an absolute clock, eg.

$ ffmpeg -i clip2.mp4 -video_track_timescale 90000 clip2timed.mp4

...before joining the clips. Can you farking imagine?

best edit process

At least check the edits after done, prior to concatenate, to see they have a reasonably close tbn. Like if you snip off the first 10 seconds of a vid, you definitely don't want to render the vid. But if a check in ffmpeg -i shows a weird tbn, then you have to, or at least try again. eg defaults, 15232, or 11488. I usually use 15232, because I remember it. Phones typically run 90000. And if I have to do a render, I also get some other action done

$ ffmpeg -i messy.mp4 -video_track_timescale 11488 -vf "eq=gamma=1.1:saturation=0.9" output.mp4

No comments: