kaltura / nginx-vod-module

NGINX-based MP4 Repackager
GNU Affero General Public License v3.0
1.99k stars 439 forks source link

mp4 with multiple audio tracks #1444

Closed kuznetcoff777 closed 1 year ago

kuznetcoff777 commented 1 year ago

Related to ticket #808 but i dont get solution.

I have mp4 with 2 audiotracks

Complete name                            : 2-audio-tracks_test-31f3XLAEi1OiNhOpunIO0_350.mp4
Format                                   : MPEG-4
Format profile                           : Base Media
Codec ID                                 : isom (isom/iso2/avc1/mp41)
File size                                : 7.72 MiB
Duration                                 : 1 min 43 s
Overall bit rate                         : 623 kb/s
Writing application                      : Lavf60.3.100

Video
ID                                       : 1
Format                                   : AVC
Format/Info                              : Advanced Video Codec
Format profile                           : High@L3
Format settings                          : CABAC / 5 Ref Frames
Format settings, CABAC                   : Yes
Format settings, Reference frames        : 5 frames
Format settings, GOP                     : M=4, N=25
Codec ID                                 : avc1
Codec ID/Info                            : Advanced Video Coding
Duration                                 : 1 min 43 s
Bit rate                                 : 350 kb/s
Maximum bit rate                         : 400 kb/s
Width                                    : 640 pixels
Height                                   : 360 pixels
Display aspect ratio                     : 16:9
Frame rate mode                          : Constant
Frame rate                               : 25.000 FPS
Color space                              : YUV
Chroma subsampling                       : 4:2:0
Bit depth                                : 8 bits
Scan type                                : Progressive
Bits/(Pixel*Frame)                       : 0.061
Stream size                              : 4.36 MiB (56%)
Writing library                          : x264 core 148
Encoding settings                        : cabac=1 / ref=5 / deblock=1:0:0 / analyse=0x3:0x133 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=11 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=25 / keyint_min=13 / scenecut=0 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=350 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=40 / qpstep=4 / vbv_maxrate=400 / vbv_bufsize=3800 / nal_hrd=none / filler=0 / ip_ratio=1.41 / aq=1:1.00
Codec configuration box                  : avcC

Audio #1
ID                                       : 2
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 1 min 43 s
Source duration                          : 1 min 43 s
Source_Duration_LastFrame                : -11 ms
Bit rate mode                            : Constant
Bit rate                                 : 132 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 1.65 MiB (21%)
Source stream size                       : 1.65 MiB (21%)
Default                                  : Yes
Alternate group                          : 1

Audio #2
ID                                       : 3
Format                                   : AAC LC
Format/Info                              : Advanced Audio Codec Low Complexity
Codec ID                                 : mp4a-40-2
Duration                                 : 1 min 43 s
Source duration                          : 1 min 43 s
Source_Duration_LastFrame                : -11 ms
Bit rate mode                            : Constant
Bit rate                                 : 129 kb/s
Channel(s)                               : 2 channels
Channel layout                           : L R
Sampling rate                            : 48.0 kHz
Frame rate                               : 46.875 FPS (1024 SPF)
Compression mode                         : Lossy
Stream size                              : 1.60 MiB (21%)
Source stream size                       : 1.60 MiB (21%)
Default                                  : No
Alternate group                          : 1

But when i call master.m3u8

EXTM3U

EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=484994,RESOLUTION=640x360,FRAME-RATE=25.000,CODECS="avc1.64001e,mp4a.40.2"

index-v1-a1.m3u8

If i call for 2-audio-tracks_test-31f3XLAEi1OiNhOpunIO0_350.mp4/master.m3u8 - it works with second audio track. But how to make it visible via master.m3u8?

kuznetcoff777 commented 1 year ago

I got it from comment https://github.com/kaltura/nginx-vod-module/issues/768#issuecomment-354353451

But what if i don want multiple languages (for example a1=with commentator - and a2 = internoise)? How to call a2 to make it alternative?

kuznetcoff777 commented 1 year ago

Seems to be "zxx" language code need to set https://github.com/kaltura/nginx-vod-module/blob/6c305a78b7ab6e4312279bea5c45741bb54a713b/vod/languages_x.h

erankor commented 1 year ago

The module does not output multiple audio tracks if they have the same "label". By default, the label is derived from the language (if specified), but it can also be set explicitly using the mapping JSON. If you set the label in the JSON, you can have 2 English tracks, one named "commentator" and the other "internoise".