occivink / mpv-scripts

Various scripts for mpv
The Unlicense
420 stars 38 forks source link

Best practice for adding in custom commands? #16

Closed joeynotjoe closed 6 years ago

joeynotjoe commented 6 years ago

Hello, I have been modifying encode.lua in an effort to include some custom commands before the encode command, such as running Noti. I have been successful in getting that one to work by itself, but if I try and add in other commands in the Args section, I run into problems. I don't see much info in the logs, just the line of the command that was run, but no mention of the failures.

Is there a better way to include these types of commands? Maybe a better spot in the code than the args?

This is what I have now, which is indeed working (however, I could not get the timestamp of the encode to work in the -m flag portion, but it did work with -t... but I am also very much an amateur when it comes to Lua)

function start_encoding(input_path, from, to, settings)
    local args = {
        "noti",
        "-t", mp.get_property("filename/no-ext"),
        "-m", '🎥 Your clip is finished encoding.',
        "ffmpeg",
        "-loglevel", "panic", "-hide_banner", --stfu ffmpeg
        "-ss", seconds_to_time_string(from, false),
        "-i", input_path,
        "-to", tostring(to-from),
        }

It would be cool if there was a place in the config, preferably in the profile .conf settings, where you could define any other commands to be run before or after the script. Bonus points if those commands can reference the variables like $t or $s, as that would be super beneficial.

Thanks so much for your invaluable script!

occivink commented 6 years ago

At a glance, I think your snippet should be working, I'll try to see why it wouldn't.

Regarding the extensibility suggestion, we could make the ffmpeg command configurable. Let's say we create the following simple shell script encode.sh:

#!/bin/sh
ffmpeg "$@"
noti

we'd set ffmpeg_command=/path/to/encode.sh in encode.conf and enjoy notifications when encoding without touching any lua. Unfortunately, with this approach you can't use the builtin variables. But at least it's simple and adresses some use-cases. It's also not very flexible since the script just gets the ffmpeg arguments as-is, but if your needs are more elaborate, you're probably better serviced by modifying the script directly.

joeynotjoe commented 6 years ago

Sorry, my original message wasn't clear. The snippet I shared above is indeed working, but if I try and add in more commands or parameters, it fails. For instance, I was trying to use terminal-notifier to generate a more rich notification than what Noti offers. When I try and cut a clip, it shows the notification properly, but the clip doesn't encode. Here is my snippet for this code that's failing:

    local args = {
        "terminal-notifier",
        "-title", 'IINA',
        "-message", 'Encoding Complete',
        "-subtitle", mp.get_property("filename/no-ext"),
        "-appIcon", 'https://cl.ly/rZzd/iina.png',
        "ffmpeg",
        "-loglevel", "panic", "-hide_banner", --stfu ffmpeg
        "-ss", seconds_to_time_string(from, false),
        "-i", input_path,
        "-to", tostring(to-from),
        }
Here is the successful notification: ![successful notification](https://cl.ly/rZSb/Image%202018-05-15%20at%2010.23.18%20AM.png) It would be great if I could get the from/to timestamps in the `-message` paramter for `terminal-notifier`, but I'm not sure how to include those.
Partial Log: ``` [ 0.686][d][cplayer] Run command: list, flags=0, args=[] [ 0.686][d][cplayer] Run command: run, flags=9, args=[sh, -c, IFS='';printf '${time-pos} - ' >> ~/Movies/Times/"${filename}".times] [ 0.687][d][cplayer] Run command: script-message-to, flags=9, args=[encode, set-timestamp, encode_slice] [ 0.687][d][cplayer] Run command: show-text, flags=0, args=[Encode [encode_slice]: waiting for end timestamp (press ESC to cancel), 2000, 0] [ 0.687][d][cplayer] Run command: define-section, flags=0, args=[input_encode, , default] [ 0.687][d][cplayer] Run command: enable-section, flags=0, args=[input_encode, allow-hide-cursor+allow-vo-dragging] [ 0.687][d][input] enable section 'input_encode' [ 0.687][d][input] active section stack: [ 0.687][d][input] default 12 [ 0.687][d][input] input_stats 12 [ 0.687][d][input] input_forced_stats 12 [ 0.687][d][input] input_slicing_h265 12 [ 0.687][d][input] input_forced_slicing_h265 12 [ 0.687][d][input] input_mpv_gif 12 [ 0.687][d][input] input_forced_mpv_gif 12 [ 0.687][d][input] input_seek_to 12 [ 0.687][d][input] input_forced_seek_to 12 [ 0.687][d][global] config path: 'fonts' -/-> '/Users/joeynotjoe/Cloud/Dropbox/Config/iina/fonts' [ 0.687][d][input] input_slicing 12 [ 0.687][d][input] input_forced_slicing 12 [ 0.687][d][input] input_slicing_raw 12 [ 0.687][d][input] input_forced_slicing_raw 12 [ 0.687][d][input] input_slicing_prores_ks 12 [ 0.687][d][input] input_forced_slicing_prores_ks 12 [ 0.687][d][input] input_misc 12 [ 0.687][d][input] input_forced_misc 12 [ 0.687][d][input] input_slicing_h264 12 [ 0.687][d][input] input_forced_slicing_h264 12 [ 0.687][d][input] input_forced_encode 12 [ 0.687][d][input] input_slicing_4k_hdr 12 [ 0.687][d][input] input_forced_slicing_4k_hdr 12 [ 0.687][v][osd/libass] Shaper: FriBidi 1.0.2 (SIMPLE) HarfBuzz-ng 1.7.6 (COMPLEX) [ 0.687][d][input] input_encode 12 [ 0.687][d][global] config path: 'subfont.ttf' -/-> '/Users/joeynotjoe/Cloud/Dropbox/Config/iina/subfont.ttf' [ 0.687][d][global] config path: 'fonts.conf' -/-> '/Users/joeynotjoe/Cloud/Dropbox/Config/iina/fonts.conf' [ 0.687][v][osd/libass] Setting up fonts... [ 0.688][d][cplayer] Run command: define-section, flags=0, args=[input_forced_encode, ESC script-binding encode/encode-ESC [ 0.688][d][cplayer] , force] [ 0.688][d][input] add: section='input_forced_encode' key='ESC' cmd='script-binding encode/encode-ESC' location=':1' [ 0.688][d][cplayer] Run command: enable-section, flags=0, args=[input_forced_encode, allow-hide-cursor+allow-vo-dragging] [ 0.688][d][input] enable section 'input_forced_encode' [ 0.688][d][input] active section stack: [ 0.688][d][input] default 12 [ 0.688][d][input] input_stats 12 [ 0.688][d][input] input_forced_stats 12 [ 0.688][d][input] input_slicing_h265 12 [ 0.688][d][input] input_forced_slicing_h265 12 [ 0.688][d][input] input_mpv_gif 12 [ 0.688][d][input] input_forced_mpv_gif 12 [ 0.688][d][input] input_seek_to 12 [ 0.688][d][input] input_forced_seek_to 12 [ 0.688][d][input] input_slicing 12 [ 0.688][d][input] input_forced_slicing 12 [ 0.688][d][input] input_slicing_raw 12 [ 0.688][d][input] input_forced_slicing_raw 12 [ 0.688][d][input] input_slicing_prores_ks 12 [ 0.688][d][input] input_forced_slicing_prores_ks 12 [ 0.688][d][input] input_misc 12 [ 0.688][d][input] input_forced_misc 12 [ 0.688][d][input] input_slicing_h264 12 [ 0.688][d][input] input_forced_slicing_h264 12 [ 0.688][d][input] input_slicing_4k_hdr 12 [ 0.688][d][input] input_forced_slicing_4k_hdr 12 [ 0.688][d][input] input_encode 12 [ 0.688][d][input] input_forced_encode 12 [ 0.688][d][cplayer] Run command: define-section, flags=0, args=[input_encode, , default] [ 0.688][d][cplayer] Run command: enable-section, flags=0, args=[input_encode, allow-hide-cursor+allow-vo-dragging] [ 0.688][d][input] enable section 'input_encode' [ 0.688][d][input] active section stack: [ 0.688][d][input] default 12 [ 0.688][d][input] input_stats 12 [ 0.688][d][input] input_forced_stats 12 [ 0.688][d][input] input_slicing_h265 12 [ 0.688][d][input] input_forced_slicing_h265 12 [ 0.688][d][input] input_mpv_gif 12 [ 0.688][d][input] input_forced_mpv_gif 12 [ 0.688][d][input] input_seek_to 12 [ 0.688][d][input] input_forced_seek_to 12 [ 0.688][d][input] input_slicing 12 [ 0.688][d][input] input_forced_slicing 12 [ 0.688][d][input] input_slicing_raw 12 [ 0.688][d][input] input_forced_slicing_raw 12 [ 0.688][d][input] input_slicing_prores_ks 12 [ 0.688][d][input] input_forced_slicing_prores_ks 12 [ 0.688][d][input] input_misc 12 [ 0.688][d][input] input_forced_misc 12 [ 0.688][d][input] input_slicing_h264 12 [ 0.688][d][input] input_forced_slicing_h264 12 [ 0.688][d][input] input_slicing_4k_hdr 12 [ 0.688][d][input] input_forced_slicing_4k_hdr 12 [ 0.688][d][input] input_forced_encode 12 [ 0.688][d][input] input_encode 12 [ 0.688][d][cplayer] Run command: define-section, flags=0, args=[input_forced_encode, ESC script-binding encode/encode-ESC [ 0.688][d][cplayer] ENTER script-binding encode/encode-ENTER [ 0.688][d][cplayer] , force] [ 0.688][d][input] add: section='input_forced_encode' key='ESC' cmd='script-binding encode/encode-ESC' location=':1' [ 0.688][d][input] add: section='input_forced_encode' key='ENTER' cmd='script-binding encode/encode-ENTER' location=':2' [ 0.688][d][cplayer] Run command: enable-section, flags=0, args=[input_forced_encode, allow-hide-cursor+allow-vo-dragging] [ 0.688][d][input] enable section 'input_forced_encode' [ 0.688][d][input] active section stack: [ 0.688][d][input] default 12 [ 0.688][d][input] input_stats 12 [ 0.688][d][input] input_forced_stats 12 [ 0.688][d][input] input_slicing_h265 12 [ 0.688][d][input] input_forced_slicing_h265 12 [ 0.688][d][input] input_mpv_gif 12 [ 0.688][d][input] input_forced_mpv_gif 12 [ 0.688][d][input] input_seek_to 12 [ 0.688][d][input] input_forced_seek_to 12 [ 0.688][d][input] input_slicing 12 [ 0.688][d][input] input_forced_slicing 12 [ 0.688][d][input] input_slicing_raw 12 [ 0.688][d][input] input_forced_slicing_raw 12 [ 0.688][d][input] input_slicing_prores_ks 12 [ 0.688][d][input] input_forced_slicing_prores_ks 12 [ 0.688][d][input] input_misc 12 [ 0.688][d][input] input_forced_misc 12 [ 0.688][d][input] input_slicing_h264 12 [ 0.688][d][input] input_forced_slicing_h264 12 [ 0.688][d][input] input_slicing_4k_hdr 12 [ 0.688][d][input] input_forced_slicing_4k_hdr 12 [ 0.688][d][input] input_encode 12 [ 0.688][d][input] input_forced_encode 12 [ 0.690][v][osd/libass] Using font provider coretext [ 0.690][v][osd/libass] Done. [ 0.701][v][osd/libass] fontselect: (Source Sans Pro, 400, 0) -> /Users/joeynotjoe/Library/Fonts/SourceSansPro-Regular.otf, -1, SourceSansPro-Regular [ 0.703][v][opengl-cb] Reallocating OSD texture to 2048x256. [ 0.704][d][opengl-cb] vertex shader source: [ 0.704][d][opengl-cb] [ 1] #version 410 [ 0.704][d][opengl-cb] [ 2] #define tex1D texture [ 0.704][d][opengl-cb] [ 3] #define tex3D texture [ 0.704][d][opengl-cb] [ 4] #define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x)) [ 0.704][d][opengl-cb] [ 5] in vec2 vertex_position; [ 0.704][d][opengl-cb] [ 6] in vec2 vertex_texcoord; [ 0.704][d][opengl-cb] [ 7] out vec2 texcoord; [ 0.704][d][opengl-cb] [ 8] in vec4 vertex_ass_color; [ 0.704][d][opengl-cb] [ 9] out vec4 ass_color; [ 0.704][d][opengl-cb] [ 10] void main() { [ 0.704][d][opengl-cb] [ 11] gl_Position = vec4(vertex_position, 1.0, 1.0); [ 0.704][d][opengl-cb] [ 12] texcoord = vertex_texcoord; [ 0.704][d][opengl-cb] [ 13] ass_color = vertex_ass_color; [ 0.704][d][opengl-cb] [ 14] } [ 0.704][d][opengl-cb] fragment shader source: [ 0.704][d][opengl-cb] [ 1] #version 410 [ 0.704][d][opengl-cb] [ 2] #define tex1D texture [ 0.704][d][opengl-cb] [ 3] #define tex3D texture [ 0.704][d][opengl-cb] [ 4] #define LUT_POS(x, lut_size) mix(0.5 / (lut_size), 1.0 - 0.5 / (lut_size), (x)) [ 0.704][d][opengl-cb] [ 5] out vec4 out_color; [ 0.704][d][opengl-cb] [ 6] in vec2 texcoord; [ 0.704][d][opengl-cb] [ 7] in vec4 ass_color; [ 0.704][d][opengl-cb] [ 8] uniform sampler2D osdtex; [ 0.704][d][opengl-cb] [ 9] uniform vec3 src_luma; [ 0.704][d][opengl-cb] [ 10] uniform vec3 dst_luma; [ 0.704][d][opengl-cb] [ 11] void main() { [ 0.704][d][opengl-cb] [ 12] vec4 color = vec4(0.0, 0.0, 0.0, 1.0); [ 0.704][d][opengl-cb] [ 13] color = vec4(ass_color.rgb, ass_color.a * texture(osdtex, texcoord).r); [ 0.704][d][opengl-cb] [ 14] // color mapping [ 0.704][d][opengl-cb] [ 15] out_color = color; [ 0.704][d][opengl-cb] [ 16] } [ 0.705][d][opengl-cb] shader link log (status=1): [ 1.144][d][cplayer] Run command: seek, flags=8, args=[10.000000, exact, unused] [ 1.144][v][mkv] queuing seek to 66.000000 [ 1.144][v][mkv] execute seek (to 66.000000 flags 32) [ 1.145][v][cplayer] hr-seek, skipping to 66.000000 [ 1.147][v][mkv] seek done [ 1.152][v][vd] Pixel formats supported by decoder: videotoolbox_vld yuv420p [ 1.152][v][vd] Codec profile: High (0x64) [ 1.152][v][vd] Requesting pixfmt 'videotoolbox_vld' from decoder. [ 1.159][d][ffmpeg/video] h264: Reinit context to 1280x720, pix_fmt: videotoolbox_vld [ 1.176][v][vd] Decoder format: 1280x720 nv12 bt.709/bt.709/bt.1886/limited CL=mpeg2/4/h264 (auto 0.000000/0.000000/0.000000) [ 1.176][v][vd] Using container aspect ratio. [ 1.180][v][cplayer] first video frame after restart shown [ 1.180][v][cplayer] starting audio playback [ 1.180][v][cplayer] playback restart complete [ 1.640][d][cplayer] Run command: list, flags=0, args=[] [ 1.640][d][cplayer] Run command: run, flags=9, args=[sh, -c, IFS='';printf '${time-pos} [ 1.640][d][cplayer] [ 1.640][d][cplayer] ' >> ~/Movies/Times/"${filename}".times] [ 1.640][d][cplayer] Run command: script-message-to, flags=9, args=[encode, set-timestamp, encode_slice] [ 1.640][d][cplayer] Run command: define-section, flags=0, args=[input_encode, , default] [ 1.641][d][cplayer] Run command: enable-section, flags=0, args=[input_encode, allow-hide-cursor+allow-vo-dragging] [ 1.641][d][input] enable section 'input_encode' [ 1.641][d][input] active section stack: [ 1.641][d][input] default 12 [ 1.641][d][input] input_stats 12 [ 1.641][d][input] input_forced_stats 12 [ 1.641][d][input] input_slicing_h265 12 [ 1.641][d][input] input_forced_slicing_h265 12 [ 1.641][d][input] input_mpv_gif 12 [ 1.641][d][input] input_forced_mpv_gif 12 [ 1.641][d][input] input_seek_to 12 [ 1.641][d][input] input_forced_seek_to 12 [ 1.641][d][input] input_slicing 12 [ 1.641][d][input] input_forced_slicing 12 [ 1.641][d][input] input_slicing_raw 12 [ 1.641][d][input] input_forced_slicing_raw 12 [ 1.641][d][input] input_slicing_prores_ks 12 [ 1.641][d][input] input_forced_slicing_prores_ks 12 [ 1.641][d][input] input_misc 12 [ 1.641][d][input] input_forced_misc 12 [ 1.641][d][input] input_slicing_h264 12 [ 1.641][d][input] input_forced_slicing_h264 12 [ 1.641][d][input] input_slicing_4k_hdr 12 [ 1.641][d][input] input_forced_slicing_4k_hdr 12 [ 1.641][d][input] input_forced_encode 12 [ 1.641][d][input] input_encode 12 [ 1.641][d][cplayer] Run command: define-section, flags=0, args=[input_forced_encode, ENTER script-binding encode/encode-ENTER [ 1.641][d][cplayer] , force] [ 1.641][d][input] add: section='input_forced_encode' key='ENTER' cmd='script-binding encode/encode-ENTER' location=':1' [ 1.641][d][cplayer] Run command: enable-section, flags=0, args=[input_forced_encode, allow-hide-cursor+allow-vo-dragging] [ 1.641][d][input] enable section 'input_forced_encode' [ 1.641][d][input] active section stack: [ 1.641][d][input] default 12 [ 1.641][d][input] input_stats 12 [ 1.641][d][input] input_forced_stats 12 [ 1.641][d][input] input_slicing_h265 12 [ 1.641][d][input] input_forced_slicing_h265 12 [ 1.641][d][input] input_mpv_gif 12 [ 1.641][d][input] input_forced_mpv_gif 12 [ 1.641][d][input] input_seek_to 12 [ 1.641][d][input] input_forced_seek_to 12 [ 1.641][d][input] input_slicing 12 [ 1.641][d][input] input_forced_slicing 12 [ 1.641][d][input] input_slicing_raw 12 [ 1.641][d][input] input_forced_slicing_raw 12 [ 1.641][d][input] input_slicing_prores_ks 12 [ 1.641][d][input] input_forced_slicing_prores_ks 12 [ 1.641][d][input] input_misc 12 [ 1.641][d][input] input_forced_misc 12 [ 1.641][d][input] input_slicing_h264 12 [ 1.641][d][input] input_forced_slicing_h264 12 [ 1.641][d][input] input_slicing_4k_hdr 12 [ 1.641][d][input] input_forced_slicing_4k_hdr 12 [ 1.641][d][input] input_encode 12 [ 1.641][d][input] input_forced_encode 12 [ 1.641][d][cplayer] Run command: define-section, flags=0, args=[input_encode, , default] [ 1.641][d][cplayer] Run command: enable-section, flags=0, args=[input_encode, allow-hide-cursor+allow-vo-dragging] [ 1.641][d][input] enable section 'input_encode' [ 1.641][d][input] active section stack: [ 1.641][d][input] default 12 [ 1.641][d][input] input_stats 12 [ 1.641][d][input] input_forced_stats 12 [ 1.641][d][input] input_slicing_h265 12 [ 1.641][d][input] input_forced_slicing_h265 12 [ 1.641][d][input] input_mpv_gif 12 [ 1.641][d][input] input_forced_mpv_gif 12 [ 1.641][d][input] input_seek_to 12 [ 1.641][d][input] input_forced_seek_to 12 [ 1.641][d][input] input_slicing 12 [ 1.641][d][input] input_forced_slicing 12 [ 1.641][d][input] input_slicing_raw 12 [ 1.641][d][input] input_forced_slicing_raw 12 [ 1.641][d][input] input_slicing_prores_ks 12 [ 1.641][d][input] input_forced_slicing_prores_ks 12 [ 1.641][d][input] input_misc 12 [ 1.641][d][input] input_forced_misc 12 [ 1.641][d][input] input_slicing_h264 12 [ 1.641][d][input] input_forced_slicing_h264 12 [ 1.641][d][input] input_slicing_4k_hdr 12 [ 1.641][d][input] input_forced_slicing_4k_hdr 12 [ 1.641][d][input] input_forced_encode 12 [ 1.641][d][input] input_encode 12 [ 1.641][d][cplayer] Run command: define-section, flags=0, args=[input_forced_encode, , force] [ 1.641][d][cplayer] Run command: enable-section, flags=0, args=[input_forced_encode, allow-hide-cursor+allow-vo-dragging] [ 1.641][d][input] enable section 'input_forced_encode' [ 1.641][d][input] active section stack: [ 1.641][d][input] default 12 [ 1.641][d][input] input_stats 12 [ 1.641][d][input] input_forced_stats 12 [ 1.641][d][input] input_slicing_h265 12 [ 1.641][d][input] input_forced_slicing_h265 12 [ 1.642][d][input] input_mpv_gif 12 [ 1.642][d][input] input_forced_mpv_gif 12 [ 1.642][d][input] input_seek_to 12 [ 1.642][d][input] input_forced_seek_to 12 [ 1.642][d][input] input_slicing 12 [ 1.642][d][input] input_forced_slicing 12 [ 1.642][d][input] input_slicing_raw 12 [ 1.642][d][input] input_forced_slicing_raw 12 [ 1.642][d][input] input_slicing_prores_ks 12 [ 1.642][d][input] input_forced_slicing_prores_ks 12 [ 1.642][d][input] input_misc 12 [ 1.642][d][input] input_forced_misc 12 [ 1.642][d][input] input_slicing_h264 12 [ 1.642][d][input] input_forced_slicing_h264 12 [ 1.642][d][input] input_slicing_4k_hdr 12 [ 1.642][d][input] input_forced_slicing_4k_hdr 12 [ 1.642][d][input] input_encode 12 [ 1.642][d][input] input_forced_encode 12 [ 1.642][d][cplayer] Run command: show-text, flags=0, args=[, 0, 0] [ 1.642][d][cplayer] Run command: show-text, flags=0, args=[Encoding from 00:56.000 to 01:06.000, 2000, 0] [ 1.642][d][encode] reading options for encode_slice [ 1.642][d][global] config path: 'lua-settings/encode_slice.conf' -> '/Users/joeynotjoe/Cloud/Dropbox/Config/iina/lua-settings/encode_slice.conf' [ 1.642][i][encode] terminal-notifier Encoding Complete -subtitle Big Buck Bunny -appIcon https://cl.ly/rZzd/iina.png ffmpeg -loglevel panic -hide_banner -ss 00:56.000 -i "/Users/joeynotjoe/Movies/TV/Big Buck Bunny.mkv" -to 10.020833333333 -map 0 -c copy "/Users/joeynotjoe/Movies/Clips/Big Buck Bunny [RAW] - 0:00:56.000 - 0:01:06.020.mp4" [ 1.943][v][cplayer] Set property: window-scale=1.567187 -> 1 [ 1.943][v][opengl-cb] Window size: 4012x2258 [ 1.943][v][opengl-cb] Video source: 1280x720 (1:1) [ 1.943][v][opengl-cb] Video display: (0, 0) 1280x720 -> (0, 0) 4012x2258 [ 1.943][v][opengl-cb] Video scale: 3.134375/3.136111 [ 1.943][v][opengl-cb] OSD borders: l=0 t=0 r=0 b=0 [ 1.943][v][opengl-cb] Video borders: l=0 t=0 r=0 b=0 [ 2.609][d][cplayer] Run command: show-text, flags=0, args=[Encoding complete., -1, 0] [ 3.697][d][cplayer] Run command: quit, flags=9, args=[0] [ 3.697][d][global] config path: '/Users/joeynotjoe/Library/Application Support/com.colliderli.iina/watch_later' -> '/Users/joeynotjoe/Library/Application Support/com.colliderli.iina/watch_later' [ 3.697][i][cplayer] Saving state. [ 3.699][v][cplayer] EOF code: 6 [ 3.699][v][ad] Uninit audio decoder. [ 3.701][v][vd] Uninit video. [ 3.706][v][cplayer] finished playback, success (reason 3) [ 3.706][i][cplayer] [ 3.706][v][mpv_gif] Exiting... [ 3.706][v][blacklist_extensions] Exiting... ```

The part that confuses me is that I am getting the terminal-notifier message perfectly, but if I check the code from the log, that code is different. I can run the ffmpeg portion in terminal successfully, but I must be missing something. I'm talking about this portion specifically:

terminal-notifier Encoding Complete -subtitle Big Buck Bunny -appIcon https://cl.ly/rZzd/iina.png ffmpeg -loglevel panic -hide_banner -ss 00:56.000 -i "/Users/jmurphy/Movies/TV/Big Buck Bunny.mkv" -to 10.020833333333 -map 0 -c copy "/Users/jmurphy/Movies/Clips/Big Buck Bunny [RAW] - 0:00:56.000 - 0:01:06.020.mp4"

Thanks for looking into this!

occivink commented 6 years ago

That's because terminal-notifier behaves differently from noti. noti treats the trailing arguments (after the ones it recognizes) as a command to run, takes care of running ffmpeg itself and prints the message after the command is finished.

On the other hand, terminal-notifier doesn't do that, and I'm guessing it just ignores anything it doesn't recognize (so all args after your .png) which is why nothing happens. This means that you cannot run both ffmpeg and terminal-notifier in the same subprocess without using a wrapper script.

joeynotjoe commented 6 years ago

🤦‍♂️ That makes a whole lot of sense, haha. So I have to do some research on wrapper scripts!

joeynotjoe commented 6 years ago

Thanks a bunch for adding this!

If you have a super basic example of a wrapper script that could work, that would be really helpful. I'm not sure how to call ffmpeg properly.

If I figure it out, I'll post something here.

occivink commented 6 years ago

Yes actually that's what I mentioned in my first comment. Basically the shell script encode.sh receives the ffmpeg arguments and takes care of calling ffmpeg itself (it simply forwards the arguments using "$@"), followed by a call to noti once ffmpeg returns. A more elaborate version could use the last argument (i.e. the output filepath) in the noti invocation for a more elaborate notification.

You need to make sure that the script is executable, and that ffmpeg_command is set to the full path of the script (or that the script is part of your PATH).

joeynotjoe commented 4 years ago

Hello there @occivink - sorry to jump back into this closed thread, but I figured I might be missing something. If there's a new issue in the code, I can create a new issue.

I was wondering- I'm trying to reference my Home folder in the encode.conf > ffmpeg_command section, and I noticed that I have to put the full path in order for it to work. But just a couple lines up, in the Output directory, I don't need to use the full path - I can use a home directory shortcut, such as ~/. This is beneficial, because I can use the script on other machines without needing the full path of the home folder.

I tried using $HOME, ${HOME}, and ~/ but none of them seem to work. I tried checking the logs, but it just says subprocess failed, init.

Do you have any ideas?

Thanks so much!

Here is my .conf file:

only_active_tracks=no
preserve_filters=no
append_filter=
codec=-c copy
output_format=$f - $s - $e.$x
output_directory=~/Movies/Clips/
detached=yes
ffmpeg_command=/Users/joeynotjoe/Config/shell/encode_raw.sh
print=yes
occivink commented 4 years ago

Yes, that's because I implemented special handling for ~ in output_directory, but not for ffmpeg_command. You could either

joeynotjoe commented 4 years ago

Wow, awesome. Thanks so much for the quick response! I think that implementing the same ~ handling would be ideal, as it would again prevent the need to make any special edits or changes when going from one machine to the next.

Thanks again, Olivier!