This is version 2.0 of previously named "StreamCopy" worklow
Updated commands to send file to iina-cli as stdin. Also uses IINA's own youtube-dl binary.
This workflow takes a valid video URL from the clipboard, plays it in IINA, and writes the video file to disk.
Uses applescript to run commands with iTerm2.
Provides a dialog for the user to select video quality (the user enters the youtube-dl format code which get sent back into the script)
NOTE: When selecting video quality enter ONLY the format integer value, not the whole string listed. See screenshot of dialog below
Writes to folder ~/Movies (modify the script to save anywhere you please)
Requirements: IINA.app, iTerm2 (installed with homebrew)
Issues: The workflow creates a pipe between ffmpeg and mpv. Closing the window before the download has finished will result in a broken pipe i.e. when streaming an hls playlist. This results in ffmpeg not writing the trailer for the mp4 file correctly. The file will still plays in apps like IINA or MPV with no issue. However, Quicktime player will not recognize the file. Nor will Quicklook.
Solution 1: I have resorted to re-encoding these files with ffmpeg. Then Quicktime and Quicklook will have no issues playing file
Solution 2: Use ffmpeg's built in streaming protocol zmq to stream to a server on localhost then play the file with ffplay. Basic command for this looks somethting like:
ffmpeg -re -i input.m3u8 -c:v libx264 -c:a aac -f tee -map 0:v -map 0:a "output.mp4|[f=mpegts]zmq:tcp://127.0.0.1:5555"
Caveat: Neither IINA nor MPV seem to use the zmq protocol so using this method, one is stuck with using ffplay