ffprobe (ffmpeg) searches in an audio file

j & # 39; uses ffprobe look to position yourself on mp3 files, and it works well. That's how I do it in my ffprobe node.js wrapper:

search = function (fpath, seconds) {
var self = this;
return a new promise ((solve, reject) => {
// ffprobe -i /myfile.mp3 -show_frames -show_entries frame = pkt_pos -of default = noprint_wrappers = 1: nokey = 1 -hide_banner -loglevel panic -read_intervals 20% + # 1
var loglevel = self.logger.isDebug ()? & # 39; debug & # 39; panic & # 39 ;;
const args = [
          '-hide_banner',
          '-loglevel', loglevel,
          '-show_frames',//Display information about each frame
          '-show_entries', 'frame=pkt_pos',// Display only information about byte position
          '-of', 'default=noprint_wrappers=1:nokey=1',//Don't want to print the key and the section header and footer
          '-read_intervals', seconds + '%+#1', //Read only 1 packet after seeking to position 01:23
          '-print_format', 'json',
          '-v', 'quiet',
          '-i', fpath
        ];
const opts = {
cwd: self._options.tempDir
};
const cb = (error, stdout) => {
if (error)
returns the rejection (error);
try {
const outputObj = JSON.parse (stdout);
return resolution (outputObj);
} catch (ex) {
self.logger.error ("failed search% s", ex);
return the rejection (ex);
}
};
cp.execFile (& # 39; ffprobe & # 39 ;, args, opts, cb)
.on (& # 39 ;, rejects);
});
}//search

So, look for a specified Start time position in seconds that you do

search (path, start time)

and then you will get the equivalent in bytes by looking at the packet of the first frames managerial staff as:

position = function () {
if (this.raw.frames) {
if (this.raw.frames.length> 0) {// get the first feed reference
if (this.raw.frames[0].pkt_pos) {// get the first feed reference
return this.raw.frames[0].pkt_pos;
}
}
}
come back again;
}//position

So when you are looking for a mp3 drop it works well and the beach query is

rangeBytes bytes = 80685-8000685 {
"url": "",
"way": "",
"gross": {
"Frames": [
      {
        "pkt_pos": "80685"
      }
    ]
  }
} {
"url": "",
"way": "",
"gross": {
"Frames": [
      {
        "pkt_pos": "8000685"
      }
    ]
  }
}

the problem is that when I use it on a wave file, the resulting range query for the wave file:

rangeBytes bytes = 768058-76800058 {
"url": "",
"way": "",
"gross": {
"Frames": [
      {
        "pkt_pos": "768058"
      }
    ]
  }
} {
"url": "",
"way": "",
"gross": {
"Frames": [
      {
        "pkt_pos": "76800058"
      }
    ]
  }
}

will not work in the standard HTML5 audio player.

NOTE
the ffprobe The command line I used with the wrapper above was:

ffprobe -i /myfile.mp3 -show_frames -show_entries frame = pkt_pos -of default = noprint_wrappers = 1: nokey = 1 -hide_banner -loglevel panic -read_intervals 20% + # 1

I guess if that applies both mp3 and wave files.