Good test content is always hard to come by, so I often have to make my own.
I'm working on an issue where closed-caption/sub-titles are not displaying in alignment to spoken language. So on back-and-forth scenes the sub-titles appear to be in obvious mis-alignment.
So my plan was to use a video of a millisecond "accurate" counter and then display timed-text images (PNG) over the video through the application of which I don't have source for. Should my test prove that there are timing issues then I'll be able to push the vendor for source and/or have them address their timing issue(s).
So with a millisecond "accurate" counter movie in the background I intend to display imagemagick-convert created PNGs which will have sufficient embedded text to allow a high-speed camera to then show any mis-alignments during decode/rendering from the timed-text source file (Scenartist DVD SST format).
The issue I've run into is that my call to 'convert' works from the console, but doesn't work from my bash script. I've placed all necessary break-characters around single and double quotes, and have also tried passing the arguments via 'xargs' and achieved the same failure. it seems that bash's interpretation of the string gets construed before its passed to 'convert'. With 'set -x' enabled at the top of the script I see the string that's passed, and interestingly if that string is pasted to the console it works. Only it doesn't work directly from the script.
Please advise if my approach is incorrect and/or if I'm missing a parameter/option to make this work.
Here are a few rows of the SST file for reference:
1613 02:29:08:20 02:29:09:14 NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX1595.png
1614 02:29:56:10 02:29:57:15 NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX1596.png
1615 02:29:57:20 02:29:59:05 NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX1597.png
Format: Enumeration, display-start time hh:mm:ss:frame display-stop time hh:mm:ss:frame, and image file name.
Note: I manually remove the SST file header and leave only the timed-text information for now, for those that are familiar with the format.
Bash-script:
#! /bin/sh
set -x
echo "SST File name passed in <$1>"
COUNT=0
GFX_FILENAME="test"
while IFS= read -r LINE; do
COUNT=`expr $COUNT + 1`; # Debug not needed
echo "Converting entry <$COUNT>... " # Debug not needed
echo "Line read is <$LINE>" # Debug not needed
GFX_FILENAME=$(printf "%s" "$LINE" | cut -f4 -d' ') # works
GFX_INLINE_TEXT=$(printf "%s" "$LINE" | tr \\t ' ') # works
GFX_FILENAME="gfx_filename_here.png" # debug, put in place to isolate any issue introduced from parsed value
GFX_INLINE_TEXT="gfx text here" # debug, put in place to isolate any issue introduced from parsed value
echo "Filename parsed from line is <$GFX_FILENAME>" # debug to check value before calling convert
# Method 1, call convert directly:
convert -size 720x480 xc:transparent -font Palatino-Bold -pointsize 72 -fill black -draw \"text 20,55 \'$GFX_INLINE_TEXT\'\" $GFX_FILENAME
# Method 2, echo arguments to xargs then call convert (same result) commented out for now. Note: xargs hides 'convert's error output.
# echo -size 720x480 xc:transparent -font Palatino-Bold -pointsize 72 -fill black -draw \"text 20,55 \'$GFX_INLINE_TEXT\'\" $GFX_FILENAME | xargs
echo "Converted an image..." # debug, when i find this in console output from script execution I know what's above (from run with set -x enabled) is what I can paste to the console to double-check my syntax
done < $1 # method used to pass file to while loop
echo "Done!!!" # not true, since it doesn't work
Output:
./sst_to_png.sh NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_v05.sst
+ echo File name passed in is <NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_v05.sst>
File name passed in is <NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_v05.sst>
+ COUNT=0
+ GFX_FILENAME=test
+ IFS= read -r LINE
+ expr 0 + 1
+ COUNT=1
+ echo Converting entry <1>...
Converting entry <1>...
> echo Line read is <0003 01:01:11:22 01:01:14:25 NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX0000.png
>ine read is <0003 01:01:11:22 01:01:14:25 NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX0000.png
+ printf %s 0003 01:01:11:22 01:01:14:25 NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX0000.png
+ cut -f4 -d
+ GFX_FILENAME=NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX0000.png
+ printf %s 0003 01:01:11:22 01:01:14:25 NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX0000.png
+ tr \t
+ GFX_INLINE_TEXT=0003 01:01:11:22 01:01:14:25 NightAtTheMuseum_Th_16x9_EnS_DYN_B5-01608_FOX0000.png
+ GFX_FILENAME=gfx_filename_here.png
+ GFX_INLINE_TEXT=gfx text here
+ echo Filename parsed from line is <gfx_filename_here.png>
Filename parsed from line is <gfx_filename_here.png>
+ convert -size 720x480 xc:transparent -font Palatino-Bold -pointsize 72 -fill black -draw "text 20,55 'gfx text here'" gfx_filename_here.png
convert.im6: non-conforming drawing primitive definition `text' @ error/draw.c/DrawImage/3158.
convert.im6: unable to open image `20,55': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `20,55' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `'gfx': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `'gfx' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `text': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `text' @ error/constitute.c/ReadImage/544.
convert.im6: unable to open image `here'"': No such file or directory @ error/blob.c/OpenBlob/2638.
convert.im6: no decode delegate for this image format `here'"' @ error/constitute.c/ReadImage/544.
convert.im6: non-conforming drawing primitive definition `text' @ error/draw.c/DrawImage/3158.
+ echo Converted an image...
Converted an image...
Then I paste:
convert -size 720x480 xc:transparent -font Palatino-Bold -pointsize 72 -fill black -draw "text 20,55 'gfx text here'" gfx_filename_here.png
To the console, copied from the script's output and it works.
Thanks in advance, hopefully the 'convert' errors mean something to someone. Its odd to me that the verbose output, with set -x enabled at top of script, produces something that works when pasted to the console but not when executed directly from script.