computers:ffmpeg

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
computers:ffmpeg [2024/09/14 03:25] – [Joining video files together (Concatenate)] joncomputers:ffmpeg [2025/12/15 16:40] (current) jon
Line 98: Line 98:
 Example using Powershell: Example using Powershell:
 <code>ffmpeg -ss 00:53:00 -i 'input' -avoid_negative_ts 1 -to 07:19:17 -c copy 'output'</code> <code>ffmpeg -ss 00:53:00 -i 'input' -avoid_negative_ts 1 -to 07:19:17 -c copy 'output'</code>
 +
 +=== 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/display timestamps (DTS/PTS) can become inconsistent around the cut boundary. Then when you concat, ffmpeg sees timestamps going “backwards” and prints: "Non-monotonic DTS... This may result in incorrect timestamps."
 +
 +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/indexing in a way that makes sloppy cuts more painful than in some other workflows.
 +
 +Workaround is to use a copy-cut and regenerate timestamps
 +
 +<code>ffmpeg -ss 0 -to 02:03:12 -i ogvideo.mp4 \
 +  -map 0 -c copy \
 +  -fflags +genpts -avoid_negative_ts make_zero \
 +  croppedvid.mp4</code>
 +
 +Then, "remux normalize" the video to give clean metadata. This is a nice to do on all the videos that you're working on if concat-ing them togther
 +
 +<code>
 +ffmpeg -i croppedvid.mp4 -map 0 -c copy -movflags +faststart fixed1.mp4
 +</code>
 +
 ==== Joining video files together (Concatenate) ==== ==== Joining video files together (Concatenate) ====
  
Line 117: Line 137:
 Then, reference the text file as your input. Then, reference the text file as your input.
 <code> <code>
-ffmpeg -f concat -i concat.txt -c copy output.mp4+ffmpeg -f concat -safe 0 -i concat.txt -c copy output.mp4
 </code> </code>
 +
 ==== Splitting a large video into smaller clips ==== ==== Splitting a large video into smaller clips ====
 https://trac.ffmpeg.org/wiki/Seeking#Cuttingsmallsections https://trac.ffmpeg.org/wiki/Seeking#Cuttingsmallsections
  • computers/ffmpeg.txt
  • Last modified: 2025/12/15 16:40
  • by jon