Skip to content

Instantly share code, notes, and snippets.

@realies
Last active September 7, 2021 17:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save realies/7c5de4debba6d2af587bb31a548f7587 to your computer and use it in GitHub Desktop.
Save realies/7c5de4debba6d2af587bb31a548f7587 to your computer and use it in GitHub Desktop.
nodejs pts packet sequence analysis using ffprobe
const { execSync } = require('child_process');
const stdout = execSync(`ffprobe -of json -show_packets -show_streams -show_format -i ${process.argv[2]}`, { maxBuffer: 1024 * 1024 * 32 });
const { packets } = JSON.parse(stdout);
for (let i = 0; i < packets.length - 1; i++) {
const pts = Number(packets[i].pts);
const duration = Number(packets[i].duration);
const pts_next = Number(packets[i + 1]?.pts);
if (pts + duration !== pts_next) {
console.log(`timestamp issue on packet index: ${i + 1}, pts is expected to be ${pts + duration} but it is ${pts_next}`);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment