One of P5 Archive’s strengths is the mini-MAM function, which can capture thumbnails, proxies and metadata from media assets. This allows for the content of off-line media to be browsed visually in P5’s web-admin interface.
The capture of thumbnails and proxies can be configured beyond the default ‘preview generators’ by writing scripts to call software tools to generate different types of previews. In this article we’ll link to a script that generates a ‘mosaic’ image from a video file, as an alternative to rendering all or part of the original file into a low-res proxy. A 4×3 mosaic of an example video file looks like this.
It contains frames from throughout the video file, a simple representation of the content in a single image frame.
Let’s look in detail at how we configure P5 Archive to generate such mosaic images from media files that have been archived. We provide a script that works on Linux, macOS and Synology operating systems. It may work on additional Linux-based platforms, we’ve not yet tested. For Windows systems, a .BAT batch file will need to be written, we’re open to assistance with this from the community!
Credit to Christophe Rémond (https://www.helios.pro/) for coming up the idea and writing the script.
Step 1 – Download the script and place somewhere on your P5 Server host. I’ve used the P5 installation directory /usr/local/aw in my examples here. Once copied to the P5 host, you’ll need to make the script executable, so it can be treated as a script rather then just a plain text file. There are many resources online if you search ‘make script executable’. If you’re already familiar with executing commands in a shell/terminal window, you can enter ‘chmod +x video_to_mosaic.sh’ at the command-line while in the same folder as the script.
Step 2 – Create or edit an existing Archive Plan, visit the ‘Previews’ tab, click the ‘New…’ button and pick ‘Add a Custom Script’ from the drop-down menu. Provide a list of file extensions for video file formats for which you would like to see mosaics, add as many as you wish for your workflow. Then provide the full path and filename of the script file that you’ve copied onto the P5 host system. See below for how this looks on our system (click image for larger version):
Apply the changes to save the preview generator and the archive plan.
Step 3 – Archive some video files with extensions that match those you specified in the preview generator. If all is working, you should now see something like this when you browse in the P5 Archive Index.
Step 4 – Customise! You can edit the script to customise the number of video frames that appear in the mosaic. Look for this section in the script:
# mosaic is format 4:3 mosaic_factor=1 # a 1 value ratio 4x3= 12 images # a 2 value ratio 8x6= 48 images # a 3 value ratio 12x9= 108 images ...
The lines that begin with the hash ‘#’ character are comments and have no effect on the function of the script. These comments show what effect values of 1,2 and 3 will have when you edit the line ‘mosaic_factor=1’. Our examples above used a value of 1 resulting in 4×3=12 images in our mosaic. Adjust this value and re-archive files to see the changes.
Make copies of the script and experiment! Note that the script uses the FFMPEG software/tool to generate the mosaic. This tool is pre-installed within Archiware’s installation so there’s nothing additional to install to use this script.