Home Forums Software ELAN Problem with media clip using script

Problem with media clip using script

This topic contains 13 replies, has 4 voices, and was last updated by  Han 10 months, 1 week ago.

Viewing 10 posts - 1 through 10 (of 14 total)
Author Posts
Author Posts
October 1, 2017 at 18:46 #11703


I have not been able to extract any media clips from ELAN using the media clip using script feature. Every time I try, nothing happens. I currently use the ELAN 5.0.0-alpha and beta versions for MacOS Sierra and have looked through the forum. I wonder if I need to edit the clip media text file. Would someone take the time to look at it? Here it is:

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

# M2-edit-cl /in:$begin(fr) /out:$end(fr) $in_file $out_file
# ffmpeg.exe -vcodec copy -acodec copy -ss $begin(sec.ms) -t “$duration(sec.ms)” -i $in_file $out_file

# Lines starting with a # (dash) are considered to be comment lines.
# This is an example media clipping configuration file for use with ELAN.
# The configuration consists of the name of an application that can clip
# media files and that supports parameterized calls from the command line
# followed by a number of parameters for the application.
# The actual set of parameters depends on the application of choice.
# But most programs will need the path to an input file, the path to an output file,
# the begin time of the portion to clip and either the end time or the duration of
# the portion to clip.
# When creating a clip from within ELAN, it reads the script and fills the
# placeholders for the common parameters with the necessary information.
# The first part of the script should be the name or the path to the application
# to be used for the clipping. If only a name is used the application should be
# known to the system, “in the path”. If a path is specified it should be the
# absolute path to the application. If the absolute path contains white spaces the
# path should be within double quotation marks. If the input file and output file
# paths might contain spaces and the clipping application would need them to
# be in quotation marks these should be added before and after the placeholders
# in the script.in
# The placeholders have this form:
# $in_file
# $out_file
# $begin(format)
# $end(format)
# $duration(format)
# where format needs to be replaced by one of the following formats:
# hour:min:sec.ms
# hour:min:sec:fr
# hour:min:sec:fr_NTSC
# sec.ms
# ms
# fr
# fr_NTSC
# when frames are specified PAL is assumed, for NTSC use hour:min:sec:fr_NTSC or fr_NTSC
# Examples:
# C:\Program\ffmpeg\bin\ffmpeg.exe -i $in_file -vcodec copy -acodec copy -ss $begin(sec.ms) -t $duration(sec.ms) $out_file
# M2-edit-cl /in:$begin(fr) /out:$end(fr) $in_file $out_file

October 3, 2017 at 01:25 #11705


Yes, there are several issues with this functionality on macOS. As of version 10.11 (I believe) all the libraries and resources of an application need to be inside the .app folder. If you right-click e.g. the ELAN_5.0.0-beta(.app) and choose Show Package Contents, you’ll find a lot of files in the Contents/Resources folder. Apart from the ‘clip-media.txt’ file, normally there would also be a file ‘qtp_clip_10_7_export.scpt’ there. But if we do so the .app cannot be digitally signed because the .scpt is detected as ‘junk’. They are now zipped in ‘scripts.zip’.
The best thing to do is maybe look into the ‘Clip_media_osx.pdf’ and follow the steps to copy ‘Clip-media.txt’ to ELAN’s preferences folder.
Then edit it. Either change the relevant line to call ffmpeg or extract the most recent, the 10_7 version, of the scpt archive and save it e.g in the same ELAN preferences folder and modify ‘clip-media’ by setting the absolute path to the .scpt file as the second parameter, after ‘osascript’. After saving clip-media and launching ELAN, clipping media might work.

There are still problems with the .scpt file: the time values for start and end times are read as ‘integer’ and the fractional part is removed (or rounded down to whole seconds). The arguments 3 and 4 in the .scpt file should be read as ‘real’ but then (on the system I tested on) time values in the format sec.ms are not parsed correctly when there are three decimals, as ELAN passes such time values. E.g. 12.333 is apparently not correct, 12.3 is. At this moment I don’t think there is a way to specify such format.
Maybe clipping with ffmpeg is easier now (but I haven’t checked that recently).


October 5, 2017 at 14:00 #11708


I have now uploaded new versions of the two variants of AppleScript-based clipping, one that calls QuickTime’s export function and one that calls the Save As function. The first one works on a macOS 10.12 machine, the second one results in a “no permission” message at the point of saving the file (maybe someone can try that one too).
In order to use e.g. the “qtp_clip_10_10_export.scpt” version the clip-media.txt has to be modified as mentioned above. If it doesn’t work from within the ELAN .app folder, it can be tried from the ELAN Preferences folder.
The new scripts can be downloaded here.

April 7, 2018 at 21:43 #12143


I really couldn’t solve the issue. Where should I copy ‘qtp_clip_10_10_export.scpt’and how ‘clip-media.txt’ has to be modified?
I tried this ‘The best thing to do is maybe look into the ‘Clip_media_osx.pdf’ and follow the steps to copy ‘Clip-media.txt’ to ELAN’s preferences folder.’, but not able to. Maybe a tutorial with the steps within MacOs (High Sierra)?
Many Thanks

April 9, 2018 at 22:21 #12145


Dear Giorgina,
The “Clip_media_osx.pdf” is intended to be a kind of tutorial or macOS users, but it still has to be updated. We have limited resources so it is not easy to keep everything up to date. It’s not quite clear to me whether you didn’t find the “Clip_media_osx.pdf” file at all or whether you were not able to follow the steps. In the latter case it would be helpful which steps you were not able to follow.

Summarizing: assume your login name is “giocan”, your “home” folder will be /Users/giocan/ If you go to this folder in the Finder you probably won’t see a subfolder “Library” but it is there. Press the Alt/Option key and click the Go menu in the main menu bar and you’ll see a Library menu item. Select this item and that folder will open in the Finder. Then go to subfolders like this;
into that folder copy “clip-media.txt” and “qtp_clip_10_10_export.scpt”
open “clip-media.txt” and modify the first line such that it is like this:
osascript /Users/giocan/Library/Preferences/ELAN/qtp_clip_10_10_export.scpt $in_file $out_file $begin(sec.ms) $end(sec.ms)
Save the file, launch ELAN and try to clip a selection via Export As - Media Clip using script.. etc. Does it work?

April 12, 2018 at 15:51 #12168


We’ve created an updated version of the media clipping tutorial, it is now available on the ELAN web page. This is the macOS version, hopefully this clarifies the procedure a bit better.

April 28, 2018 at 18:38 #12185


Thank you.

April 28, 2018 at 20:53 #12186


So, I’m working with ELAN 4.9.4.
I did part 1 of the tutorial (where to place the script) and placed the files
but about part 2 that’s what I find in clip-media.text:

ffmpeg.exe -i $in_file -ss $begin(sec.ms) -t $duration(sec.ms) $out_file

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

# Lines starting with a # (dash) are considered to be comment lines.
# This is an example media clipping configuration file for use with ELAN.


and that’s the kind of error I have when I try to export as ‘media clip using script’:

Error running script: Cannot run program “ffmpeg.exe”: error=2, No such file or directory(1)

Thanks for more help to my dummy questions

April 28, 2018 at 21:03 #12187


One more,
is it regular that ‘qtp_clip_10_10_save.scpt’ downloaded from the link above is actually an empty file (no lines)?

May 1, 2018 at 12:07 #12193


But on macOS the default non-comment line in clip-media.txt starts with osascript ..., or doesn’t it?
The line starting with ffmpeg.exe will only work on Windows (if all requirements are met), .exe are Windows executables. (If you want to clip with ffmpeg on macOS name and/or path to it needs to be modified).

The two .scpt files in the mentioned .zip file are not empty (15-17 Kb). If you’ve opened it in Script Editor you might need to resize the Description part of the window or choose View->Hide Description to see the lines.

Viewing 10 posts - 1 through 10 (of 14 total)

You must be logged in to reply to this topic.