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

Can i play encrypted .mp4 files generated by ffmpeg ? #2139

Closed
abdullahoday710 opened this issue Sep 9, 2019 · 5 comments
Closed

Can i play encrypted .mp4 files generated by ffmpeg ? #2139

abdullahoday710 opened this issue Sep 9, 2019 · 5 comments
Assignees
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Milestone

Comments

@abdullahoday710
Copy link

i use this command to encrypt my video ffmpeg -i SampleVideo_1280x720_1mb.mp4 -vcodec copy -acodec copy -encryption_scheme cenc-aes-ctr -encryption_key 76a6c65c5ea762046bd749a2e632ccbb -encryption_kid a7e61c373e219033c21091fa607bf3b8 SampleVideo_1280x720_1mb_encrypted.mp4

can i play the output file in shaka player ? if so can you please provide examples or links to docs ?

@abdullahoday710 abdullahoday710 added the type: question A question from the community label Sep 9, 2019
@joeyparrish
Copy link
Member

If it's encrypted with cenc encryption (AES-128 CTR mode following Common Encryption spec), then you can decrypt it with ClearKey without the need for a license server. See https://shaka-player-demo.appspot.com/docs/api/tutorial-drm-config.html

If you want to do actual DRM and hide the keys from the end user, then you'll need to contact Widevine/Microsoft/Apple about running a Widevine/PlayReady/FairPlay license server.

Does this answer your question?

@abdullahoday710
Copy link
Author

If it's encrypted with cenc encryption (AES-128 CTR mode following Common Encryption spec), then you can decrypt it with ClearKey without the need for a license server. See https://shaka-player-demo.appspot.com/docs/api/tutorial-drm-config.html

If you want to do actual DRM and hide the keys from the end user, then you'll need to contact Widevine/Microsoft/Apple about running a Widevine/PlayReady/FairPlay license server.

Does this answer your question?

Hi , thank you for your quick response , yes i don't need a license server and i have tried the drm configuration. when i try to play my video i get the following error message PIPELINE_ERROR_DECODE: Failed to send audio packet for decoding: timestamp=0 duration=23220 size=185 side_data_size=0 is_key_frame=1 encrypted=0 discard_padding (us)=(0, 0)

@joeyparrish
Copy link
Member

I was able to reproduce your results with ffmpeg 4.1.3. I tried re-encoding audio & video, I tried audio-only, I tried video-only, and I tried with flags to output fragmented mp4.

I got it to work with Shaka Packager for encryption, and playing back through a DASH manifest:

packager \
  input=SampleVideo_1280x720_1mb.mp4,stream=video,output=video.mp4 \
  input=SampleVideo_1280x720_1mb.mp4,stream=audio,output=audio.mp4 \
  --enable_raw_key_encryption \
  --keys key_id=a7e61c373e219033c21091fa607bf3b8:key=76a6c65c5ea762046bd749a2e632ccbb \
  --clear_lead 0 \
  --mpd_output dash.mpd

This plays through DASH & MediaSource w/ ClearKey for decryption, but if I try to play back one of the individual files (video.mp4 or audio.mp4) with src=, playback seems to fail. I'm not sure why yet. When this fails, video.mediaKeys is null, so I think that Shaka's DrmEngine doesn't set up ClearKey with src= for some reason. It could be a lack of PSSH box in the mp4s.

@joeyparrish joeyparrish added type: bug Something isn't working correctly and removed type: question A question from the community labels Sep 9, 2019
@joeyparrish
Copy link
Member

I've found that there is a bug in DrmEngine which suppresses errors for src= content with ClearKey. With that fixed, I then see that ClearKey setup fails with src= due to a lack of codec information on the content. If I hack in some hard-coded codec info, I then get garbled playback.

The same exact files work correctly through MediaSource.

So, even with bugs fixed in Shaka Player, it appears you won't be able to play back encrypted content in Chrome without using MediaSource. We'll fix what bugs we can, but I would advise you to pursue DASH or HLS encrypted content instead of plain mp4.

@shaka-bot shaka-bot added this to the v2.6 milestone Sep 9, 2019
@joeyparrish
Copy link
Member

We've fixed the bug that suppressed an EME failure for ClearKey content with src= playback. But the other issues still stand, and point to the conclusion that you will need to use MediaSource to be able to play back encrypted content, and that with Shaka Player, that would mean DASH or HLS. If you choose to use MediaSource directly instead of Shaka Player, you may still be able to play this encrypted content without DASH or HLS.

I hope the information is helpful. Let us know if we can do anything else for you.

TheModMaker pushed a commit that referenced this issue Nov 6, 2019
Because src= content lacks codec information, ClearKey setup fails.
However, because there was no DrmInfo prior to the ClearKey settings
being applied, the variable hadDrmInfo was false, which led to a
suppression of the resulting DRM error.

Instead, we should count ClearKey settings toward hadDrmInfo.  So now,
ClearKey settings are applied before we calculate hadDrmInfo.

Closes #2139

Change-Id: I14d5bfe63fd2ce1a461ae7ef8c2fee7f42bb1b3e
@shaka-project shaka-project locked and limited conversation to collaborators Nov 11, 2019
@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Apr 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
status: archived Archived and locked; will not be updated type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

3 participants