Skip to content
New issue

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

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

Already on GitHub? # to your account

Encryption of H265 fails with Failed to read slice header #627

Closed
johnpletka opened this issue Jul 26, 2019 · 13 comments
Closed

Encryption of H265 fails with Failed to read slice header #627

johnpletka opened this issue Jul 26, 2019 · 13 comments
Labels
status: archived Archived and locked; will not be updated status: duplicate A duplicate of another issue; should be closed after linking to the original issue type: bug Something isn't working correctly

Comments

@johnpletka
Copy link

System info

Operating System: Linux Mint 18.1 Serena
Shaka Packager Version: v2.3.0-5bf8ad5-release (also master branch from 20190726)

Issue and steps to reproduce the problem

Packager Command:
$PACKAGER
in="$VIDEO_FILE,stream=video,init_segment=encrypted_content/video_init.mp4,segment_template=encrypted_content/video$Number$.m4s"
in="$AUDIO_FILE,stream=audio,init_segment=encrypted_content/audio_init.mp4,segment_template=encrypted_content/audio$Number$.m4s"
--enable_widevine_encryption
--key_server_url "$PROD_KEY_URL"
--content_id "$CONTENT_ID"
--signer "$PROVIDER"
--aes_signing_key "$PROD_SIGNING_KEY"
--aes_signing_iv "$PROD_SIGNING_IV"
--generate_static_mpd
--segment_duration '30'
--mpd_output encrypted_content/h265.mpd

Extra steps to reproduce the problem?
If I leave off the encryption parameters from the packager command (i.e. just segment and make an mpd_output), then it works fine.
The source file is being produced by AWS Media Convert with the following settings:
"VideoDescription": {
"Width": 2048,
"ScalingBehavior": "DEFAULT",
"Height": 858,
"TimecodeInsertion": "DISABLED",
"AntiAlias": "ENABLED",
"Sharpness": 50,
"CodecSettings": {
"Codec": "H_265",
"H265Settings": {
"InterlaceMode": "PROGRESSIVE",
"NumberReferenceFrames": 2,
"GopClosedCadence": 1,
"AlternateTransferFunctionSei": "DISABLED",
"GopSize": 48,
"Slices": 1,
"GopBReference": "DISABLED",
"SlowPal": "DISABLED",
"SpatialAdaptiveQuantization": "ENABLED",
"TemporalAdaptiveQuantization": "ENABLED",
"FlickerAdaptiveQuantization": "DISABLED",
"Bitrate": 16000000,
"FramerateControl": "INITIALIZE_FROM_SOURCE",
"RateControlMode": "CBR",
"CodecProfile": "MAIN_MAIN",
"Tiles": "ENABLED",
"Telecine": "NONE",
"MinIInterval": 0,
"AdaptiveQuantization": "HIGH",
"CodecLevel": "AUTO",
"SceneChangeDetect": "ENABLED",
"QualityTuningLevel": "SINGLE_PASS_HQ",
"FramerateConversionAlgorithm": "DUPLICATE_DROP",
"UnregisteredSeiTimecode": "DISABLED",
"GopSizeUnits": "FRAMES",
"ParControl": "INITIALIZE_FROM_SOURCE",
"NumberBFramesBetweenReferenceFrames": 2,
"TemporalIds": "DISABLED",
"SampleAdaptiveOffsetFilterMode": "ADAPTIVE",
"WriteMp4PackagingType": "HEV1",
"DynamicSubGop": "STATIC"
}
},
"AfdSignaling": "NONE",
"DropFrameTimecode": "ENABLED",
"RespondToAfd": "NONE",
"ColorMetadata": "INSERT"
},
"NameModifier": "_video"
}

What is the expected result?
It creates a encrypted_content directory with a h265.mpd file, video_init.mp4, audio_init.mp4 and the video chunked into 30 second segments and encrypted

What happens instead?
~/bin/package_encrypt_latest.sh charlie ANFC_video_120s.mp4 ANFC_audio_120s.mp4
CONTENT_NAME = charlie ID = 636861726c6965
VIDEO_FILE = ANFC_video_120s.mp4
AUDIO_FILE = ANFC_audio_120s.mp4
PROD_KEY_URL = https://license.widevine.com/cenc/getcontentkey/nagramycinema
[0726/140626:INFO:demuxer.cc(88)] Demuxer::Run() on file 'ANFC_audio_120s.mp4'.
[0726/140626:INFO:demuxer.cc(160)] Initialize Demuxer for file 'ANFC_audio_120s.mp4'.
[0726/140626:INFO:demuxer.cc(88)] Demuxer::Run() on file 'ANFC_video_120s.mp4'.
[0726/140626:INFO:demuxer.cc(160)] Initialize Demuxer for file 'ANFC_video_120s.mp4'.
[0726/140626:WARNING:track_run_iterator.cc(699)] Seeing non-zero composition offset 3750. An EditList is probably missing.
[0726/140626:WARNING:track_run_iterator.cc(703)] Adjusting timestamps by -3750. Please file a bug to https://github.com/google/shaka-packager/issues if you do not think it is right or if you are seeing any problems.
[0726/140626:ERROR:subsample_generator.cc(319)] Failed to read slice header.
[0726/140626:ERROR:demuxer.cc(327)] Failed to process sample 256 9 (ENCRYPTION_FAILURE): Failed to read slice header.
[0726/140626:ERROR:mp4_media_parser.cc(793)] Failed to process the sample.
[0726/140626:ERROR:packager_main.cc(530)] Packaging Error: 8 (PARSER_FAILURE): Cannot parse media file ANFC_video_120s.mp4

@kqyang
Copy link
Contributor

kqyang commented Jul 26, 2019

Can you share your input files with us? You may email it to shaka-packager-issues@google.com if it cannot be shared publicly.

@kqyang kqyang added the status: waiting on response Waiting on a response from the reporter(s) of the issue label Jul 26, 2019
@johnpletka
Copy link
Author

The files were sent via email. Let me know if you have any issues receiving them.

@kqyang
Copy link
Contributor

kqyang commented Jul 31, 2019

@johnpletka Received. Thanks. Will take a look soon.

@kqyang kqyang added needs triage and removed status: waiting on response Waiting on a response from the reporter(s) of the issue labels Jul 31, 2019
@markitodelacruz
Copy link

Hi there. I have the exact same issue here.... using an h265 generated video from aws media convert.
Any solution coming soon?

@kqyang
Copy link
Contributor

kqyang commented Aug 2, 2019

@johnpletka @markitodelacruz It is the same problem as #621, but for H265, i.e. the parameter sets, e.g. SPS, PPS, are not present in the header (sample description box). A fixed will be pushed soon. Please follow the update on #621.

@kqyang kqyang closed this as completed Aug 2, 2019
@kqyang kqyang added type: bug Something isn't working correctly status: duplicate A duplicate of another issue; should be closed after linking to the original issue and removed needs triage labels Aug 2, 2019
@markitodelacruz
Copy link

@kqyang thanks for the update. Quick question... is this issue related to this specific Shaka packager version only? is there any other version where this process works that we could use in the meantime?
thanks

shaka-bot pushed a commit that referenced this issue Aug 5, 2019
- Parses parameter set NAL units in the samples.
- Calculate pixel width and height from track width and height.

Fixes #621, #627.

Change-Id: Ic1e120dccbd220b01168f7bf4effeaa43f95b055
@kqyang
Copy link
Contributor

kqyang commented Aug 5, 2019

@markitodelacruz It is a new problem. I have just pushed the fix this morning. Let us know if it does not work for you.

@markitodelacruz
Copy link

thank you @kqyang
where can I find this new version?

@kqyang
Copy link
Contributor

kqyang commented Aug 5, 2019

@markitodelacruz You can build it yourself. See building instructions here: https://google.github.io/shaka-packager/html/build_instructions.html.

You may also be able to find it in our build bots: https://travis-ci.org/google/shaka-packager, https://ci.appveyor.com/project/shaka/shaka-packager.

If you don't mind waiting, we should have a new release this month.

@johnpletka
Copy link
Author

I can confirm that this is fixed for my H265 AWS transcode. Thanks for the quick response!

@kqyang
Copy link
Contributor

kqyang commented Aug 6, 2019

@johnpletka Thanks for the verification!

@markitodelacruz You may also use Docker: https://google.github.io/shaka-packager/html/docker_instructions.html if you don't want to build it by yourself.

@markitodelacruz
Copy link

thank you @kqyang
I tested using docker and I can confirm that this works great!
Thank you so much for the quick response and guidance.

@kqyang
Copy link
Contributor

kqyang commented Aug 6, 2019

@markitodelacruz Glad to hear that! Enjoy.

@shaka-bot shaka-bot added the status: archived Archived and locked; will not be updated label Oct 1, 2019
@shaka-project shaka-project locked and limited conversation to collaborators Oct 1, 2019
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
status: archived Archived and locked; will not be updated status: duplicate A duplicate of another issue; should be closed after linking to the original issue type: bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

4 participants