FWM CLI Packager Guide

PallyCon FWM CLI Packager is a command line interface (CLI) tool for watermark preprocessing and DRM packaging on an encoded video file.

It runs on an on-premise or cloud packaging server built by the content service, and processes the source mp4 video into watermark-preprocessed outputs (0/1 versions, also known as A/B variants).

sequenceDiagram
    participant A as Encoder
    participant B as Packaging server
    participant C as CDN
    A ->> B: Encoded MP4
    Note right of B: FwmPreprocessor
    B -->> B: Watermark Preprocessing
    opt Multi DRM 
    Note right of B: PallyConPackager
    B -->> B: Content packaging and encryption
    end
    Note right of B: ABComposer
    B -->> B: Re-structure filename and directory
    B ->> C: Packaged streams
    Note right of C: DASH / HLS contents<br>(0 and 1 marked)

Modules

You may contact PallyCon team to get the FWM CLI Packager after subscribing to PallyCon Forensic Watermarking plan. It contains the below files.

  • FwmPreprocessor: Creates two video files, each marked ‘0’ or ‘1’. For example, when the input content is ‘A.mp4’, it creates ‘A_0.mp4’ and ‘A_1.mp4’. Each of the two generated content can be packaged as DASH / HLS streaming content using PallyCon CLI Packager.

  • fmkeyDemo.dat: This is a demo version key file used for watermark preprocessing in a trial account. In addition to the invisible forensic watermark, a visible watermark (`PALLYCON DEMO') will be added in the video preprocessed with the demo key.

  • PallyConPackager: CLI-based DRM packager that can produce DRM-encrypted DASH/HLS content with the preprocessed 0/1 version mp4 video.

  • ABComposer: Restructures the packaged files for watermark embedding via CDN integration.

  • FwmCliPackager.py: A Python script that calls the above modules in a single command.

  • Library files: In the lib folder, there are various libraries used in the FwmPreprocessor.

Required environments

You need the following environment to run the FWM CLI Packager.

Hardware

AWS GPU instance performance

  • Geforce GTX1050 (Desktop, Pascal) « P2 (Tesla K80) « P3 (Tesla V100), G3 (Tesla M60)
  • When using an AWS EC2 instance as a watermark preprocessing server, we recommend an instance of type P3 or G3 for GPU acceleration.

Software

  • Ubuntu server 18.04, 20.04 or CentOS 7
  • Intel IPP (Integrated Performance Primitives) 2018: Included in the distribution.
  • NVIDIA CUDA Toolkit 9.1 or later (NVIDIA hardware acceleration)
  • Dependency libraries
  • Python 3.7 or later
FWM CLI packager is built into different binaries for each supported Linux distribution and version. (Example: If the delivered archive file name is pallycon-fwm-cli-packager-v1.0-ubuntu1804, only Ubuntu 18.04 is supported) When requesting the product to PallyCon team, you need to inform the OS name and version you want to use. For environments other than the supported OS specified above, additional development would be required or the support may not be possible.

Installation guide

NVIDIA CUDA Toolkit 10.0

Pallycon FWM CLI Packager supports NVIDIA H/W encoding/decoding. You can check supported GPUs and codecs here.

It supports CUDA Toolkit 9.1, but 10.0 or higher is recommended. You can also install the latest version if there are no compatibility issues with your other programs. If you need to install other CUDA Toolkit version, please refer latest downlaod or archive.

  • Installing on Ubuntu 18.04

    $ distribution=$(. /etc/os-release;echo $ID$VERSION_ID|tr -d '.')
    $ wget https://developer.download.nvidia.com/compute/cuda/repos/${distribution}/x86_64/cuda-repo-${distribution}_10.0.130-1_amd64.deb
    $ sudo dpkg -i cuda-repo-${distribution}_10.0.130-1_amd64.deb
    $ sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/${distribution}/x86_64/7fa2af80.pub
    $ sudo apt-get update
    $ sudo apt-get install -y linux-headers-$(uname -r)
    $ sudo apt-get install -y cuda-10-0
    $ rm cuda-repo-${distribution}_10.0.130-1_amd64.deb
    $ sudo reboot
    
  • Installing on CentOS 7

    $ sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
    $ wget https://developer.download.nvidia.com/compute/cuda/repos/rhel7/x86_64/cuda-repo-rhel7-10.0.130-1.x86_64.rpm
    $ sudo rpm -i cuda-repo-rhel7-10.0.130-1.x86_64.rpm
    $ sudo yum clean all
    $ sudo yum install kernel-devel-$(uname -r) kernel-headers-$(uname -r)
    $ sudo yum install cuda-10-0
    $ rm cuda-repo-rhel7-10.0.130-1.x86_64.rpm
    $ sudo reboot
    
  • Installing on AWS Linux2

    • Please refer to this link
  • Verification

    $ nvidia-smi
    
  • References

Install Dependencies

  • Ubuntu 18.04 version

    $ sudo apt update
    $ sudo apt install -y \
            libva-drm2 \
            libvdpau1 \
            libmediainfo0v5 \
            libpng16-16
    
  • Ubuntu 20.04 version

    $ sudo apt update
    $ sudo apt install -y \
            libnuma1 \
            libva-drm2 \
            libvdpau1 \
            libmediainfo0v5 \
            libpng16-16
    
  • CentOS 7 version

    $ sudo yum update
    $ sudo yum install -y \
            openssl-devel \
            libpng-devel \
            libmediainfo-devel
    

FWM CLI Packager usage

Execute the FwmCliPackager.py file in the bin folder of the downloaded archive with the following command.

$ python3 FwmCliPackager.py -i INPUT_FILE -o OUTPUT_DIR [optional parameters]
If an error occurs that is related to the common library path, you must set LD_LIBRARY_PATH in the PATH environment variable. For details, refer to the FwmPreprocessor.sh file included in the archive file.

FwmCliPackager parameters

Parameter Description Example Remarks
-i Inputs filepath of source video -i ~/fwm/input.mp4 Required. You can input multiple source videos with different bitrate for ABR content.
-o Sets a path where output files will be stored -o ~/fwm/output Required. In DEMO mode(--demo), _demo will be added to the directory name.
--fmkey_file Instead of the trial seed key (fmkeyDemo.dat) included in the distribution, set the commercial seed key file delivered separately. --fmkey_file fmkey.dat Can be omitted during FWM trial or when a commercial seed key file (fmkey.dat) is saved in the same directory as FwmPreprocessor.
--access_key Access Key for service authorization --access_key QSTO...2zE7 Enter the access key value displayed in the integration settings of the PallyCon console site. Required for FWM commercial plan or DRM encryption.
--preprocessing_only Skips DASH/HLS content packaging Used when packaging with a separate third-party packager instead of the included CLI Packager
--demo Enables demo mode (FWM trial) Required until commercial subscription of forensic watermarking
--keep Does not remove the intermediate files of preprocessing and packaging
-y If there are intermediate files that has not been deleted, the files are overwritten without being used. If this parameter is omitted, it asks whether to overwrite or reuse the files
-h, -v Shows help or version info of FWMCliPackager
CLI Packager parameters Options for DASH/HLS packaging and DRM encryption --site_id SITE --content_id CID --dash --hls See below for details
When processing DASH/HLS packaging and DRM encryption using FWM CLI packager, input the parameters of PallyCon multi-DRM CLI packager as additional parameters of FwmCliPackager.py script. All parameters specified in the CLI Packager guide can be used, and the --access_key parameter and its value are used in both the FWM preprocessor and CLI packager.

Example commands

Watermark preprocessing + Non-DRM DASH/HLS packaging

The command below produces non-DRM DASH, HLS output with demo (trial) watermark preprocessing applied.

$ python3 FwmCliPackager.py -i ~/fwm/input.mp4 -o ~/fwm/output --demo --dash --hls --disable_encryption

If you are using a commercial forensic watermarking service, enter it without the --demo parameter. (If the commercial seed key fmkey.dat file is stored in the same directory as the executable file)

Watermark preprocessing + DRM packaging

The command below generates DASH and HLS output with commercial version watermark preprocessing and DRM packaging applied. (When manually specifying the commercial key file path)

$ python3 FwmCliPackager.py -i ~/fwm/input.mp4 -o ~/fwm/output --fmkey_file ~/fwm/fmkey.dat --access_key YOUR_ACCESS_KEY --dash --hls --site_id YOUR_SITE_ID --content_id UNIQUE_CONTENT_ID

In the case of ABR (Adaptive Bitrate) content, input original files with different resolutions and bitrates with the -i parameter as shown below.

$ python3 FwmCliPackager.py -i ~/fwm/input_hd.mp4 ~/fwm/input_sd.mp4 -o ~/fwm/output-abr --fmkey_file ~/fwm/fmkey.dat --access_key YOUR_ACCESS_KEY --dash --hls --site_id YOUR_SITE_ID --content_id UNIQUE_CONTENT_ID

Watermark preprocessing only

If you want to package commercially preprocessed A/B version videos using a third-party solution, run the following command. In the resulting directory, two mp4 files with _0 and _1 added after the original file name are created.

$ python3 FwmCliPackager.py -i ~/fwm/input.mp4 -o ~/fwm/output --access_key YOUR_ACCESS_KEY --preprocessing_only

Watermark preprocessing + DRM packaging with external key

When performing commercial watermarking preprocessing and external key input DRM packaging, run the following command.

$ python3 FwmCliPackager.py -i ~/fwm/input.mp4 -o ~/fwm/output --access_key YOUR_ACCESS_KEY --dash --hls --content_id UNIQUE_CONTENT_ID --enable_raw_key_encryption --keys label=:key_id=16BYTE_HEX_STRING:key=16BYTE_HEX_STRING
In addition to external key input, various PallyCon CLI Packager options can be applied by inputting them as the FwmCliPackager.py script’s parameters. For details, refer to the corresponding guide.

Packaging option for CDN integration

A/B watermark contents packaged in DASH or HLS format by FWM CLI packager are mixed in real time and delivered to users through watermark embedding integration at CDN edge. Basically, FWM CLI packager adds a separate label to the B version file name among A/B version segment files. (‘Unlabeled A variant’ method) It can be integrated with Akamai CDN or Amazon CloudFront with PallyCon FWM Lambda@Edge Embedder (v2.3 or later) applied.

If you want to integrate with CloudFront to which Lambda@Edge Embedder prior to v2.2.2 has been applied, you must modify the cdnpack_option item defined in the FwmCliPackager class of the FwmCliPackager.py script as follows before executing it. (Creates two sets of content into separate 0/1 directories)

self.cdnpack_option = {"type": "aws"}
Next