ffmpeg - How to check (programmatically) if a file has DRM protection?
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 !
ffmpeg drm
add a comment |
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 !
ffmpeg drm
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
add a comment |
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 !
ffmpeg drm
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 !
ffmpeg drm
ffmpeg drm
edited Dec 18 '18 at 0:40
waldenCalms
asked Dec 18 '18 at 0:19
waldenCalmswaldenCalms
205
205
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
add a comment |
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
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
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
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
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
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
add a comment |
0
active
oldest
votes
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "3"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385391%2fffmpeg-how-to-check-programmatically-if-a-file-has-drm-protection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
0
active
oldest
votes
0
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Super User!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsuperuser.com%2fquestions%2f1385391%2fffmpeg-how-to-check-programmatically-if-a-file-has-drm-protection%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
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