beandog / dvd_info

Linux/BSD/Cygwin DVD utilities - dvd_info, dvd_copy, dvd_backup, dvd_player, dvd_rip, dvd_drive_status
http://dvds.beandog.org
GNU General Public License v2.0
22 stars 4 forks source link

libdvdread outputs to stdout when reading from disk, ruining JSON output #11

Open koorogi opened 3 months ago

koorogi commented 3 months ago

Here's the beginning out the output I get when running dvd_info -j /dev/sr0 for a DVD I have.

libdvdread: Attempting to retrieve all CSS keys
libdvdread: This can take a _long_ time, please be patient
libdvdread: Get key for /VIDEO_TS/VIDEO_TS.VOB at 0x0000013d
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_01_0.VOB at 0x000004ee
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_01_1.VOB at 0x000090d8
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_02_0.VOB at 0x002903f2
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_02_1.VOB at 0x00290598
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_03_0.VOB at 0x002912f9
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_03_1.VOB at 0x0029149f
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_04_0.VOB at 0x002b486d
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_04_1.VOB at 0x002b4a13
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_05_0.VOB at 0x003189da
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_05_1.VOB at 0x00318b80
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_06_0.VOB at 0x00318b9c
libdvdread: Elapsed time 0
libdvdread: Get key for /VIDEO_TS/VTS_06_1.VOB at 0x00318d42
libdvdread: Elapsed time 0
libdvdread: Found 6 VTS's
libdvdread: Elapsed time 0
{
 "dvd": {
   "title": "500DAYSOFSUMMER_RENTAL",
   "side": 1,
   "tracks": 13,
   "longest track": 1,
   "vmg id": "DVDVIDEO-VMG",
   "video title sets": 6,
   "dvdread id": "1b4b5cb5c064371deb3f1db41e2d8623"
 },

All those libdvdread logging lines are included in stdout, and make it impossible to parse the JSON without going out of my way to filter them out.

It looks like libdvdread offers a DVDOpen2 function which allows you to provide a custom logging callback, to direct the log message somewhere other than stdout.

beandog commented 1 day ago

Thanks for the bug report, I had no idea DVDOpen2 was even in there!

In the past, I've patched my own copy of libdvdread to disable log output completely, which is obviously not sustainable.

Fixed so it dumps any libdvdread logs to stderr instead of stdout, and only displays if its log level is ERROR or WARN.

@koorogi can you test it with latest commit and see if you run into any errors? thanks