Tdarr_Plugins icon indicating copy to clipboard operation
Tdarr_Plugins copied to clipboard

[Plugin Request] Only Keep Highest Quality Video Stream

Open AbbieDoobie opened this issue 1 year ago • 3 comments

I'd like to request a plugin which can handle removing extraneous Video Streams.

Could someone build a plugin that deletes all but the highest quality video stream, WITH one important configuration option: "Keep video streams with different titles"

Sometimes an MKV will have multiple video streams, but this is specifically to allow inbuilt editions, or visual commentary pointers. In those cases, the stream will (hopefully) be named/titled as such. Hence the option to keep streams with different titles.

So when... True: keep the highest quality version per named stream. EX: file has two video streams with no name (undefined), and a video stream with Commentary for the name. The highest quality undefined stream will be kept, along with the commentary stream. False: keep the highest quality video stream, regardless of naming. EX: for the above example, instead the only stream kept would be whichever was highest quality.

AbbieDoobie avatar Aug 01 '23 01:08 AbbieDoobie

Here you go

Unzip and add to local no inputs needed

Simple logic

  1. Aborts if file medium is not Video line 97
  2. Aborts if only one video stream exists line 112
  3. Loops over video stream
  4. Removes video stream that are NOT first and have no title tag line 132

FFmpeg argument
general '-map 0 -c copy -max_muxing_queue_size 9999' add if removing -map -0:v:${id}

File is largely untested and should be used at your own risk Feel free to modify and use as needed

Tdarr_Plugin_tws101_Video_Stream_Remove.zip

tws101 avatar Aug 10 '23 21:08 tws101

and I did miss something a comma Preset ' -map 0 -c copy -max_muxing_queue_size 9999 ' Needs to be ' , -map 0 -c copy -max_muxing_queue_size 9999 '

needs that comma

tws101 avatar Aug 24 '23 22:08 tws101

Hello, thank you very much for the plugin, it did appear to work (I did make that adjustment).

Updated copy, for anyone who sees this: Tdarr_Plugin_tws101_Video_Stream_Remove.zip

Would it be possible to change this to not just go by first video stream, but instead highest quality? I don't mean to be a choosing beggar, but I had a couple files with dual streams and:

  1. The test file with two NAMED streams retained both. So the "video commentary" was retained.
  2. The test file with two unnamed streams retained the top one, but in this case the top one was lower quality.

I realize that's a hell of a corner case (two video streams, and they are in the 'wrong' order), but if possible I think it would be better to analyze resolution and/or encoder and keep only the highest quality.

AbbieDoobie avatar Sep 28 '23 21:09 AbbieDoobie