Stream Copy

An Alfred Workflow


Short Description

Stream a URL video to MPV and write video file to disk simultaneously

Last Updated

08 Dec 2021

Compatibility

Yosemite
(10.10)
Mavericks
(10.9)
Mountain Lion
(10.8)
Lion
(10.7)
Snow Leopard
(10.6)
Yes No No No No
 

Version

1.0
 

Bundle ID

com.strassell.streamcopy
 

Categories

Applications

StreamCopy Alfred Workflow

Takes a valid video URL from the clipboard (mp4, hls, etc.), plays the video using MPV and writes a video file to disk.

-Uses applescriipting to run commands with iTerm2

-Provides popup user interface to select video quality

-Writes to folder ~/Movies

Requirements:

youtube-dl, ffmpeg, mpv, 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 from an hls playlist. This results in ffmpeg not writing the trailer for the mp4 file correctly. The file still plays in apps like IINA or MPV but Quicktime player does not recognize the format. Nor does Quicklook.

Solution 1: re-encode the video file with ffmpeg. Then Quicktime and Quicklook will have no issues playing file

Solution 2: Use ffmpeg built in streaming protocol zmq to stream to server on localhost then play 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"

then

ffplay zmq:tcp://127.0.0.1:5555

To Do: Incorporate above strategy into project as alternative method.