Media clip using script
Up one level
Media clip using script
I have ffmpeg (16537) installed on my Dell laptop running Windows 7. I modified the clip-media.txt file in the Elan folder thusly:
"C:\Program Files (x86)\FFmpeg\win32-static\bin\ffmpeg.exe" -sameq -ss $begin(sec.ms) -t "$duration(sec.ms)" -i $in_file $out_file
Yet when I open Elan and highlight a selection of the media and choose "File > Export As > Media Clip Using Script" nothing happens. No pop-up windows, no error messages, nothing. I have tried many minor edits to the clip-media.txt file as well as different attempts at installing ffmpeg (I tried installing it using the WinFF GUI but that didn't work with Elan either, though it worked independently). What am I doing wrong?
Thanks,
TG
Re: Media clip using script
Yes, error reporting and providing feedback to the user has to be improved, here and in other places. One problem we ran into was that different programs that can be executed this way behave quite differently in how they report back to ELAN.
Another consideration was that we want to be able to use this script to create clips for all annotations on a certain tier, maybe in multiple files. In that scenario one might want to have a "silent" mode and a "pop up messages" mode. All not implemented yet.
Anyway, there might be some information in the log file. After trying to export a clip with the script, exit ELAN and go to \Users\<login_name>\.elan_data and locate the most recent elan(n).log. Can be opened in a text editor, maybe there are some error messages from ffmpeg?
Did you try to run ffmpeg from the command line, by copy/pasting "C:\Program Files (x86)\FFmpeg\win32-static\bin\ffmpeg.exe" in the Command Prompt window (in order to check if it works that way)?
-Han
Re: Re: Media clip using script
Thanks for the suggestions. FFmpeg does run from the DOS command line prompt. I have identified what I think may be causing the problem, but I still can't quite solve it.
After looking at the original log file, I saw that the error message was "Unable to find a suitable output format for <filename>" which I surmised was due to my using .mts files. Indeed I got the same error message when using FFmpeg through the command line directly.
I was able to solve the problem at the DOS prompt by getting rid of the -sameq switch and forcing the format of the output to be .mov. This command worked just fine at the DOS prompt:
"C:\Program Files (x86)\WinFF\ffmpeg.exe" -ss 0:02:00 -t 0:00:30 -i "C:\Users\myoldfile.mts" -f mov "C:\Users\mynewfile.mov"
And the resulting .mov file played without difficulty.
However, when I edited the clip-media.txt file to this:
"C:\Program Files (x86)\WinFF\ffmpeg.exe" -ss $begin(sec.ms) -t "$duration(sec.ms)" -i $in_file -f mov $out_file
Elan produced a file with the filename:
myoldfile_103310_104485.mts
But this file is corrupt and will not play (even if I change the extension to .mov)
So some progress, but still no solution. Here is the relevant part of the log file after this command:
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: FFmpeg version SVN-r18709, Copyright (c) 2000-2009 Fabrice Bellard, et al.
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: configuration: --enable-memalign-hack --prefix=/mingw --cross-prefix=i686-mingw32- --cc=ccache-i686-mingw32-gcc --target-os=mingw32 --arch=i686 --cpu=i686 --enable-avisynth --enable-gpl --enable-zlib --enable-bzlib --enable-libgsm --enable-libfaac --enable-libfaad --enable-pthreads --enable-libvorbis --enable-libtheora --enable-libspeex --enable-libmp3lame --enable-libopenjpeg --enable-libxvid --enable-libschroedinger --enable-libx264
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: libavutil 50. 3. 0 / 50. 3. 0
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: libavcodec 52.27. 0 / 52.27. 0
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: libavformat 52.32. 0 / 52.32. 0
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: libavdevice 52. 2. 0 / 52. 2. 0
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: libswscale 0. 7. 1 / 0. 7. 1
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: built on Apr 28 2009 04:04:42, gcc: 4.2.4
Jan 21, 2011 3:25:16 PM mpi.eudico.server.corpora.clomimpl.dobes.EAF27Encoder save
INFO: C:\Users\Teresa\Documents\Linguistics\RC.data\test1.eaf.001 <----XML output
Jan 21, 2011 3:25:16 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Input #0, mpegts, from 'C:\Users\Teresa\Documents\Linguistics\RC.data\test.mts':
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Duration: 01:17:04.12, start: 599.966700, bitrate: 12974 kb/s
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Program 1
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Stream #0.0[0x1011]: Video: h264, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], 59.94 tbr, 90k tbn, 59.94 tbc
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Stream #0.1[0x1100]: Audio: ac3, 48000 Hz, 5.1, s16, 384 kb/s
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Output #0, mov, to 'C:\Users\Teresa\Documents\Linguistics\RC.data\test_103310_104485.mts':
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Stream #0.0: Video: mpeg4, yuv420p, 1920x1080 [PAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 60k tbn, 59.94 tbc
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Stream #0.1: Audio: libfaac, 48000 Hz, 5.1, s16, 64 kb/s
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Stream mapping:
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Stream #0.0 -> #0.0
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Stream #0.1 -> #0.1
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Press [q] to stop encoding
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 13 referenced in buffering period
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]B picture before any references, skipping
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]decode_slice_header error
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]no frame!
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Error while decoding stream #0.0
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 14 referenced in buffering period
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]B picture before any references, skipping
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]decode_slice_header error
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]no frame!
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Error while decoding stream #0.0
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 3 referenced in buffering period
Jan 21, 2011 3:25:17 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]B picture before any references, skipping
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]decode_slice_header error
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]no frame!
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Error while decoding stream #0.0
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 3 referenced in buffering period
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]B picture before any references, skipping
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]decode_slice_header error
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]no frame!
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Error while decoding stream #0.0
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 3 referenced in buffering period
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]number of reference frames exceeds max (probably corrupt input), discarding one
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: Last message repeated 130 times
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]reference picture missing during reorder
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]Missing reference picture
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 3 referenced in buffering period
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 4 referenced in buffering period
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 4 referenced in buffering period
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 4 referenced in buffering period
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:18 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 4 referenced in buffering period
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 5 referenced in buffering period
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 5 referenced in buffering period
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 5 referenced in buffering period
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 5 referenced in buffering period
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 6 referenced in buffering period
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing SPS 6 referenced in buffering period
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: [h264 @ 0x1482550]non-existing PPS referenced
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: frame= 5 fps= 0 q=4.4 size= 4kB time=0.21 bitrate= 159.6kbits/s
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: frame= 16 fps= 12 q=30.3 size= 81kB time=0.60 bitrate=1116.3kbits/s
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: frame= 28 fps= 16 q=31.0 size= 378kB time=0.98 bitrate=3154.4kbits/s
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: frame= 35 fps= 17 q=31.0 Lsize= 472kB time=1.22 bitrate=3182.8kbits/s
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO:
Jan 21, 2011 3:25:19 PM mpi.eudico.client.annotator.commands.ClipMediaCommand$ReaderThread run
INFO: video:443kB audio:28kB global headers:0kB muxing overhead 0.469556%
Jan 21, 2011 3:26:16 PM mpi.eudico.server.corpora.clomimpl.dobes.EAF27Encoder save
INFO: C:\Users\Teresa\Documents\Linguistics\RC.data\test1.eaf.001 <----XML output
Jan 21, 2011 3:27:07 PM mpi.eudico.client.annotator.prefs.PreferencesWriter encodeAndSave
INFO: Writing preferences: ///C:/Users/Teresa/Documents/Linguistics/RC.data/test1.pfsx
Jan 21, 2011 3:27:07 PM mpi.eudico.client.annotator.prefs.PreferencesWriter encodeAndSave
INFO: Writing preferences: C:\Users\Teresa\.elan_data\elan.pfsx
Clean up media player...
Jan 21, 2011 3:27:09 PM mpi.eudico.client.annotator.prefs.PreferencesWriter encodeAndSave
INFO: Writing preferences: C:\Users\Teresa\.elan_data\elan.pfsx
Jan 21, 2011 3:27:09 PM mpi.eudico.client.annotator.integration.ExternalLauncher stop
INFO: External launch thread stopped...
Jan 21, 2011 3:27:09 PM mpi.eudico.client.annotator.integration.ExternalLauncher$LaunchThread run
INFO: Launch thread interrupted...
Re: Re: Re: Media clip using script
That is strange. I don't think that the fact that the file extension doesn't match the actual type of the file is a problem. At least, when I tried with your syntax (-f mov) to extract a clip from an mpeg1 file (I don't have a mts around) it just seems to work fine from within ELAN.
Did you try longer segments as well? Your example seems rather short and maybe with some file types/encodings that can be a problem? I'm just guessing...
-Han