Difference between revisions of "Media Commons"

From Immersive Visualization Lab Wiki
Jump to: navigation, search
(Created page with "=Media Commons= ==Convert Image to Pyramidal TIFF== Example: <pre> gdal_translate -co "TILED=YES" original.tif output.tif gdaladdo -r average output.tif 2 4 8 16 32 64 </p...")
 
(Convert Image to Pyramidal TIFF)
 
(8 intermediate revisions by one user not shown)
Line 3: Line 3:
 
==Convert Image to Pyramidal TIFF==
 
==Convert Image to Pyramidal TIFF==
  
Example:
+
Log in to vroomcglx.calit2.net as user demo. Then do the conversion with the following commands, replacing the image names with those of yours:
 +
 
 
<pre>
 
<pre>
 
  gdal_translate -co "TILED=YES" original.tif output.tif
 
  gdal_translate -co "TILED=YES" original.tif output.tif
Line 10: Line 11:
  
 
The first command will tile the image which helps with performance.
 
The first command will tile the image which helps with performance.
The second will add overviews: 2 4 8 16 32 64 (each number is a split level (so this will create 6 levels - you can create more but making a tile smaller than 256 by 256 is pointless).
+
The second will add overviews: 2 4 8 16 32 64 (each number is a split level (so this will create 6 levels - you can create more but making a tile smaller than 256 by 256 is pointless because that is the smallest tile size Media Commons will use).
 
The final image in the example will be output.tif.
 
The final image in the example will be output.tif.
 +
 +
To make the image show up in the menu, copy it to <tt>/home/demo/demo_content</tt> or <tt>/export/fionavroom/demo_content/</tt>.
 +
 +
==Convert high resolution video for CGLX player==
 +
 +
Converting high resolution video into CGLX renderable OSG tile clusters with XML metadata for playback under MediaCommons:
 +
 +
Script requires FFMPEG and Python 2.7
 +
 +
Usage: sh clustertile.sh [INPUT_DIR_FILE] [OUTPUT_DIR] [OUTPUT_PREFIX] [WIDTH] [HEIGHT] [COL] [ROW]
 +
 +
Example:
 +
user$> sh clustertile.sh /foo/foo.mp4 /bar test 3840 2160 8 8
 +
 +
Depending on the source resolution and level of subdivision FFMPEG crop streaming can be fast or take some time.
 +
Transcoding your source content to H264 before running the clustertile script can speed things up significantly.
 +
 +
 +
<pre>
 +
#!/bin/bash
 +
# Rev021115
 +
# Nathan Wade
 +
#
 +
# This script creates cluster optimized OpenSceneGraph quad tiles with metadata
 +
# from a single HD video source for synchronous playback on MediaCommons CGLX video walls. 
 +
#
 +
# http://sc13.supercomputing.org/sites/default/files/WorkshopsArchive/pdfs/wp154s1.pdf
 +
# http://vis.ucsd.edu/~cglx/
 +
#
 +
# required: FFMPEG, Python 2.7
 +
# usage: sh scriptname INPUT_DIR_FILE OUTPUT_DIR OUTPUT_PREFIX WIDTH HEIGHT COL ROW
 +
 +
echo "INPUT_DIR_FILE: $1"
 +
#ffmpeg -i $1
 +
echo "OUTPUT_DIR: $2"
 +
echo "OUTPUT_PREFIX: $3"
 +
echo "WIDTH: $4"
 +
echo "HEIGHT: $5"
 +
echo "COL: $6"
 +
echo "ROW: $7"
 +
 +
mkdir $2/$3/
 +
touch $2/$3.xml
 +
 +
 +
PYTHON_ARG="$1 $2 $3 $4 $5 $6 $7" python - <<END
 +
 +
import os
 +
import subprocess as sp
 +
 +
FMPEG_BIN = "ffmpeg" # unix, os x
 +
FFMPEG_BIN = "ffmpeg.exe" # ms windows
 +
 +
XML = open('$2/$3.xml','w')
 +
XML.write("<?xml version=\"1.0\"?>\n<RenderableDataObject type=\"tiled_video\">\n")
 +
 +
cW = $4/$6
 +
cH = $5/$7
 +
cRow = 0
 +
cCol = 0
 +
 +
for col in range(0,$6):
 +
for row in range(0,$7):
 +
XML.write('    <tile path=\"$2/$3/%i-%i.mp4\" column=\"%i\" row=\"%i\" />\n'%(cCol, cRow, cCol, $7-cRow-1))
 +
       
 +
        #ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" [-an | -c:a copy] out.mp4 -y
 +
command = [ FMPEG_BIN,
 +
            '-i', '$1',
 +
            '-filter:v', 'crop=%i:%i:%i:%i'%(cW,cH, cW*cCol, cH*cRow),
 +
            '-an','$2/$3/%i-%i.mp4'%(cCol, cRow),
 +
            '-y']
 +
pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)
 +
 +
cRow+=1
 +
 +
cRow = 0
 +
cCol+=1
 +
 +
XML.write("</RenderableDataObject>\n")
 +
XML.close
 +
END
 +
 +
exit
 +
</pre>

Latest revision as of 17:55, 13 March 2019

Media Commons

Convert Image to Pyramidal TIFF

Log in to vroomcglx.calit2.net as user demo. Then do the conversion with the following commands, replacing the image names with those of yours:

 gdal_translate -co "TILED=YES" original.tif output.tif
 gdaladdo -r average output.tif 2 4 8 16 32 64

The first command will tile the image which helps with performance. The second will add overviews: 2 4 8 16 32 64 (each number is a split level (so this will create 6 levels - you can create more but making a tile smaller than 256 by 256 is pointless because that is the smallest tile size Media Commons will use). The final image in the example will be output.tif.

To make the image show up in the menu, copy it to /home/demo/demo_content or /export/fionavroom/demo_content/.

Convert high resolution video for CGLX player

Converting high resolution video into CGLX renderable OSG tile clusters with XML metadata for playback under MediaCommons:

Script requires FFMPEG and Python 2.7

Usage: sh clustertile.sh [INPUT_DIR_FILE] [OUTPUT_DIR] [OUTPUT_PREFIX] [WIDTH] [HEIGHT] [COL] [ROW]

Example: user$> sh clustertile.sh /foo/foo.mp4 /bar test 3840 2160 8 8

Depending on the source resolution and level of subdivision FFMPEG crop streaming can be fast or take some time. Transcoding your source content to H264 before running the clustertile script can speed things up significantly.


#!/bin/bash
# Rev021115
# Nathan Wade
#
# This script creates cluster optimized OpenSceneGraph quad tiles with metadata 
# from a single HD video source for synchronous playback on MediaCommons CGLX video walls.  
#
# http://sc13.supercomputing.org/sites/default/files/WorkshopsArchive/pdfs/wp154s1.pdf
# http://vis.ucsd.edu/~cglx/
#
# required: FFMPEG, Python 2.7
# usage: sh scriptname INPUT_DIR_FILE OUTPUT_DIR OUTPUT_PREFIX WIDTH HEIGHT COL ROW

echo "INPUT_DIR_FILE: $1"
#ffmpeg -i $1
echo "OUTPUT_DIR: $2"
echo "OUTPUT_PREFIX: $3"
echo "WIDTH: $4"
echo "HEIGHT: $5"
echo "COL: $6"
echo "ROW: $7"

mkdir $2/$3/
touch $2/$3.xml


PYTHON_ARG="$1 $2 $3 $4 $5 $6 $7" python - <<END

import os
import subprocess as sp

FMPEG_BIN = "ffmpeg" # unix, os x
FFMPEG_BIN = "ffmpeg.exe" # ms windows

XML = open('$2/$3.xml','w')
XML.write("<?xml version=\"1.0\"?>\n<RenderableDataObject type=\"tiled_video\">\n")

cW = $4/$6
cH = $5/$7
cRow = 0
cCol = 0

for col in range(0,$6):
	for row in range(0,$7):
		XML.write('    <tile path=\"$2/$3/%i-%i.mp4\" column=\"%i\" row=\"%i\" />\n'%(cCol, cRow, cCol, $7-cRow-1))
        
        #ffmpeg -i in.mp4 -filter:v "crop=out_w:out_h:x:y" [-an | -c:a copy] out.mp4 -y
		command = [ FMPEG_BIN,
            '-i', '$1',
            '-filter:v', 'crop=%i:%i:%i:%i'%(cW,cH, cW*cCol, cH*cRow),
            '-an','$2/$3/%i-%i.mp4'%(cCol, cRow),
            '-y']
		pipe = sp.Popen(command, stdout = sp.PIPE, bufsize=10**8)

		cRow+=1
		
	cRow = 0
	cCol+=1

XML.write("</RenderableDataObject>\n")
XML.close
END

exit