1

I have an app that runs ffmpeg/ffprobe as a child process (similar to running on the command line), and then parses the command output to retrieve metadata about a file and/or perform transcoding of the file. And my app needs to know whether or not a given file is DRM protected.

NOTE - I have looked at this question. It does not address programmatic parsing of output to determine DRM protection. It only addresses human parsing of output.

I already know that I can run ffprobe and if I scan through the output with my eyes and see something like "DRM protection detected ... decoding will likely fail" somewhere in the output, I know that the file is protected. See this sample output:

ffprobe -hide_banner CelticWoman-OnlyAWomansHeart.wma

[asf @ 0x7f9bab000000] DRM protected stream detected, decoding will likely fail!
Input #0, asf, from 'CelticWoman-OnlyAWomansHeart.wma':
Metadata:
...

However, there are two problems with the above output:

1 - It is not machine-friendly. I have to scan through a whole bunch of output to look for a few words. Parsing such output is inefficient, because it is intended for human consumption, not machine consumption.

2 - I don't know if the above output is consistent across different file types. In other words, the sample output above is for a WMA file in an ASF container. What if this were a FLAC or DTS or other kind of file ? Would the verbiage used be the same so my app could parse and detect it each time ?

What I need is some sort of output property that my app can reliably and predictably parse ... some key-value pair like "drm-protected=true" that is consistent across media file types

So, what options on ffprobe/ffmpeg will give me a machine-parseable key-value pair that tells me whether a file has DRM protection ?

Thanks a million !

  • DRM is a very broad term – there's no single mechanism in ffmpeg for detecting whether it's present or not. The string you found is only valid for ASF decoding. In your use case, are you talking about audio only? – slhck Dec 18 '18 at 8:14
  • Yes, audio only. Hmm, ok. – waldenCalms Dec 18 '18 at 10:31
  • I guess the real question is: Why does your app need to know that, and what kinds of files (containers, codecs) will you be handling? That said, I am not sure if there are really so many DRM formats for audio floating around. Probably iTunes (AAC/MP4), PlayReady (WMA/ASF), … – slhck Dec 18 '18 at 13:24
  • My app is an audio player, and cannot handle DRM files, so if DRM is detected, it will simply inform the user that it cannot be played. I noticed that ffmpeg transcoding actually appears to succeed (zero exit code) even though the file is protected, so I cannot always rely on the transcoding process exit code to detect an error, so I need some other way. Otherwise, ffmpeg will produce an empty file (a few KB) that actually plays silence for the duration of the track. This is not an ideal user experience for an audio player. I need to detect DRM protection so I can tell the user "Sorry". – waldenCalms Dec 18 '18 at 22:36

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.