DSRCorporation / imf-conversion

NF IMF media conversion utility allows to handle flat file creation from a specified CPL within the IMF package
GNU General Public License v3.0
62 stars 6 forks source link

IMF Conversion Utility

Contents

Build

The project can be built very easily by using the included Gradle wrapper. Having downloaded the sources, simply invoke the following commands inside the folder containing the sources:

$ ./gradlew clean
$ ./gradlew build

JDK requirements

Distribution

After the project is built, the distribution is created in the 'build' folder of the root project

./build/imf-conversion-utility-{version}.tar
./build/imf-conversion-utility-{version}.zip

as well as in

./imf-conversion-main/build/distributions

The distribution includes

  1. All necessary .jar files in the lib folder (lib/imf-conversion-utility-{version}.jar contains the Main Class).
  2. Start scripts in the bin folder.
  3. Default tools used by the utility in the tools folder.
  4. Sample config.xml in samples folder.
  5. License.
  6. README
  7. Sample metadata.xml and audiomap.xml in samples folder.

Usage

Conversion to DPP format

  1. [Done Once] Prepare external tools used for conversion.
  2. [Done Once; edit when needed] Prepare config.xml.
  3. Run Utility with appropriate command line arguments to generate metadata.xml to enter DPP metadata values.
    • dpp
    • --mode [-m] metadata
    • --output [-o] metadata.xml
  4. Enter required DPP metadata values manually (DPP_MMS_TechMetadata).
  5. [Optional] Run Utility with appropriate command line arguments to generate audiomap.xml to map input audio tracks and channels to the output ones depending on the AudioTrackLayout parameter set in metadata.xml.
    • dpp
    • --mode [-m] audiomap
    • --output [-o] audiomap.xml
  6. [Optional] Edit audiomap.xml to map input audio streams and channels.
  7. Run conversion job:
    • dpp
    • --mode [-m] convert (may be omitted as it's a default mode)
    • --config [-c] config.xml
    • --metadata metadata.xml
    • --audiomap audiomap.xml (optional)
    • --imp path-to-imp-folder (optional: can be set in config.xml)
    • --cpl CPL.xml (optional: can be set in config.xml)
    • --working-dir [-w] path-to-output-folder (optional: can be set in config.xml)
    • -- output [-o] the output .mxf file name (as well as .stl file name) without extension (optional: if not set, 'output' default name will be used).
  8. An output flat file is created under the specified output directory (-w) and is called output.mxf.
  9. Logs:
    • The current conversion job log file: /logs/imf-utility.log.
    • Previous conversion jobs log files: /logs/archive.
    • External tools log files: {output-dir}/logs.
  10. Validation

Note 1:

Prepare external tools used for conversion

  1. Get FFMPEG FFMPEG

  2. Get x264 Encoder x264. 10-bit version must be used!

  3. Get BMX: bmx2raw and raw2bmx applications from tools directory. tools/bmx directory contains proper BMX tools snapshots because latest BMX tools include MCA implementation and if we have incorect MXF audio file (without MCA label id property) mxf2raw exits with exception and does not extract audio data.

  4. Get ASDCP tool. Please build it from https://github.com/DSRCorporation/asdcplib-as02 repository. This is a fork from from http://www.cinecert.com/asdcplib/ which is enhanced to work properly with TTML wrapped in MXF. There is a Windows distribution there which can be used out of the box on Windows (TBD).

Prepare config.xml

  1. A sample config.xml can be found in the /samples folder.

  2. Required External Tools

    • Specify external tools to be used.
    • If an executable is added to the PATH, then a short name can be used. Otherwise enter a full absolute path.
      <externalTools>
          <tool id="ffmpeg">ffmpeg</tool>
          <tool id="ffprobe">ffprobe</tool>
          <tool id="bmx">raw2bmx</tool>
          <tool id="mxf2raw">mxf2raw</tool>
          <tool id="x264">x264-10bit</tool>
          <tool id="asdcp-unwrap">as-02-unwrap</tool>
      </externalTools>
  3. Optional External Tools

    • There is a number of external tools which are distributed with the utility and used by default (no user settings required)
      • IMF validation (/imf-validation project which as a wrapper on Photon tool (Photon)).
      • TTML to EBU STL captions converter (/ttml-to-stl).
    • However, it's possible to use another external tools for these tasks.
    • If another tools are used, then either they should expect the same input and output as the default tools, or the code should be modified to support the new tools.
    • To specify custom IMF validation and TTML to STL conversion tools, add the following to the config.xml:
      <externalTools>
          ...
          <tool id="ttml-to-stl">ttmlToStl path</tool>
          <tool id="imf-validation">imf validation path</tool>
      </externalTools>
  4. IMF package and CPL

    • The input IMF package and CPL can be specified either in config.xml or as a command line argument.
    • If it's specified in both places, then values from command line parameters will be used.
    • Including IMF package and CPL into config.xml can be used to reduce the number of command line arguments when using the same IMP and CPL for different conversions.
    • To set IMF package and CPL in config.xml, add the following:
      <imp>path to imp</imp>
      <cpl>path of CPL.xml</cpl>
    • Please note that the CPL can be specified either as a path to CPL.xml or as a name of CPL.xml within IMP folder (an IMF package may contain several CPLs, so we should select the one to be used for conversion).
  5. Output directory

    • The output directory is a folder where the output flat file (output.mxf) will be created.
    • The output directory also contains tmp files created during conversion as well as logs of all external tools.
    • It can be controlled via config.xml whether to clear the output directory at the beginning of conversion job, and whether to delete all tmp files at the end of the job.
    • The output directory can be specified either in config.xml or as a command line argument.
    • If it's specified in both places, then values from command line parameters will be used.
    • To set the output directory in config.xml, add the following:
      <workingDirectory>path to output directory</workingDirectory>
  6. Allows/disallows silent conversion

    • Input audio/video parameters may not match the required output ones (for example, input fps is 30, but the output must be 25).
    • The user can control conversion of a parameter to the required value.
    • By default, all conversions are allowed, and no special settings are needed.
    • To allow/disallow conversion, do the following for each parameter to be controlled:
      <conversionParameters>
          <param name="bitDepth">yes</param>
          <param name="frameRate">no</param>
          <param name="size">yes</param>
          <param name="pixelFormat">yes</param>
          <param name="bitsSample">yes</param>
          <param name="sampleRate">no</param>
      </conversionParameters>
    • If the parameter is not specified, then conversion is allowed.
  7. Clear Output directory

    • It can be controlled via config.xml whether to
      • clear the output directory at the beginning of conversion job
        • false by default
        • be careful with setting it to true to not delete important files!
      • delete all tmp files at the end of the job when the job finished successfully
        • true by default
        • {output-dir}/logs folder with the logs of all external processed is not deleted
      • delete all tmp files at the end of the job when the job finished with an error
        • false by default
        • useful to find the reason of fail
    • To control these options in config.xml, add the following:
      <cleanWorkingDir>false</cleanWorkingDir>
      <deleteTmpFilesOnExit>true</deleteTmpFilesOnExit>
      <deleteTmpFilesOnFail>false</deleteTmpFilesOnFail>
  8. It can be configured whether to perform IMF validation of the input IMF package (Photon is used by default for validation).

    • It's true by default
    • It may be set to false for some test reasons
    • To control this option in config.xml, add the following:
      <validateImf>false</validateImf>

Generate metadata.xml

imf-conversion-utility dpp -m metadata -o metadata.xml

Generate audiomap.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AudioMap xmlns="http://audiomap.dpp.imfutility.netflix.com">
    <EBUTrack>
        <Number>1</Number>
        <CPLVirtualTrackId>urn:uuid:63b41d86-c5df-4169-b036-3a25024bd711</CPLVirtualTrackId>
        <CPLVirtualTrackChannel>2</CPLVirtualTrackChannel>
    </EBUTrack>
    <EBUTrack>
        <Number>2</Number>
        <CPLVirtualTrackId>urn:uuid:63b41d86-c5df-4169-b036-3a25024bd711</CPLVirtualTrackId>
        <CPLVirtualTrackChannel>1</CPLVirtualTrackChannel>
    </EBUTrack>
    <EBUTrack>
        <Number>3</Number>
        <CPLVirtualTrackId>urn:uuid:63b41d86-c5df-4169-b036-3a25024bd712</CPLVirtualTrackId>
        <CPLVirtualTrackChannel>1</CPLVirtualTrackChannel>
    </EBUTrack>
    <EBUTrack>
        <Number>4</Number>
        <CPLVirtualTrackId>urn:uuid:63b41d86-c5df-4169-b036-3a25024bd712</CPLVirtualTrackId>
        <CPLVirtualTrackChannel>2</CPLVirtualTrackChannel>
    </EBUTrack>
</AudioMap>

Run Conversion Job

Output and Logs

Conversion to iTunes format

  1. [Done Once] Prepare external tools used for conversion.
  2. [Done Once; edit when needed] Prepare config.xml.
  3. [Optional] Run Utility with appropriate command line arguments to generate metadata.xml to enter iTunes metadata values.
    • itunes
    • --mode [-m] metadata
    • --output [-o] metadata.xml
  4. Enter required metadata values manually (Tunes Film Package or Tunes TV Package) or specify custom metadata.xml file. After conversion done metadata.xml of resulting iTunes package can be invalid (missing some required data) and will require manually changes.
  5. [Optional] Run Utility with appropriate command line arguments to generate audiomap.xml to map input audio tracks and channels to the output ones.
    • itunes
    • --mode [-m] audiomap
    • --output [-o] audiomap.xml
  6. [Optional] Edit audiomap.xml to map input audio streams and channels. If audiomap will not be set then default audiomap will be used basis on essence descriptions if exist or by natural order.
  7. Run conversion job:
    • itunes
    • --mode [-m] convert (may be omitted as it's a default mode)
    • --config [-c] config.xml
    • --metadata metadata.xml
    • --audiomap audiomap.xml (optional)
    • --imp path-to-imp-folder (optional: can be set in config.xml)
    • --cpl CPL.xml (optional: can be set in config.xml)
    • --working-dir [-w] path-to-output-folder (optional: can be set in config.xml)
    • --vendor-id vendor identifier
    • --package-type [-p] iTunes package type film (default) or tv (optional)
    • --format [-f] video format (optional)
    • --trailer trailer asset location (optional, processed only for "film" package type)
    • --poster poster asset location (optional)
    • --chapters chapters.xml location (optional, processed only for "film" package type)
    • --cc a path to external closed captions (optional)
    • –-sub a paths to external subtitles (optional, processed only for "film" package type)
    • --fallback-locale main locale for iTunes package (optional, will be used if CPL or metadata locale is not set)
  8. An output iTines package is created under the specified output directory (-w) and is called vindor-id.itmsp.
  9. Logs:
    • The current conversion job log file: /logs/imf-utility.log.
    • Previous conversion jobs log files: /logs/archive.
    • External tools log files: {output-dir}/logs.
  10. Validation
    • To validate iTunes package against XML schema of metadata.xml official iTunes Transporter tool can be used. Transporter can validate assets too but need corresponding iTunes Connect account credentials.

Note 1:

Prepare external tools used for conversion

iTunes version of the utility on OS X used native Apple ProRes encoder that provided by PrEnc utility that can be found at GitHub PrEnc pero. Download PrEnc sources and follow installation instructions from README.md:

Other tools installation is the same tools as for DPP tools.

Prepare config.xml

The same process as for DPP config preparation.

Generate metadata.xml

imf-conversion-utility itunes -m metadata -o metadata.xml

Generate audiomap.xml

<?xml version="1.0" encoding="UTF-8"?>
<audiomap xmlns="http://netflix.com/imf/itunes/audiomap">
    <mainAudio locale="de-DE" name="main-audio.mov">
        <Option6/>
    </mainAudio>

    <alternativeAudio locale="ja" name="audio_JA.mov">
        <Option6>
            <Track1>
                <L>
                    <CPLVirtualTrackId>urn:uuid:850bd841-5c4a-4b02-b853-5ce1afbb3629</CPLVirtualTrackId>
                    <CPLVirtualTrackChannel>1</CPLVirtualTrackChannel>
                </L>
                <R>
                    <CPLVirtualTrackId>urn:uuid:850bd841-5c4a-4b02-b853-5ce1afbb3629</CPLVirtualTrackId>
                    <CPLVirtualTrackChannel>2</CPLVirtualTrackChannel>
                </R>
            </Track1>
        </Option6>
    </alternativeAudio>
</audiomap>

Run Conversion Job

The same process as for DPP run conversion except that output is a iTunes store package with

.itmsp name. #### Output and Logs The same as for [DPP](output-and-logs). ## Project Structure * The project is a Java project. * JDK-8 is required. * The project is a Gradle multi-project. * Findbugs and Checktyle are used for code quality. * It contains the following sub-projects: * __imf-conversion-main (imf-conversion-utility)__ * The main project. * Contains the main class. * Contains conversion.xml which describes external tools to be used for conversion for each format. * Contains log4j configuration. * Creates a final distribution. * Depends on conversion plugins to be included into the distribution. * __imf-conversion-common__ * Contains logic common for all Java projects. * __imf-conversion-core__ * Main IMF utility logic base for all formats. * Contains CPL processing logic. * Calls IMF validation. * Contains the logic of parsing conversion.xml and executing external tools. * A base project for all plugins. * __imf-essence-descriptors__ * An independent project that contains JAXB classes of IMF Essence schemas. * __dpp-conversion__ * A plugin to perform conversion to BBC DPP format. * Depends on imf-conversion-core and dpp-conversion-input-xsd * __dpp-conversion-input-xsd__ * A plugin containing XSDs for DPP format input XML files (metadata.xml, audiomap.xml). * It's separated from _dpp_conversion_ as there are other projects that require DPP metadata.xml (for example, ttml-to-stl). * __itunes-conversion__ * A plugin to perform conversion to iTunes Package format. * Depends on imf-conversion-core, itunes-conversion-input-xsd, itunes-metadata-film and itunes-metadata-tv * __itunes-conversion-input-xsd__ * A plugin containing XSDs for iTunes format input XML files (metadata.xml, audiomap.xml). * __itunes-metadata-film__ * An independent project that contains JAXB classes of iTunes Film Package 5.2 XML schema. * __itunes-metadata-tv__ * An independent project that contains JAXB classes of iTunes TV Package 5.2 XML schema. * __ttml2itt__ * An independent project to perform TTML to iTunes iTT subtitle conversion. * It's used as a default subtitle conversion tool by iTunes plugin. * The project fat jar (ttml2itt.jar) is copied into the 'tools' folder within delivery. * Depends on ttml-java * __ttml-java__ * An independent project that contains JAXB classes of ttml-cr-ttaf1-20100223 TTML schemas. * __ttml-to-stl__ * An independent project to perform TTML to EBU STL caption conversion. * It's used as a default caption conversion tool by DPP plugin. * The project fat jar (ttml-to-stl.jar) is copied into the 'tools' folder within delivery. * __imf-validation__ * An independent project to IMF package validation. * Uses Photon under the hood ([Photon](https://github.com/Netflix/photon)). * It's used as a default IMF validation tool. * The project fat jar (imf-validation.jar) is copied into the 'tools' folder within delivery.