Last active
September 7, 2021 17:20
-
-
Save realies/7c5de4debba6d2af587bb31a548f7587 to your computer and use it in GitHub Desktop.
nodejs pts packet sequence analysis using ffprobe
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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