Closed borkfomb closed 3 months ago
mpv requires at least that portion of the cache being filled to write it to disk, so I don't really see a way around this. As far as I can remember at the moment the script only has additional cache checks in the case of chapter writes and this is required due to the way cache dumping works, so I'm not sure what I could do in the more general case or if it's a problem with the script; or maybe I'm not understanding the request.
I think if a reasonable limit on the cache is set with --demuxer-max-bytes
and --demuxer-max-back-bytes
then --cache=yes
shouldn't fill the entire cache with large local files and it'll still allow you to write small clips (as long as that portion is copied to memory) so it shouldn't be too much of an issue, but I agree it doesn't seem to be entirely ideal.
Thanks for the quick reply. I guess it's beyond mpv, upon checking the other clipping scripts it seems all of them do pass the job to ffmpeg.
https://github.com/aerobounce/trim.lua/blob/master/trim.lua#L390 https://github.com/citrus-lemon/mpv-export-clip/blob/master/export_clip.lua#L42
Yeah, I'm kinda surprised how well mpv's cache dumping works already with local files even though it was never meant for that. I do wonder how many people actually use this script to clip local stuff given that it was written primarily to save online streams already loaded in memory; I get the sense that a decent fraction do since a lot of the recent changes I've added to the script have been fixes dealing with cases resulting from working with local files.
I've used it myself to quickly clip local files from time to time and found it pretty fast and convenient, but it's definitely limited as it requires turning on the cache, is prone to errors, and ultimately feels hacky; I'm not sure how I could improve it outside of hooking into ffmpeg as you mentioned and having external dependencies.
mpv does have an encoding mode, maybe there's a way to get that to copy
losslessly, but something tells me that'll be really hacky itself and not a fruitful avenue to pursue.
Ideally it would function like clipping with ffmpeg.
ffmpeg -ss $a -to $b -i input.mkv -c copy output.mkv
I modified took tons of tinkering (encode or trim...not quite sure of name) to just trim audio / video clips with ffmpeg. Works great of course 1 or 2 seconds off / keyframe. I also use videoclip and webm but requires encoding.
I just put in input.conf
F2 script-binding videoclip-menu-open #! [Video] > [Editing] > Videoclip F3 script-binding display-webm-encoder #! [Video] > [Editing] > Webm F4 script-binding set-timestamp #! [Video] > [Editing] > Trimclip copy
attached is the Trimclip (encode.lua) encode.lua.zip
Hi, would you consider a check for local files so streamsave can write clips regardless of the cache? As it stands, dumping longer clips of local files is cumbersome since the cache must be filled, and then checked before writing.
Ideally it would function like clipping with ffmpeg.
ffmpeg -ss $a -to $b -i input.mkv -c copy output.mkv
I've tested the other clipping scripts for mpv but they're inferior and have bizarre defaults. I understand if this is beyond scope, however it really would make streamsave the complete solution for clipping within mpv. Thank you