ekisu / mpv-webm

Simple WebM maker for mpv, with no external dependencies.
MIT License
571 stars 33 forks source link

Feature request: skip encoding #8

Closed robertgzr closed 6 years ago

robertgzr commented 6 years ago

I know it doesn't really fit with the script's tagline/name but I would love an option to just slice the video without doing any encoding. Your UI is just way better than mpv_slicing

ekisu commented 6 years ago

I've looked into mpv_slicing, and I think you can get the same results by setting the same/similar video/audio codec (raw) and output format. I'll try it out to see if it works.

Note that "true" slicing (as in, the output has the same contents and codec as the input, without reencoding) isn't possible, as mpv can't copy streams (and even if it was possible, it usually has some weird results).

robertgzr commented 6 years ago

So it's not possible to basically do ffmpeg -i <input> -ss <start-time> -to <end-time> -c copy <output> via your script?

I thought you were using the ffmpeg that comes with mpv?

ekisu commented 6 years ago

So it's not possible to basically do ffmpeg -i <input> -ss <start-time> -to <end-time> -c copy <output> via your script?

Exactly. My script uses mpv's encoding capabilities (similar to how the old mencoder worked, with mplayer), so as to avoid a hard dependency on the ffmpeg binary. Although it supports quite a lot of ffmpeg features, stream copying (the -c copy in the command line) isn't supported as of now.

robertgzr commented 6 years ago

@ElegantMonkey thanks for explaining.

So is this something that could be requested upstream, because:

mpv can't copy streams (and even if it was possible, it usually has some weird results).

robertgzr commented 6 years ago

Doesn't look like there's much interest there https://github.com/mpv-player/mpv/issues/728 :(

ekisu commented 6 years ago

The stream copy support could indeed be requested upstream, but, as I said, even when using ffmpeg, slicing with -c:v copy has weird results.

If you happen to choose your start time in a non-keyframe, the video will be blank until the next one starts (at least for me, when I tried this with HEVC). The only way to ensure your output is "perfect" is by reencoding (even if there's a potential quality loss).

Doesn't look like there's much interest there

and nothing of value was lost just kidding.

I'm working on multiple format support - webm, gif (encode logic is way too different), etc - and "raw video" will probably be one of the formats. Although this is a bit off the original scope, but whatever.

ekisu commented 6 years ago

Commit 17a0a75 has the raw video support, see if it suits you.

robertgzr commented 6 years ago

@ElegantMonkey nice. Raw is about 4x the speed I get with either of the webm options and it looks way better. I might be doing something wrong here but I always get compression artifacts on the output with them.

ekisu commented 6 years ago

with them

"Them", the WebM codecs, or the Raw codec? If it's the WebM ones, it's normal, as reencoding and using a single-pass process (as 2-pass is currently broken) degrade quality quite a bit.

robertgzr commented 6 years ago

Yeah the webm codecs. Raw is fine

ekisu commented 6 years ago

I see. I'm closing this issue then, as everything seems to be solved.