shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
1.9k stars 496 forks source link

fix: exact-order-hls #1374

Open SteveR-PMP opened 3 months ago

SteveR-PMP commented 3 months ago

HLS manifest was still grouping by audio codecs first in the manifest before forcing the command line order.

vish91 commented 3 months ago

@joeyparrish @cosmin if you can help review this please. We found a bug with the input command based ordering feature where it was working correctly for DASH but not for HLS because of this grouping logic baked into packager only in HLS. so this rework from @SteveR-PMP should help fix that and make that feature a true command input order for both HLS and DASH.

SteveR-PMP commented 3 months ago

as an example, the following command line:

packager \ in=audio.mp4,stream=audio,hls_group_id=ec3,output=audio2.mp4 \ in=audio.mp4,stream=audio,hls_group_id=aac,output=audio3.mp4 \ in=audio.mp4,stream=audio,hls_group_id=ec3,output=audio4.mp4 \ in=audio.mp4,stream=audio,hls_group_id=aac,output=audio5.mp4 \ in=video.mp4,stream=video,output=video2.mp4 \ --hls_master_playlist_output master.m3u8

would previously generate a HLS manifest that grouped by hls_group_id first:

EXT-X-MEDIA:TYPE=AUDIO,URI="stream_0.m3u8",GROUP-ID="ec3",NAME="stream_0",DEFAULT=NO,AUTOSELECT=YES,CHANNELS="2"

EXT-X-MEDIA:TYPE=AUDIO,URI="stream_2.m3u8",GROUP-ID="ec3",NAME="stream_2",DEFAULT=NO,CHANNELS="2"

EXT-X-MEDIA:TYPE=AUDIO,URI="stream_1.m3u8",GROUP-ID="aac",NAME="stream_1",DEFAULT=NO,AUTOSELECT=YES,CHANNELS="2"

EXT-X-MEDIA:TYPE=AUDIO,URI="stream_3.m3u8",GROUP-ID="aac",NAME="stream_3",DEFAULT=NO,CHANNELS="2"

EXT-X-STREAM-INF:BANDWIDTH=2354148,AVERAGE-BANDWIDTH=880371,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=720x300,FRAME-RATE=24.000,AUDIO="aac",CLOSED-CAPTIONS=NONE

stream_4.m3u8

EXT-X-STREAM-INF:BANDWIDTH=2354148,AVERAGE-BANDWIDTH=880371,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=720x300,FRAME-RATE=24.000,AUDIO="ec3",CLOSED-CAPTIONS=NONE

stream_4.m3u8

and now it will force the exact command-line order:

EXT-X-MEDIA:TYPE=AUDIO,URI="stream_0.m3u8",GROUP-ID="ec3",NAME="stream_0",DEFAULT=NO,AUTOSELECT=YES,CHANNELS="2"

EXT-X-MEDIA:TYPE=AUDIO,URI="stream_1.m3u8",GROUP-ID="aac",NAME="stream_1",DEFAULT=NO,AUTOSELECT=YES,CHANNELS="2"

EXT-X-MEDIA:TYPE=AUDIO,URI="stream_2.m3u8",GROUP-ID="ec3",NAME="stream_2",DEFAULT=NO,CHANNELS="2"

EXT-X-MEDIA:TYPE=AUDIO,URI="stream_3.m3u8",GROUP-ID="aac",NAME="stream_3",DEFAULT=NO,CHANNELS="2"

EXT-X-STREAM-INF:BANDWIDTH=2354148,AVERAGE-BANDWIDTH=880371,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=720x300,FRAME-RATE=24.000,AUDIO="aac",CLOSED-CAPTIONS=NONE

stream_4.m3u8

EXT-X-STREAM-INF:BANDWIDTH=2354148,AVERAGE-BANDWIDTH=880371,CODECS="avc1.64001e,mp4a.40.2",RESOLUTION=720x300,FRAME-RATE=24.000,AUDIO="ec3",CLOSED-CAPTIONS=NONE

stream_4.m3u8

cosmin commented 3 months ago

And the groups no longer being grouped together is what we want? On the one hand I guess it's not really strict command line ordering if we preserve the groups being grouped, on the other hand it's not clear where that would matter, as long as we respect the ordering within each group.

SteveR-PMP commented 3 months ago

And the groups no longer being grouped together is what we want? On the one hand I guess it's not really strict command line ordering if we preserve the groups being grouped, on the other hand it's not clear where that would matter, as long as we respect the ordering within each group.

@cosmin This is important because:

If someone still wants it grouped by audio-groups first, they could manually enforce that on the command line.