Changes between Version 8 and Version 9 of FilteringGuide


Ignore:
Timestamp:
Dec 9, 2011, 1:01:37 PM (5 years ago)
Author:
nichot20
Comment:

Added scripting guide

Legend:

Unmodified
Added
Removed
Modified
  • FilteringGuide

    v8 v9  
    5151}}} 
    5252Note that the examples given in the documentation mix and match the use of "full quoting" and "\" escaping, and that use of unusual shells may upset escaping. 
     53=== Scripting your command line parameters === 
     54If building complex filtergraphs the command line can get very messy so it can help to break things down into manageable pieces. However one needs to be careful when joining them all together to avoid issues due to your shell and escaped characters. 
     55 
     56The following example shows a sample bash script containing a filtergraph of one chain with three filters; yadif, scale and drawtext. 
     57{{{ 
     58#!/bin/bash 
     59# ffmpeg test script 
     60 
     61path="/path/to/file/" 
     62 
     63in_file="in.mp4" 
     64out_file="out.mp4" 
     65 
     66cd $path 
     67 
     68filter="-vf \"yadif=0:-1:0, scale=400:226, drawtext=fontfile=/usr/share/fonts/truetype/DroidSans.ttf: \ 
     69text='tod- %X'':x=(w-text_w)/2:y=H-60 :fontcolor=white :box=1:boxcolor=0x00000000@1\"" 
     70codec="-vcodec libx264  -pix_fmt yuv420p -b:v 700k -r 25 -maxrate 700k -bufsize 5097k" 
     71 
     72command_line="ffmpeg -i $in_file $filter $codec -an $out_file" 
     73 
     74echo $command_line 
     75eval $command_line 
     76exit 
     77}}} 
     78Note that the double quotes " around the whole filtergraph have been escaped \" and the filtergraph spans more than one line, the echo command shows the full command as it is executed. Useful for debugging. 
     79 
     80The {{{eval}}} invocation of the $command_line variable is required to avoid loss of the embedded escaped quotes which occurs if it is absent. Other shells may behave differently. 
    5381 
    5482=== List of Filters ===