Skip to content

Instantly share code, notes, and snippets.

@jsaowji

jsaowji/main.cpp Secret

Created September 20, 2023 09:16
Show Gist options
  • Save jsaowji/2bbf9c776a3226d1272e93bb245f7538 to your computer and use it in GitHub Desktop.
Save jsaowji/2bbf9c776a3226d1272e93bb245f7538 to your computer and use it in GitHub Desktop.
print ptt times ???? ./a.out <isopath> <title_nr>
// g++ main.cpp -ldvdnav -o dvdsrc_dvdnav_title_ptt_test
#include <assert.h>
#include <cstdio>
#include <cstring>
extern "C" {
#include <dvdnav/dvdnav.h>
}
void nulllog(void *, dvdnav_logger_level_t, const char *, va_list) {}
int main(int argc,char** argv) {
if(argc <= 2) { printf("ERROR NOT ENOUGH ARGS"); return 0; }
dvdnav_logger_cb loggercb;
loggercb.pf_log = nulllog;
dvdnav_t* dvdnav;
//auto ret = dvdnav_open2(&dvdnav, argv[1]);
auto ret = dvdnav_open2(&dvdnav, nullptr,&loggercb,argv[1]);
int32_t titles;
dvdnav_get_number_of_titles(dvdnav, &titles);
//printf("Titles: %d\n",titles);
//uint64_t times[900];
uint64_t* times;
uint64_t duration;
//for (int i = 1; i <= titles; i++) {
{
int i = argv[2][0] - '0';
if(strlen(argv[2]) == 2) {
i*=10;
i+=argv[2][1] - '0';
}
int32_t parts;
dvdnav_get_number_of_parts(dvdnav, i, &parts);
dvdnav_title_play(dvdnav, i);
//printf("Title%d: %d Parts\n",titles,parts);
auto ret2 = dvdnav_describe_title_chapters(dvdnav,i,&times,&duration);
assert(ret2 == parts);
for(int j = 0;j < ret2; j++) {
//printf("%ld\n",times[j]);
printf("%f\n",(float)times[j] / 90000.0);
}
}
dvdnav_close(dvdnav);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment