0

I am not able to figure out how Python ProtoBuf library is related to use pssh python script in this documentation https://github.com/google/shaka-packager/tree/master/packager/tools/pssh

How can I build the pssh.py script without the proto file?

Suhayb
  • 3,163
  • 3
  • 23
  • 30

1 Answers1

1

You can either use the build-script with the shaka-packager, or you can simply generate the python protobuf files from the widevine header proto file directly.

The Protocol Buffers tutorial for python describes nicely how to use protoc to compile the necessary python code.

If you don't want or need any of the other shaka-packager stuff, but just want to use the pssh.py, then you can just modify this part:

# Append the local protobuf location.  Use a path relative to the tools/pssh
# folder where this file should be found.  This allows the file to be executed
# from any directory.
_pssh_dir = os.path.dirname(os.path.realpath(__file__))
sys.path.insert(0, os.path.join(_pssh_dir, '../../third_party/protobuf/python'))
# Import the widevine protobuf.  Use either Release or Debug.
_proto_path_format = os.path.join(
    _pssh_dir, '../../../out/%s/pyproto/packager/media/base')
if os.path.isdir(_proto_path_format % 'Release'):
  sys.path.insert(0, _proto_path_format % 'Release')
else:
  sys.path.insert(0, _proto_path_format % 'Debug')
try:
  import widevine_pssh_data_pb2  # pylint: disable=g-import-not-at-top
except ImportError:
  print >> sys.stderr, 'Cannot find proto file, make sure to build first'
  raise

Just keep import widevine_pssh_data_pb2 and make sure that the code you generated with protoc is in the path of the pssh.py file. Then it should work nicely.

What are you planning to use the pssh.py for?

colde
  • 3,192
  • 1
  • 15
  • 26
  • I am using it to generate pssh-boxes, thank you i will try this – Suhayb Nov 01 '18 at 11:09
  • this is overkill, shaka didnt provide .proto file to compile – Suhayb Nov 01 '18 at 12:02
  • @SuhaybKharabsheh it does provide the .proto file, i linked directly to it: https://github.com/google/shaka-packager/blob/master/packager/media/base/widevine_pssh_data.proto Note that PSSH boxes are different for each DRM system, and PlayReady for instance uses a completely different format. – colde Nov 01 '18 at 14:30
  • sorry for not paying attention to your words, works like a charm, from where should I get pssh for fairPlay? – Suhayb Nov 01 '18 at 14:58
  • @SuhaybKharabsheh Microsoft have extensive documentation on it here: https://learn.microsoft.com/en-us/playready/specifications/mpeg-dash-playready or you can look at how the excellent Bento4 tools handle it: https://github.com/axiomatic-systems/Bento4/blob/master/Source/Python/utils/mp4-dash.py#L265 – colde Nov 02 '18 at 09:23
  • bento4 looks good option but seems to not support fairplay?, I am currently sicked to Shaka packager. – Suhayb Nov 02 '18 at 12:59
  • 1
    @SuhaybKharabsheh FairPlay doesn't support DASH. So there are no PSSH boxes anyway. But Bento4 actually does support it for HLS: https://www.bento4.com/developers/hls/ – colde Nov 02 '18 at 18:30