flomacbook:~ flo$ #!/bin/bashflomacbook:~ flo$ #set -vx
flomacbook:~ flo$
flomacbook:~ flo$ [[ "$1" = "-h" ]] && echo "Syntax: ${0##*/} [-t]" && exit 1
flomacbook:~ flo$
flomacbook:~ flo$
flomacbook:~ flo$ theLength=2; #in seconds
flomacbook:~ flo$ theResolution=425; #x in pixels (y=auto aspect ratio)
flomacbook:~ flo$ theFrameRate=14; #frames per second
flomacbook:~ flo$
flomacbook:~ flo$
flomacbook:~ flo$ thePath=$(osascript -e 'tell app "VLC" to get path of current item');
flomacbook:~ flo$ thePos=$(osascript -e 'tell app "VLC" to get current time');
flomacbook:~ flo$ echo $SECONDS
154
flomacbook:~ flo$ [[ "$thePath" ]] && echo -e "$thePath:$thePos\n" && tmpdir=$(mktemp -d -t "${0##*/}") && \
> echo $SECONDS
/Users/flo/Downloads/111.mp4:1003
154
flomacbook:~ flo$ /usr/local/bin/ffmpeg -threads 4 -i "$thePath" -ss "$thePos" -t "$theLength" -r "$theFrameRate" -vf scale="$theResolution":-1 -f image2 "$tmpdir"/%03d.png && \
> echo $SECONDS
ffmpeg version 2.3.2 Copyright (c) 2000-2014 the FFmpeg developers
built on Aug 22 2014 13:45:20 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.2 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
libavutil 52. 92.100 / 52. 92.100
libavcodec 55. 69.100 / 55. 69.100
libavformat 55. 48.100 / 55. 48.100
libavdevice 55. 13.102 / 55. 13.102
libavfilter 4. 11.100 / 4. 11.100
libavresample 1. 3. 0 / 1. 3. 0
libswscale 2. 6.100 / 2. 6.100
libswresample 0. 19.100 / 0. 19.100
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/flo/Downloads/111.mp4':
Metadata:
major_brand : M4V
minor_version : 1
compatible_brands: M4V mp42isom
creation_time : 2014-07-18 03:37:18
track : 0
artist :
album :
comment :
date : 0
genre :
Duration: 00:18:39.34, start: 0.000000, bitrate: 4090 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1280x720 [SAR 1:1 DAR 16:9], 3888 kb/s, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2014-07-18 03:37:18
handler_name : Mainconcept MP4 Video Media Handler
encoder : AVC Coding
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 189 kb/s (default)
Metadata:
creation_time : 2014-07-18 03:37:18
handler_name : Mainconcept MP4 Sound Media Handler
Output #0, image2, to '/var/folders/94/hksvplw93znd7kcgts43cyq80000gn/T/-bash.DqYsOwdI/%03d.png':
Metadata:
major_brand : M4V
minor_version : 1
compatible_brands: M4V mp42isom
genre :
track : 0
artist :
album :
comment :
date : 0
encoder : Lavf55.48.100
Stream #0:0(eng): Video: png, rgb24, 425x239 [SAR 3824:3825 DAR 16:9], q=2-31, 200 kb/s, 14 fps, 14 tbn, 14 tbc (default)
Metadata:
creation_time : 2014-07-18 03:37:18
handler_name : Mainconcept MP4 Video Media Handler
encoder : Lavc55.69.100 png
Stream mapping:
Stream #0:0 -> #0:0 (h264 (native) -> png (native))
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A
Enter command: <target>|all <time>|-1 <command>[ <argument>]
Parse error, at least 3 arguments were expected, only 1 given in string 'k/bin/convert -delay 1x"$theFrameRate" "$tmpdir"/*.png -coalesce -layers OptimizeTransparency "${thePath%.*}${thePos%.*}.gif" || \'
frame= 0 fps=0.0 q=0.0 size=N/A time=00:00:00.00 bitrate=N/A
Enter command: <target>|all <time>|-1 <command>[ <argument>]
Parse error, at least 3 arguments were expected, only 1 given in string 'ho "VLC: No file open." && exit 2; }'
error parsing debug value size=N/A time=00:00:00.00 bitrate=N/A
debug=0
[FONT=Menlo]1004[/FONT]