Many music videos on youtube are just a static frame and several hours long. I wrote a simple script to automatically extract the frame, remux without video track and attach the frame as an attachment. In the future I will implement detecting and croppng black bars, and better heuristics for auto-detecting whether a video really is static. eg sampling every minute or so and running SSIM on each frame.
@echo off
set "mkvdir=C:\Program Files\MKvToolNix"
FOR %%M IN (*.mkv) DO (
ffmpeg -y -v 0 -i "%%M" -ss 00:00:00 -frames:v 1 "%TEMP%\%%~nM.png" > NUL
truepng /omax /quiet "%TEMP%\%%~nM.png"
"%mkvdir%\mkvmerge.exe" --no-video --no-track-tags --no-global-tags --attach-file "%TEMP%\%%~nM.png" -o "%%~dpnM.mka" "%%M"
IF EXIST "%%~dpnM.mka" (del "%%M")
)
pause
Yes it's written in batch. I don't know bash or powershell. results in test cases when I've done this manually are a 500+ MB file can be reduced to the size of the audio track, usually like 50 - 70 mb for an hour or two. Uses truepng for the image optimization, you can repalce that with pngout, optipng, zopflipng, whatever.. No tools are used to losslessly optimize the audio, as the results for AAC and opus have been poor in the past.