shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
2.01k stars 512 forks source link

Restore support for legacy FairPlay PSSH #1356

Closed Canta closed 9 months ago

Canta commented 9 months ago

System info

Operating System: several GNU/Linux distros Shaka Packager Version: 9be7c2b-release

Issue and steps to reproduce the problem

When packaging HLS with FairPlay using raw key and PSSH, there's no EXT-X-KEY output in the output medialists. This is a continuation issue derived from #1304, where some extra details are available, including a PlayReady (NOT FairPlay) PSSH which actually outputs the EXT-X-KEY tag on the medialists.

Given that some system works but other do not (again, check #1304 for details), I suspect it may be related to the System ID parameter inside the PSSH, triggering different logics for different DRM systems.

It's important to note that this is some kind of regression: the command was working fine for years on previous packager versions. Some recent change must have change something in the medialists code, or even in some DRM code, but I'm not aware where exactly or when.

Packager Command:

packager \
  --segment_duration=6.4 \
  --time_shift_buffer_depth=10 \
  --preserved_segments_outside_live_window=10 \
  --default_language=spa \
  --suggested_presentation_delay=0 \
  --min_buffer_time=12.8 \
  --minimum_update_period=12.8 \
  --io_cache_size=10000000 \
  --mp4_include_pssh_in_stream=false \
  --allow_approximate_segment_timeline \
  --transport_stream_timestamp_offset_ms 250 \
  --segment_template_constant_duration \
  --hls_master_playlist_output=/run/packager/testsignal2/master.m3u8 \
  --hls_playlist_type LIVE \
  --enable_raw_key_encryption \
  --mp4_include_pssh_in_stream=false \
  --keys label=HD:key_id=8a69d922542950b487d9779cec940712:key=00000000000000000000000000000000,label=SD:key_id=a4c4ad4605405a378e4ffac5489b93ae:key=00000000000000000000000000000000,label=AUDIO:key_id=beb28005e90758008f9bc3f17c918ff5:key=00000000000000000000000000000000 \
  --protection_scheme cbcs \
  --pssh 00000054707373680100000029701FE43CC74A348C5BAE90C7439A47000000038A69D922542950B487D9779CEC940712A4C4AD4605405A378E4FFAC5489B93AEBEB28005E90758008F9BC3F17C918FF500000000 \
  --iv 00000000000000000000000000000000 \
  --hls_key_uri skd://redacted_url \
  in=udp://127.0.0.1:20022,stream_selector=0,init_segment=/run/packager/testsignal2/360x240_hls_init.m4s,segment_template=/run/packager/testsignal2/360x240_hls_\$Time%09d\$.m4s,drm_label=SD,playlist_name=360x240.m3u8,bandwidth=5000000 \
  in=udp://127.0.0.1:20022,stream_selector=1,init_segment=/run/packager/testsignal2/audiospa_hls_init.m4s,segment_template=/run/packager/testsignal2/audiospa_hls_\$Time%09d\$.m4s,drm_label=SD,playlist_name=audiospa.m3u8,hls_name=spa,bandwidth=64000,language=spa

Extra steps to reproduce the problem? (1) Create an input source, like this:

ffmpeg -hide_banner -f lavfi -re -i "testsrc=s=360x240:r=30,format=yuv420p" -f lavfi -re -i "anullsrc" -map 0 -c:v h264 -preset ultrafast -strict_gop 1 -g 24 -keyint_min 24 -r 30 -a53cc 1 -map 1 -c:a aac -b:a 64k -ar 48000 -ac 2 -vsync cfr -fflags '+flush_packets +genpts' -avioflags direct -movflags faststart -pcr_period 20 -max_muxing_queue_size 9999 -muxdelay 0 -muxpreload 0 -avoid_negative_ts disabled -f mpegts "udp://127.0.0.1:20022?timeout=8000000&buffer_size=10000000"

(2) After it works, check the output medialist (not masterlist). In the example command, it's /run/packager/testsignal2/360x240.m3u8

What is the expected result? There should be an EXT-X-KEY tag in the resulting medialist, as it was working in previous versions during years.

What happens instead? There's no EXT-X-KEY tag present.

<Please attach the input files or email to shaka-packager-issues@google.com.>

cosmin commented 9 months ago

I believe this is due to this warning message

HLS: Ignore unknown or unsupported system ID: 29701fe43cc74a348c5bae90c7439a47
cosmin commented 9 months ago

This was caused by #1281

It updated the system ID based on https://github.com/Dash-Industry-Forum/Identifiers/issues/119 and https://dashif.org/identifiers/content_protection/

joeyparrish commented 9 months ago

@Canta, can you please update your system ID to Apple's official (since 2017) ID? Just replace 29701fe43cc74a348c5bae90c7439a47 with 94CE86FB07FF4F43ADB893D2FA968CA2 in the PSSH and let us know if that works for you.

joeyparrish commented 9 months ago

I should have read @cosmin's PR #1357 before I commented... @Canta, please confirm that one or the other works for you. Thanks!

cosmin commented 9 months ago

Using the proper system ID will also work, but I think it's important to avoid breaking clients that might have hardcoded the old unofficial system ID.

Canta commented 9 months ago

I'm sorry I wasn't able to test this last days, or even answer to the issue. But I've tested it seconds ago, and can confirm it's all working now. You guys solved it before I had the chance.

About the proper System ID, I'd prefer not to change a working FairPlay setup, as in LATAM we deal with many old devices and pushing newer standards is always very troublesome. So also thank you for honoring the previous System ID.