How can I make Android's VideoView to read padded file?
Is it possible for Android's VideoView to read an MP4 file but skip the first 512 bytes?
Our client does not want his videos to be easily transferred/copied on different devices. What we did was to "obfuscate" the MP4 file by adding random 512 bytes at the beginning of the file and then renaming the files with a different file extension.
Obviously, the above approach does not perfectly protect his videos from being pirated. He's fine with just enough protection for "non-techies".
Currently, upon playing the video, our Android app extracts the actual video content to a new temporary file by skipping the first 512 bytes. This temp file will be the one played by the VideoView.
The problem is that this takes a long time especially that our videos are more than 100MB+ each. This is clearly not an acceptable solution.
I think, if we can just make the VideoView skip the first 512 bytes, we're all set. Is it possible? If not, what are the better alternatives?
Disclaimer: I'm the web developer of the server app that adds the 512-byte padding. I'm not an Android developer. I'm posting this question on behalf of my Android dev colleague. Forgive me if our approach is totally noob. Feel free to suggest better (and hopefully) easy ways.
android video videoview android-videoview
add a comment |
Is it possible for Android's VideoView to read an MP4 file but skip the first 512 bytes?
Our client does not want his videos to be easily transferred/copied on different devices. What we did was to "obfuscate" the MP4 file by adding random 512 bytes at the beginning of the file and then renaming the files with a different file extension.
Obviously, the above approach does not perfectly protect his videos from being pirated. He's fine with just enough protection for "non-techies".
Currently, upon playing the video, our Android app extracts the actual video content to a new temporary file by skipping the first 512 bytes. This temp file will be the one played by the VideoView.
The problem is that this takes a long time especially that our videos are more than 100MB+ each. This is clearly not an acceptable solution.
I think, if we can just make the VideoView skip the first 512 bytes, we're all set. Is it possible? If not, what are the better alternatives?
Disclaimer: I'm the web developer of the server app that adds the 512-byte padding. I'm not an Android developer. I'm posting this question on behalf of my Android dev colleague. Forgive me if our approach is totally noob. Feel free to suggest better (and hopefully) easy ways.
android video videoview android-videoview
I think the proper solution for this is would be a DRM-based approach instead of random padding.
– dashmug
Apr 15 '15 at 7:29
Dashmug, did you get answer for this? We are in same situation..
– user1923551
May 18 '15 at 9:48
@user1923551: No, I didn't find a solution for this. We're still using the workaround.
– dashmug
May 18 '15 at 22:09
add a comment |
Is it possible for Android's VideoView to read an MP4 file but skip the first 512 bytes?
Our client does not want his videos to be easily transferred/copied on different devices. What we did was to "obfuscate" the MP4 file by adding random 512 bytes at the beginning of the file and then renaming the files with a different file extension.
Obviously, the above approach does not perfectly protect his videos from being pirated. He's fine with just enough protection for "non-techies".
Currently, upon playing the video, our Android app extracts the actual video content to a new temporary file by skipping the first 512 bytes. This temp file will be the one played by the VideoView.
The problem is that this takes a long time especially that our videos are more than 100MB+ each. This is clearly not an acceptable solution.
I think, if we can just make the VideoView skip the first 512 bytes, we're all set. Is it possible? If not, what are the better alternatives?
Disclaimer: I'm the web developer of the server app that adds the 512-byte padding. I'm not an Android developer. I'm posting this question on behalf of my Android dev colleague. Forgive me if our approach is totally noob. Feel free to suggest better (and hopefully) easy ways.
android video videoview android-videoview
Is it possible for Android's VideoView to read an MP4 file but skip the first 512 bytes?
Our client does not want his videos to be easily transferred/copied on different devices. What we did was to "obfuscate" the MP4 file by adding random 512 bytes at the beginning of the file and then renaming the files with a different file extension.
Obviously, the above approach does not perfectly protect his videos from being pirated. He's fine with just enough protection for "non-techies".
Currently, upon playing the video, our Android app extracts the actual video content to a new temporary file by skipping the first 512 bytes. This temp file will be the one played by the VideoView.
The problem is that this takes a long time especially that our videos are more than 100MB+ each. This is clearly not an acceptable solution.
I think, if we can just make the VideoView skip the first 512 bytes, we're all set. Is it possible? If not, what are the better alternatives?
Disclaimer: I'm the web developer of the server app that adds the 512-byte padding. I'm not an Android developer. I'm posting this question on behalf of my Android dev colleague. Forgive me if our approach is totally noob. Feel free to suggest better (and hopefully) easy ways.
android video videoview android-videoview
android video videoview android-videoview
asked Apr 15 '15 at 3:52
dashmugdashmug
6,4341842
6,4341842
I think the proper solution for this is would be a DRM-based approach instead of random padding.
– dashmug
Apr 15 '15 at 7:29
Dashmug, did you get answer for this? We are in same situation..
– user1923551
May 18 '15 at 9:48
@user1923551: No, I didn't find a solution for this. We're still using the workaround.
– dashmug
May 18 '15 at 22:09
add a comment |
I think the proper solution for this is would be a DRM-based approach instead of random padding.
– dashmug
Apr 15 '15 at 7:29
Dashmug, did you get answer for this? We are in same situation..
– user1923551
May 18 '15 at 9:48
@user1923551: No, I didn't find a solution for this. We're still using the workaround.
– dashmug
May 18 '15 at 22:09
I think the proper solution for this is would be a DRM-based approach instead of random padding.
– dashmug
Apr 15 '15 at 7:29
I think the proper solution for this is would be a DRM-based approach instead of random padding.
– dashmug
Apr 15 '15 at 7:29
Dashmug, did you get answer for this? We are in same situation..
– user1923551
May 18 '15 at 9:48
Dashmug, did you get answer for this? We are in same situation..
– user1923551
May 18 '15 at 9:48
@user1923551: No, I didn't find a solution for this. We're still using the workaround.
– dashmug
May 18 '15 at 22:09
@user1923551: No, I didn't find a solution for this. We're still using the workaround.
– dashmug
May 18 '15 at 22:09
add a comment |
2 Answers
2
active
oldest
votes
If by "skipping" you want to jump to a certain point in the video then you can use VideoView#seekTo(int msec)
. However this method simply skips the start over a certain duration into the video.
If what you want is to cut the video at the beginning or do some other modifications then one solution is to pre-process it in a server and stream the result into the app. This way your app won't have to handle the heavy pre-processing and more importantly avoid downloading the whole video file in advance.
We need to skip the first 512 bytes not a specific number of milliseconds soseekto()
doesn't help. We also need to make the videos playable offline so that rules out streaming.
– dashmug
Apr 15 '15 at 4:14
But the problem you posed was "it takes long" especially because the videos are 100MB each. What takes long ? The downloading or your processing ? If downloading then there is no alternative since the videos are to be played offline. If processing then you can still use the server approach to pre-process the video. Remember though that some users will get annoyed having to download large files.
– inmyth
Apr 15 '15 at 4:32
"It takes long" means the removal of the padded bytes. Since the device will have to load the entire video file into memory and then write it as a new temporary file. The server is supposed to add the padding and the client is supposed to remove it upon playback.
– dashmug
Apr 15 '15 at 7:23
add a comment |
Can you get a FileDescriptor
to your file and then pass it into MediaPlayer
's public void setDataSource(FileDescriptor fd, long offset, long length)
method with an offset of 512
?
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
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%2fstackoverflow.com%2fquestions%2f29641289%2fhow-can-i-make-androids-videoview-to-read-padded-file%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
If by "skipping" you want to jump to a certain point in the video then you can use VideoView#seekTo(int msec)
. However this method simply skips the start over a certain duration into the video.
If what you want is to cut the video at the beginning or do some other modifications then one solution is to pre-process it in a server and stream the result into the app. This way your app won't have to handle the heavy pre-processing and more importantly avoid downloading the whole video file in advance.
We need to skip the first 512 bytes not a specific number of milliseconds soseekto()
doesn't help. We also need to make the videos playable offline so that rules out streaming.
– dashmug
Apr 15 '15 at 4:14
But the problem you posed was "it takes long" especially because the videos are 100MB each. What takes long ? The downloading or your processing ? If downloading then there is no alternative since the videos are to be played offline. If processing then you can still use the server approach to pre-process the video. Remember though that some users will get annoyed having to download large files.
– inmyth
Apr 15 '15 at 4:32
"It takes long" means the removal of the padded bytes. Since the device will have to load the entire video file into memory and then write it as a new temporary file. The server is supposed to add the padding and the client is supposed to remove it upon playback.
– dashmug
Apr 15 '15 at 7:23
add a comment |
If by "skipping" you want to jump to a certain point in the video then you can use VideoView#seekTo(int msec)
. However this method simply skips the start over a certain duration into the video.
If what you want is to cut the video at the beginning or do some other modifications then one solution is to pre-process it in a server and stream the result into the app. This way your app won't have to handle the heavy pre-processing and more importantly avoid downloading the whole video file in advance.
We need to skip the first 512 bytes not a specific number of milliseconds soseekto()
doesn't help. We also need to make the videos playable offline so that rules out streaming.
– dashmug
Apr 15 '15 at 4:14
But the problem you posed was "it takes long" especially because the videos are 100MB each. What takes long ? The downloading or your processing ? If downloading then there is no alternative since the videos are to be played offline. If processing then you can still use the server approach to pre-process the video. Remember though that some users will get annoyed having to download large files.
– inmyth
Apr 15 '15 at 4:32
"It takes long" means the removal of the padded bytes. Since the device will have to load the entire video file into memory and then write it as a new temporary file. The server is supposed to add the padding and the client is supposed to remove it upon playback.
– dashmug
Apr 15 '15 at 7:23
add a comment |
If by "skipping" you want to jump to a certain point in the video then you can use VideoView#seekTo(int msec)
. However this method simply skips the start over a certain duration into the video.
If what you want is to cut the video at the beginning or do some other modifications then one solution is to pre-process it in a server and stream the result into the app. This way your app won't have to handle the heavy pre-processing and more importantly avoid downloading the whole video file in advance.
If by "skipping" you want to jump to a certain point in the video then you can use VideoView#seekTo(int msec)
. However this method simply skips the start over a certain duration into the video.
If what you want is to cut the video at the beginning or do some other modifications then one solution is to pre-process it in a server and stream the result into the app. This way your app won't have to handle the heavy pre-processing and more importantly avoid downloading the whole video file in advance.
answered Apr 15 '15 at 4:05
inmythinmyth
6,68633137
6,68633137
We need to skip the first 512 bytes not a specific number of milliseconds soseekto()
doesn't help. We also need to make the videos playable offline so that rules out streaming.
– dashmug
Apr 15 '15 at 4:14
But the problem you posed was "it takes long" especially because the videos are 100MB each. What takes long ? The downloading or your processing ? If downloading then there is no alternative since the videos are to be played offline. If processing then you can still use the server approach to pre-process the video. Remember though that some users will get annoyed having to download large files.
– inmyth
Apr 15 '15 at 4:32
"It takes long" means the removal of the padded bytes. Since the device will have to load the entire video file into memory and then write it as a new temporary file. The server is supposed to add the padding and the client is supposed to remove it upon playback.
– dashmug
Apr 15 '15 at 7:23
add a comment |
We need to skip the first 512 bytes not a specific number of milliseconds soseekto()
doesn't help. We also need to make the videos playable offline so that rules out streaming.
– dashmug
Apr 15 '15 at 4:14
But the problem you posed was "it takes long" especially because the videos are 100MB each. What takes long ? The downloading or your processing ? If downloading then there is no alternative since the videos are to be played offline. If processing then you can still use the server approach to pre-process the video. Remember though that some users will get annoyed having to download large files.
– inmyth
Apr 15 '15 at 4:32
"It takes long" means the removal of the padded bytes. Since the device will have to load the entire video file into memory and then write it as a new temporary file. The server is supposed to add the padding and the client is supposed to remove it upon playback.
– dashmug
Apr 15 '15 at 7:23
We need to skip the first 512 bytes not a specific number of milliseconds so
seekto()
doesn't help. We also need to make the videos playable offline so that rules out streaming.– dashmug
Apr 15 '15 at 4:14
We need to skip the first 512 bytes not a specific number of milliseconds so
seekto()
doesn't help. We also need to make the videos playable offline so that rules out streaming.– dashmug
Apr 15 '15 at 4:14
But the problem you posed was "it takes long" especially because the videos are 100MB each. What takes long ? The downloading or your processing ? If downloading then there is no alternative since the videos are to be played offline. If processing then you can still use the server approach to pre-process the video. Remember though that some users will get annoyed having to download large files.
– inmyth
Apr 15 '15 at 4:32
But the problem you posed was "it takes long" especially because the videos are 100MB each. What takes long ? The downloading or your processing ? If downloading then there is no alternative since the videos are to be played offline. If processing then you can still use the server approach to pre-process the video. Remember though that some users will get annoyed having to download large files.
– inmyth
Apr 15 '15 at 4:32
"It takes long" means the removal of the padded bytes. Since the device will have to load the entire video file into memory and then write it as a new temporary file. The server is supposed to add the padding and the client is supposed to remove it upon playback.
– dashmug
Apr 15 '15 at 7:23
"It takes long" means the removal of the padded bytes. Since the device will have to load the entire video file into memory and then write it as a new temporary file. The server is supposed to add the padding and the client is supposed to remove it upon playback.
– dashmug
Apr 15 '15 at 7:23
add a comment |
Can you get a FileDescriptor
to your file and then pass it into MediaPlayer
's public void setDataSource(FileDescriptor fd, long offset, long length)
method with an offset of 512
?
add a comment |
Can you get a FileDescriptor
to your file and then pass it into MediaPlayer
's public void setDataSource(FileDescriptor fd, long offset, long length)
method with an offset of 512
?
add a comment |
Can you get a FileDescriptor
to your file and then pass it into MediaPlayer
's public void setDataSource(FileDescriptor fd, long offset, long length)
method with an offset of 512
?
Can you get a FileDescriptor
to your file and then pass it into MediaPlayer
's public void setDataSource(FileDescriptor fd, long offset, long length)
method with an offset of 512
?
answered Nov 14 '18 at 18:51
Westy92Westy92
3,2122931
3,2122931
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- 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%2fstackoverflow.com%2fquestions%2f29641289%2fhow-can-i-make-androids-videoview-to-read-padded-file%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
I think the proper solution for this is would be a DRM-based approach instead of random padding.
– dashmug
Apr 15 '15 at 7:29
Dashmug, did you get answer for this? We are in same situation..
– user1923551
May 18 '15 at 9:48
@user1923551: No, I didn't find a solution for this. We're still using the workaround.
– dashmug
May 18 '15 at 22:09