0

Ok, so my task is this:

  1. Cut a video up into N parts.
    • ffmpeg -i in.mpg -ss 10 -t 10 -codec copy part1.mpg
    • ffmpeg -i in.mpg -ss 30 -t 10 -codec copy part2.mpg
    • ...
  2. Cat these parts together
    • cat part1.mpg part2.mpg ... > temp.mpg
    • This file runs fine, but the duration etc is messed up due to bad PTS values.
  3. Run it through FFmpeg
    • ffmpeg -i temp.mpg -codec copy out.mpg
    • This file also runs fine, but for the exact duration of the cuts, there is now black space. The PTS is fixed, but it is accounting also for the removed frames.

How can I correct the PTS values?

Edit: I am forced to use an older version of FFmpeg (hence no use of filters such as trim, or the concat demuxer).

  • I think every time you are running command to split videos, you should use setpts filter, like: ffmpeg -i in.mpg -ss 10 -t 10 vf "setpts=PTS-STARTPTS" -codec copy part1.mpg Then probably it would work, but using cat for video is not really a good idea. – ptQa Dec 18 '13 at 10:02
  • I'll try that. Cat is my only option unfortunately (to my knowledge). – Knossos Dec 18 '13 at 10:08
  • Thank you, that seems to have helped. Could you set your comment as an answer, so that I can accept it? – Knossos Dec 18 '13 at 10:28
3

Every time you are running command to split videos, you should use setpts filter, like:

ffmpeg -i input.mpg -ss 10 -t 10 -vf "setpts=PTS-STARTPTS" -c copy part1.mpg

Then probably it would work, but using cat for video is not really a good idea.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.