Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| computers:ffmpeg [2023/03/05 01:12] – jon | computers:ffmpeg [2025/12/15 16:40] (current) – jon | ||
|---|---|---|---|
| Line 98: | Line 98: | ||
| Example using Powershell: | Example using Powershell: | ||
| < | < | ||
| + | |||
| + | === Caveats to cropping === | ||
| + | |||
| + | When you do cut with -c copy (no re-encode), and the cut point is not exactly on a keyframe, and/or the video uses B-frames (re-ordered frames), ffmpeg can’t rewrite frames to make a clean boundary. It copies packets but the decode/ | ||
| + | |||
| + | Players often still play linearly, but seeking near the splice can fail hard (especially around the crop point). mp4 is particularly sensitive because it stores timing/ | ||
| + | |||
| + | Workaround is to use a copy-cut and regenerate timestamps | ||
| + | |||
| + | < | ||
| + | -map 0 -c copy \ | ||
| + | -fflags +genpts -avoid_negative_ts make_zero \ | ||
| + | croppedvid.mp4</ | ||
| + | |||
| + | Then, "remux normalize" | ||
| + | |||
| + | < | ||
| + | ffmpeg -i croppedvid.mp4 -map 0 -c copy -movflags +faststart fixed1.mp4 | ||
| + | </ | ||
| + | |||
| ==== Joining video files together (Concatenate) ==== | ==== Joining video files together (Concatenate) ==== | ||
| Line 103: | Line 123: | ||
| https:// | https:// | ||
| https:// | https:// | ||
| + | |||
| + | Make a text file in the same directory. Each video needs the word ' | ||
| + | < | ||
| + | file videofile.mp4 | ||
| + | file videfile2.mp4 | ||
| + | </ | ||
| + | |||
| + | Here's how I've scripted this. Note, this pertains more to macOS with the sed statement since the single quotes are needed, but the tweak for linux is to just remove the single quotes and the -e | ||
| + | < | ||
| + | find . -type f > concat.txt && sed -i '' | ||
| + | </ | ||
| + | |||
| + | Then, reference the text file as your input. | ||
| + | < | ||
| + | ffmpeg -f concat -safe 0 -i concat.txt -c copy output.mp4 | ||
| + | </ | ||
| ==== Splitting a large video into smaller clips ==== | ==== Splitting a large video into smaller clips ==== | ||