nilaoda / N_m3u8DL-RE

Cross-Platform, modern and powerful stream downloader for MPD/M3U8/ISM. English/简体中文/繁體中文.
MIT License
4.26k stars 455 forks source link

Select highest available bitrate for each audio language #97

Closed postmanpaul closed 1 year ago

postmanpaul commented 1 year ago

Hello

I want to automatically include all languages, but only the highest bitrate stream for each one.

For example, with these streams:

19:22:02.097 INFO : Aud *CENC audio_eng=128000 | 128 Kbps | ac-3 | en | A000CH | 1463 Segments | ~01h33m34s
19:22:02.098 INFO : Aud *CENC audio_lit=128000 | 128 Kbps | ac-3 | lt | A000CH | 1463 Segments | ~01h33m34s
19:22:02.099 INFO : Aud *CENC audio_pol_2=128000 | 128 Kbps | ac-3 | pl | A000CH | 1463 Segments | ~01h33m34s
19:22:02.100 INFO : Aud *CENC audio_rus_2=128000 | 128 Kbps | ac-3 | ru | A000CH | 1463 Segments | ~01h33m34s
19:22:02.107 INFO : Aud *CENC audio_eng_2=96000 | 96 Kbps | mp4a.40.2 | en | 2CH | 1463 Segments | ~01h33m34s
19:22:02.108 INFO : Aud *CENC audio_lit_1=96000 | 96 Kbps | mp4a.40.2 | lt | 2CH | 1463 Segments | ~01h33m34s
19:22:02.109 INFO : Aud *CENC audio_pol_1=96000 | 96 Kbps | mp4a.40.2 | pl | 2CH | 1463 Segments | ~01h33m34s
19:22:02.111 INFO : Aud *CENC audio_rus_1=96000 | 96 Kbps | mp4a.40.2 | ru | 2CH | 1463 Segments | ~01h33m34s
19:22:02.112 INFO : Aud *CENC audio_eng_1=96000 | 96 Kbps | ec-3 | en | A000CH | 1463 Segments | ~01h33m34s
19:22:02.113 INFO : Aud *CENC audio_lit_2=96000 | 96 Kbps | ec-3 | lt | A000CH | 1463 Segments | ~01h33m34s
19:22:02.114 INFO : Aud *CENC audio_pol=96000 | 96 Kbps | ec-3 | pl | A000CH | 1463 Segments | ~01h33m34s
19:22:02.115 INFO : Aud *CENC audio_rus=96000 | 96 Kbps | ec-3 | ru | A000CH | 1463 Segments | ~01h33m34s

The following should be selected:

19:22:02.097 INFO : Aud *CENC audio_eng=128000 | 128 Kbps | ac-3 | en | A000CH | 1463 Segments | ~01h33m34s
19:22:02.098 INFO : Aud *CENC audio_lit=128000 | 128 Kbps | ac-3 | lt | A000CH | 1463 Segments | ~01h33m34s
19:22:02.099 INFO : Aud *CENC audio_pol_2=128000 | 128 Kbps | ac-3 | pl | A000CH | 1463 Segments | ~01h33m34s
19:22:02.100 INFO : Aud *CENC audio_rus_2=128000 | 128 Kbps | ac-3 | ru | A000CH | 1463 Segments | ~01h33m34s

Is this possible, without knowing the number of available language beforehand ?

nilaoda commented 1 year ago

Try --auto-select

postmanpaul commented 1 year ago

I gave --auto-select a try. It does what I want for video & audio streams. But now I am having issue with the subtitles, because --auto-select is overriding my -ss selection, with all subtitles being selected.

Some of the subtitles cannot be fetched, causing the command to end with error when they get selected.

If it was possible to use --auto-select only for audio & video streams, it would be perfect.

These are the subtitle streams.

11:00:51.816 INFO : Sub textstream_eng=1000 | en | wvtt | 10 Segments | ~45m17s
11:00:51.821 INFO : Sub textstream_est=1000 | et | wvtt | 10 Segments | ~45m17s
11:00:51.822 INFO : Sub textstream_fin=1000 | fi | wvtt | 10 Segments | ~45m30s
11:00:51.823 INFO : Sub textstream_isl=1000 | is | wvtt | 10 Segments | ~45m17s
11:00:51.824 INFO : Sub textstream_lav=1000 | lv | wvtt | 10 Segments | ~45m17s
11:00:51.825 INFO : Sub textstream_lit=1000 | lt | wvtt | 10 Segments | ~45m10s
11:00:51.826 INFO : Sub textstream_nld=1000 | nl | wvtt | 10 Segments | ~45m17s
11:00:51.827 INFO : Sub textstream_nor=1000 | no | wvtt | 10 Segments | ~45m30s
11:00:51.828 INFO : Sub textstream_pol=1000 | pl | wvtt | 10 Segments | ~45m17s
11:00:51.829 INFO : Sub textstream_rus=1000 | ru | wvtt | 10 Segments | ~45m17s
11:00:51.830 INFO : Sub textstream_swe=1000 | sv | wvtt | 10 Segments | ~45m17s
11:00:51.831 INFO : Sub 2802173336 | da | 1 Segment | ~45m49s
11:00:51.839 INFO : Sub 1041571909 | en | 1 Segment | ~45m49s
11:00:51.840 INFO : Sub 1479534081 | et | 1 Segment | ~45m49s
11:00:51.841 INFO : Sub 2688421922 | fi | 1 Segment | ~45m49s
11:00:51.842 INFO : Sub 1137418125 | is | 1 Segment | ~45m49s
11:00:51.843 INFO : Sub 49132152 | lv | 1 Segment | ~45m49s
11:00:51.845 INFO : Sub 3042341318 | lt | 1 Segment | ~45m49s
11:00:51.846 INFO : Sub 1745223327 | nl | 1 Segment | ~45m49s
11:00:51.847 INFO : Sub 1319713392 | no | 1 Segment | ~45m49s
11:00:51.848 INFO : Sub 807629932 | pl | 1 Segment | ~45m49s
11:00:51.853 INFO : Sub 1444712723 | ru | 1 Segment | ~45m49s
11:00:51.854 INFO : Sub 3977475854 | sv | 1 Segment | ~45m49s

Only the wvtt subtitles work, the other cause error. I was using -ss id="textstream_.*=1000":for=all to pick only the working subtitle streams, but it does not work with --auto-select.

If I could --auto-select but also force drop the problematic subtitle with -ds that could also work, but I cannot figure how the syntax works with -ds, or if it's possible.

nilaoda commented 1 year ago

Drop all subtitles less then 2 segments: -ds segsMax=2:for=all --auto-select

postmanpaul commented 1 year ago

That works perfectly, thanks. And thanks for an excellent program. 🤯