Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null reference exception using dump --format json on DRM protected file #25

Closed
tmr0861 opened this issue Sep 16, 2022 · 5 comments
Closed

Comments

@tmr0861
Copy link

tmr0861 commented Sep 16, 2022

Trying to extract the chapters from a DRM protected file and write to a file so I can write them back into the non-DRM protected version. I can dump the chapters using the standard format, and manually edit this into a standard chapter format, but this is time consuming.

Trying this command so I can automate all files:
tone dump drmfilename.m4b --include-property chapters --format json > chapters.json

Then write back with this command:
tone tag nodrmfilename.m4b --meta-tone-json-file="chapters.json" --auto-import="tonejson"

When I try to dump the chapters with the json format I get a null reference exception. Debugging the application, turns out that track.ChannelsArragement is null on these files. So, the SerializeAsync method fails with the null reference exception on this line:

Channels = new { Count = track.ChannelsArrangement.NbChannels, Description = track.ChannelsArrangement.Description },

I tried it with this line commented out and I was able to write the file fine without the Channels info and the nodrm file kept its existing Channels info.

Great tool btw!

@sandreas
Copy link
Owner

sandreas commented Sep 16, 2022

Hey thanks for this detailed report.

Trying to extract the chapters from a DRM protected file and write to a file so I can write them back into the non-DRM protected version.

Interesting approach :-)

When I try to dump the chapters with the json format I get a null reference exception. Debugging the application, turns out that track.ChannelsArragement is null on these files.

Ah I see, I did not know that this is even a possibility. Unfortunately, due to this exception it is not possible to workaround this issue by using tone.json format.

However, it would have been possible to use ffmetadata or ChptFmtNativeformat to overcome this, if there was a feature to auto-import / export and vice versa these :-/

 # no import possible
tone dump --format=ffmetadata 'audiobook.m4b' --include-property=chapters

# no export / dump possible
tone tag --auto-import=chapters 'audiobook.m4b'

So in a series of unfortunate events, I think you have to wait until this is fixed in the next release - I think I'll fix this pretty quick, but the next release will take some time.

Can you build a latest code version on your own?

Seems that I have to fix / add a few things here:

  • Handle the fact, that track properties, that can be null on encrypted files (most important)
  • Add possibility --auto-import=ffmetadata - more work than expected, thus created Add --auto-import=ffmetadata #27
  • Add possibility to dump --format=ChptFmtNative
  • Think over a nightly build for early adopters (the brave people) - created Add nightly / push builds for testers and people waiting for a specific feature #28
  • (Maybe add a parameter --exclude-leaf='audio' to skip whole parts of the dump, when using json) => this is something I have to think about - not now, keep the parameter count as small as possible

@tmr0861
Copy link
Author

tmr0861 commented Sep 16, 2022

Trying to extract the chapters from a DRM protected file and write to a file so I can write them back into the non-DRM protected version.

Interesting approach :-)

Well, it would have been better if I had found a utility that would just strip the encryption so I could play the audiobooks on non-iTunes players and not lose the chapters. :-)

Can you build a latest code version on your own?

Yes, I was able to comment out the offending line, build and run from within Visual Studio. I didn't spend a lot of time, but I would have to figure out how you created the portable exe version.

So in a series of unfortunate events, I think you have to wait until this is fixed in the next release - I think I'll fix this pretty quick, but the next release will take some time.

I'm not in a huge rush. I can wait until you get it fixed, and then I'll work on updating my library. This is a winter project anyways. :-)

@sandreas
Copy link
Owner

I didn't spend a lot of time, but I would have to figure out how you created the portable exe version.

This is easy, take a look at https://github.com/sandreas/tone/blob/main/tone/build.sh (you have to adjust the runtime id) or simply fork and run ./release.sh 0.1.1, then github will do the rest for you.

I'm not in a huge rush. I can wait until you get it fixed, and then I'll work on updating my library. This is a winter project anyways. :-)

Great, then I can take the time to fix this and some other things. Thank you for the quick feedback.

@sandreas
Copy link
Owner

sandreas commented Sep 19, 2022

Ok, should be fixed in the latest commits - targeted for v0.1.1. You can now also use

tone dump --format=ChptFmtNative my-file.m4b

to get a chapters.txt only dump, which then can be used for --auto-import=chapters

I would really appreciate feedback if this fixes it for you.

@tmr0861
Copy link
Author

tmr0861 commented Sep 24, 2022

Works like a charm! Either format will do what I need! Thanks for fixing it so quickly.

sandreas added a commit that referenced this issue Oct 10, 2022
Bumped atldotnet to 4.11
Improved release notes
Fixed #25 by writing atldotnet errors to stderr
sandreas added a commit that referenced this issue Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants