Media clip using script

ELAN supports any command line tool that can extract clips from a video (or audio) file. For that purpose it uses a script file named "clip-media.txt" which can be found in the folder where ELAN is installed. In most cases some configuration needs to be performed in the script file, e.g. which command line tool to use, before clipping can succeed. Therefore ELAN first checks the (see the section called “Special ELAN data folder”) for the presence of the "clip-media.txt" file, before trying this file in its installation folder. By copying the customized "clip-media.txt" file to the data folder, the changes are accessible to all versions of ELAN.

Mac OS users will have a default execution line in "clip-media.txt" looking like this:

osascript ./scripts/qtp_clip_10_10_export.scpt $in_file $out_file $begin(sec.ms) $end(sec.ms)

Which means that an AppleScript script in the "scripts" folder will be executed when clipping media. There is a PDF file on the ELAN web site to help users with editing the script file.

Windows users can e.g. put a copy of ffmpeg.exe (or ffmbc.exe for clipping mp4 files) in the folder where ELAN is installed (or modify the execution line such that the full path to ffmpeg is included). You can find ffmpeg and ffmbc online.

If you want to use the syntax for ffmpeg, remove the # in front of the line starting with 'ffmpeg.exe -i .........' If you want to use the syntax for ffmbc, remove the # in front of 'ffmbc.exe -vcodec copy.......' Make sure the syntax you do not want to use has a # in front of it, this comments the line out.

The syntax for ffmpeg can be: ffmpeg.exe -i $in_file -vcodec copy -acodec copy -ss $begin(sec.ms) -t $duration(sec.ms) $out_file

Where the elements are:

Look in the script file for more explanation and examples. If it is not possible to edit the script file due to file permissions, copy "clip-media.txt" to the the section called “Special ELAN data folder” (and modify it to use an absolute path to the clipping application).

A few examples for command line tools are:

C:\ffmpeg.exe -i $in_file -vcodec copy -acodec copy -ss $begin(sec.ms) -t $duration(sec.ms) $out_file

C:\ffmbc.exe -vcodec copy -acodec copy -ss $begin(hour:min:sec.ms) -t $duration(hour:min:sec.ms) -i $in_file $out_file

To clip a media file first make a time selection and choose File > Export As > Media Clip using Script.... A dialog will appear in which you can set the file name and the location to save the clipped file to. You can specify more options for clipping in the Preferences dialog, see the section called “Editing preferences”.

[Note]Note

If you have more media files to be clipped, typing a file name with a extension in the 'Save as' dialog will use the same extension for all the files that will be clipped. If you want to use the same extension from the original media file for the clipped files, then don't type an extension with the file name in the 'Save as' dialog which prompts you to set the file name and location for the clipped media files.