FWM Preprocessor SDK Guide

Overview

PallyCon FWM Preprocessor SDK is a C ++ library that can be ported to an encoding solution. By preprocessing watermark directly in the video encoding process, you can omit the re-encoding process required for CLI Preprocessor.

graph LR;
    subgraph Encoder
    A[Source video] -->|Frame image| B(Preprocessor library)
    B -->|Two set of frame<br>with 0, 1 marked| C["Encoded result<br>(two MP4 videos)"]
    end
    C --> D(DASH or<br>HLS packaging)
    subgraph Packager
    D --> E["Packaging result<br>(two set of streaming content)"]
    end

By default, porting to FFMPEG-based encoder/transcoder is supported. To apply Preprocessor library to other commercial solutions, it is required to port the library by the solution vendor. Please contact us if you need more information or want to apply the library.

Contact Us

Requirements

  • OS: Ubuntu 18.04, 20.04 or CentOS 7
  • Programming language: C++11
  • FFMPEG 3.4.2 or later (to build sample application)

Preprecessor API

- PallyConForensicWatermark* CreatePallyConForensicWatermark()
  : @return watermark pre-processor instance

- void DestroyPallyConWatermark(PallyConForensicWatermark* watermark)
  : destroy watermark instance

- FMError PallyConForensicWatermark::Init(const char* fwmkeyfile, const char* accesskey)
  : initialize watermark with Keyfile and Access-Key
  : @return FMError defined in FMError.h

- bool PallyConForensicWatermark::Apply(FrameData* frame0, FrameData* frame1)
  : apply watermark
  : @return bool

API Usage

  wm = CreatePallyConForensicWatermark() [1]
   |
   v
  wm->Init("./fwmkeyfile.dat", "FOR_INKA_FORENSIC_WATERMARK_TEST") [2]
  or
  wm->Init(base64(Keyfile), "FOR_INKA_FORENSIC_WATERMARK_TEST")
   |
   v
+----------- loop [3] -----------+
| FrameData frame0               |
| FrameData frame1               |
|  |                             |
|  v                             |
| wm->Apply(&frame0, &frame1)    |
+--------------------------------+
   |
   v
  DestroyPallyConWatermark(wm) [4]
   |
   v
  XXXX_0.mp4, XXXX_1.mp4
  1. Create watermark instance

    • Create a watermark instance to preprocess the 0/1 file.
    • Refer to FwmPreprocessSample.cpp::fm_init_watermark()
  2. Initialize the instance and authorize it

    • To use the SDK, you must initialize and authorize instance using Keyfile and Access-Key.
    • The distribution package includes a Keyfile and Access-Key for demonstration. If you use the demo values, Pallycon Demo string appears at the top left of the result video. Please contact our Helpdesk to get a commercial key.
    • Refer to FwmPreprocessSample.cpp::fm_init_watermark()
  3. Apply watermark

    • The SDK uses its own data structures, FrameData, to handle video frame data. Fill the FrameData variables and use them to apply watermark.
    • Refer to FwmPreprocessSample.cpp::fm_apply(), PallyConWatermark.h
  4. Destroy watermark instance

    • After the watermark operation is finished, the instance must be destroyed.
    • Refer to FwmPreprocessSample.cpp::finalize()

Restrictions

According to Pallycon Watermark specification, GOP should be set to 60 when encoding. The method of setting GOP is different for each encoder, and the contents below apply to the case of using FFMPEG’s libx264.

  • FwmPreprocessSample.cpp::openOutputFile(), enc_ctx->gop_size
  • FwmPreprocessSample.cpp::checkAndUpdateParam(), pCtx->x264_param

For instructions on the libx265/nvenc codec, please refer to the comments of the sample source.

Sample application

We provide a simple demo source code, key file, and access key to test the SDK using the FFmpeg library.

Sample build

For Ubuntu 18.04, you can build the sample application as follows:

  1. Install FFmpeg libraries. You can skip it if FFmpeg is already configured on the system.
$ sudo apt install -y \
       build-essential \
       libavformat-dev libavcodec-dev libavutil-dev
  1. On line 5 of the Makefile, set 'YOUR_FFMPEG_PATH' to the FFmpeg libraries path. It will be /usr/lib/x86_64-linux-gnu in most cases.
  • For Ubuntu 18.04, 20.04
    YOUR_FFMPEG_PATH = /usr/lib/x86_64-linux-gnu
    
  • For CentOS 7
    //Line no. 5 in Makefile
    YOUR_FFMPEG_PATH = /usr
    
    // Line no. 19
    CXXFLAGS += -I$(YOUR_FFMPEG_PATH)/include/ffmpeg/
    

Running the sample

Run the following command through the built sample executable. The demo key file is named demokey.dat and is distributed with the SDK. The demo access key is the fixed string FOR_INKA_FORENSIC_WATERMARK_TEST.

$ LD_LIBRARY_PATH=./lib ./FwmPreprocessSample your_own_input.mp4 your_own_output.mp4 demokey.dat FOR_INKA_FORENSIC_WATERMARK_TEST
Previous
Next