cancel
Showing results for 
Search instead for 
Did you mean: 

RuntimeExec transformer woes

manders
Champ in-the-making
Champ in-the-making
I've defined a RuntimeExec transformer that converts a .wmv to .flv using ffmpeg. It seems to execute fine but then dies with Exit Code 1.

10:55:45,040 User:admin DEBUG [content.transform.ContentTransformerRegistry] Searched for transformer:
   source mimetype: video/x-ms-wmv
   target mimetype: video/x-flv
   transformers: [RuntimeExecutableContentTransformer[ transform=RuntimeExec:
   command:    ffmpeg -i '${source}' -vcodec flv -ar 44100 -ab 32 -b 800k '${target}'
   env props:  null
   dir:        null
   os:         Linux

10:55:45,197 User:admin DEBUG [util.exec.RuntimeExec] Execution result:
   os:         Linux
   command:    [ffmpeg, -i '/opt/Alfresco/tomcat/temp/Alfresco/RuntimeExecutableContentTransformer_source_730142860692261929.wmv', -vcodec flv, -ar 44100, -ab 32, -b 800k, '/opt/Alfresco/tomcat/temp/Alfresco/RuntimeExecutableContentTransformer_target_3588279390070062814.flv']
   succeeded:  true
   exit code:  1
   out:
   err:        FFmpeg version SVN-rUNKNOWN, Copyright © 2000-2007 Fabrice Bellard, et al.
  configuration: –prefix=/usr –libdir=/usr/lib –mandir=/usr/share/man –incdir=/usr/include/ffmpeg –enable-libmp3lame –enable-libogg –enable-libvorbis –enable-libogg

After the transformer has completed, the temporary target file (RuntimeExecutableContentTransformer_target_3588279390070062814.flv) exists but is 0kb large. A converted file has also been created, <video>.flv, but is similarly 0kb large.

When I take the same command and execute it on the command line (removing the commas between parameters) it works fine.

What might I be doing wrong? Is there a way to extend what is being reported in the 'err' output by log4j so I can actually see the whole ffmpeg output, rather than just the first two lines of version information?
10 REPLIES 10

manders
Champ in-the-making
Champ in-the-making
Here's my transformer:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
   <bean id="transformer.ffmpeg.WMVtoFLV" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformer" parent="baseContentTransformer">
      <property name="transformCommand">
         <bean id="commandListRootDir" class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandsAndArguments">
                <map>
                    <entry key="Linux">
                        <list>
                            <value>ffmpeg</value>
                            <value>-i '${source}'</value>
                            <value>-vcodec flv</value>
                            <value>-ar 44100</value>
                            <value>-ab 32</value>
                            <value>-b 800k</value>
                            <value>'${target}'</value>
                        </list>
                    </entry>
                    <entry key="Windows.*">
                        <list>
                            <value>ffmpeg</value>
                            <value>-i '${source}'</value>
                            <value>-vcodec flv</value>
                            <value>-ar 44100</value>
                            <value>-ab 32</value>
                            <value>-b 800k</value>
                            <value>'${target}'</value>
                        </list>
                    </entry>
                </map>
            </property>
            <property name="errorCodes">
               <value>2</value>
            </property>
         </bean>
      </property>
      <property name="explicitTransformations">
         <list>
            <bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
                <property name="sourceMimetype"><value>video/x-ms-wmv</value></property>
                <property name="targetMimetype"><value>video/x-flv</value></property>
            </bean>
         </list>
      </property>
   </bean>
</beans>

jottley
Confirmed Champ
Confirmed Champ
Can you try making ffmpeg less versbose?  As in no output.   Try adding an option to redirect the onscreen output to /dev/null.

manders
Champ in-the-making
Champ in-the-making
Hm. Adjusting the verbosity level (through -v #) doesn't seem to work - it can make things more verbose but not less, as far as I can tell.
Piping the output to /dev/null would defeat the purpose, no? I want to see the output, the more the better. Or did I misunderstand?

jottley
Confirmed Champ
Confirmed Champ
Right.  The verbosity level for ffmpeg is already set at its lowest.  What we are  trying to do is make the conversion silent. Notice I said redirect and not pipe.  What we want is to redirect all the messaging associated with the transformation.  I am not guaranteeing that this will work.  I don't have a machine I can test this out on at the moment.

Another option would be to move all of the values from the list in to a single value.  Something a little closer to:
<list>
                            <value>ffmpeg -i '${source}' -vcodec flv -ar 44100 -ab 32 -b 800k '${target}'</value>
</list>

manders
Champ in-the-making
Champ in-the-making
I understand you now, I think.

I added a parameter like '2> /somefolder/log' to log stderr (which is where all the output is coming from) to a file. Unfortunately, Alfresco doesn't seem to care - the message still shows up in catalina.log as before, and the /somefolder/log file doesn't get created (???). The user Alfresco is running as has permissions to the target folder and it all works just dandy through the CLI.

eveloper
Champ in-the-making
Champ in-the-making
Hello, I faced with the same problem you mentioned here. May be you have found any solution, or you finally used another converter? Could you please provide me some information about your achivements.. any advice will be useful!

Thanks in advance.

dward
Champ on-the-rise
Champ on-the-rise
It's your shell that understands redirections, not the OS.

Why not try this:


                    <entry key="Linux">
                        <list>
                            <value>sh</value>
                            <value>-c</value>
                            <value>ffmpeg -i '${source}' -vcodec flv -ar 44100 -ab 32 -b 800k '${target}' 2>/dev/null</value>
                        </list>
                    </entry>

eveloper
Champ in-the-making
Champ in-the-making
Thanks for the quick response, you were right it was shell problem. Your post really helped me.
Good luck and thank you again…

nowhere
Champ in-the-making
Champ in-the-making
Hi all,
I'm trying to create my content transformer using ocr.exe from intelliant.

I have in my extension folder file ocr-transformation-context.xml that looks like so:

<?xml version='1.0' encoding='UTF-8'?>
<!DOCTYPE beans PUBLIC '-//SPRING//DTD BEAN//EN' 'http://www.springframework.org/dtd/spring-beans.dtd'>

<beans>
  
   <bean id="transformer.Ocr.Tiff2Pdf" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
      <property name="checkCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandsAndArguments">
                <map>
                    <entry key=".*">
         <list>
                           <value>ocr.exe</value>
            <value>–about</value>
         </list>
                    </entry>
                </map>
            </property>
    <property name="errorCodes">
<value>1,2</value>
</property>     
         </bean>
      </property>
      <property name="transformCommand">
         <bean class="org.alfresco.util.exec.RuntimeExec">
            <property name="commandsAndArguments">
                <map>
                    <entry key="Windows.*">
                        <value>ocr.exe –replace –language fr –pdf –output-file "${target}" "${source}"</value>
                    </entry>
                </map>
            </property>
            <property name="errorCodes">
<value>1,2</value>
</property>
         </bean>
      </property>
      <property name="explicitTransformations">
         <list>
            <bean class="org.alfresco.repo.content.transform.ExplictTransformationDetails" >
      <property name="sourceMimetype"><value>image/tiff</value></property>
                <property name="targetMimetype"><value>application/pdf</value></property>
            </bean>
         </list>
      </property>
   </bean>

   <bean id="transformer.ocrTopdf" class="org.alfresco.repo.content.transform.ProxyContentTransformer"
      parent="baseContentTransformer">
      <property name="worker">
         <ref bean="transformer.Ocr.Tiff2Pdf"/>
      </property>
   </bean>
</beans>

and when I startup tomcat I read:

18:02:03,407  DEBUG [util.exec.RuntimeExec] Execution result:
   os:         Windows XP
   command:    [ocr.exe, –about]
   succeeded:  true
   exit code:  0
   out:        Intelliant OCR commandline utility, version 1.1.0. Copyright ® 20
06.

  Credits:

  TIFF Library
  Copyright © 1988-1997 Sam Leffler
  Copyright © 1991-1997 Silicon Graphics, Inc.

  Independent JPEG Group Library
  Copyright (C) 1991-19
   err:

Than I create a rule in a space specifing that all content with mimetype "tiff" should be transformed into pdf.

Rule condition: 'Item has a mimetype of 'TIFF Image'
Rule Actions: Copies content to 'my folder' and transforms to 'Adobe PDF Document'

It creates pdf, but If I open it clicking on name I see quick time simbol and than content not searchable (it's looks like more an image with pdf extension).
If I download it acrobat says it's damaged or not a valid file.
I can't figure out who (my ocr.exe or what else) is performing transformation and, also, I'm not sure if my transformer has been registered because on console I read:

18:07:38,251 User:admin DEBUG [content.transform.ContentTransformerRegistry] Sea
rched for transformer:
   source mimetype: image/tiff
   target mimetype: text/plain
   transformers: []
18:07:39,188 User:admin DEBUG [content.transform.ContentTransformerRegistry] Sea
rched for transformer:
   source mimetype: image/tiff
   target mimetype: application/pdf
   transformers: []
18:07:39,188 User:admin DEBUG [content.transform.ContentTransformerRegistry] Sea
rched for transformer:
   source mimetype: image/tiff
   target mimetype: text/plain
   transformers: []
18:07:42,126 User:admin DEBUG [content.transform.ContentTransformerRegistry] Sea
rched for transformer:
   source mimetype: image/tiff
   target mimetype: text/plain
   transformers: []
18:13:07,626 User:admin DEBUG [content.transform.ContentTransformerRegistry] Sea
rched for transformer:
   source mimetype: image/tiff
   target mimetype: text/plain
   transformers: []
18:13:13,219 User:admin DEBUG [content.transform.ContentTransformerRegistry] Sea
rched for transformer:
   source mimetype: image/tiff
   target mimetype: text/plain
   transformers: []

How could I register it? What am I missing?
If you need more info, let me know…I'm newbie, so I can't know what it's important to understand the issue.
Hope in some help, it's very urgent for me!
Thanks in advance!