@@ -738,6 +738,7 @@ Namespace API.YouTube.Objects
738738# Region "Command"
739739 <XMLEC> Public Property UseCookies As Boolean = MyYouTubeSettings.DefaultUseCookies Implements IYouTubeMediaContainer.UseCookies
740740 Protected Const mp3 As String = "mp3"
741+ Private Const mp4 As String = "mp4"
741742 Private Const aac As String = "aac"
742743 Private Const ac3 As String = "ac3"
743744 Protected PostProcessing_AudioAC3 As Boolean = False
@@ -773,7 +774,12 @@ Namespace API.YouTube.Objects
773774 '2023.3.4 -> 2023.7.6
774775 'cmd.StringAppend($"ba*[format_id={SelectedAudio.ID}]", "+")
775776 cmd.StringAppend(SelectedAudio.ID, "+" )
776- If OutputAudioCodec.StringToLower = ac3 Then
777+ If SelectedVideoIndex >= 0 And SelectedAudio.ProtocolType = Protocols.m3u8 And
778+ (SelectedAudio.Codec.StringToLower = mp4 Or OutputAudioCodec.StringToLower = mp4) Then
779+ PostProcessing_AudioAC3 = True
780+ formats.StringAppend( $"--merge-output-format ""{mp4}{IIf(OutputVideoExtension.IsEmptyString, String.Empty, $" /{OutputVideoExtension.StringToLower} ")}""" , " " )
781+ atCodec = aac
782+ ElseIf OutputAudioCodec.StringToLower = ac3 Then
777783 PostProcessing_AudioAC3 = True
778784 formats.StringAppend( $"--audio-format {aac}" , " " )
779785 atCodec = aac
@@ -1753,9 +1759,12 @@ Namespace API.YouTube.Objects
17531759 If If (e({ "formats" })?.Count, 0 ) > 0 Then
17541760 Dim obj As MediaObject
17551761 Dim nValue#
1756- Dim sValue$
1762+ Dim sValue$ = String .Empty
17571763 Dim allowWebm As Boolean = MyYouTubeSettings.DefaultVideoAllowWebm
1758- Dim validCodecValue As Func( Of String , Boolean ) = Function (codec) Not codec.IsEmptyString AndAlso Not codec = "none"
1764+ Dim validCodecValue As Func( Of String , Boolean ) = Function ( ByVal codec As String ) As Boolean
1765+ sValue = codec
1766+ Return Not codec.IsEmptyString AndAlso Not codec = "none"
1767+ End Function
17591768
17601769 For Each ee In e({ "formats" })
17611770 obj = New MediaObject With {
@@ -1779,19 +1788,30 @@ Namespace API.YouTube.Objects
17791788 If obj.Size <= 0 And obj.Bitrate > 0 And Duration.TotalSeconds > 0 Then _
17801789 obj.Size = (obj.Bitrate / 8 * Duration.TotalSeconds).RoundVal( 2 )
17811790
1782- sValue = ee.Value( "vcodec" )
1783- If validCodecValue(sValue ) Then
1791+ ' sValue = ee.Value("vcodec")
1792+ If validCodecValue(ee.Value( "vcodec" ) ) Then
17841793 obj.Type = UMTypes.Video
17851794 obj.Codec = sValue.Split( "." ).First
17861795 If validCodecValue(ee.Value( "acodec" )) Then obj.Type = av
1796+ ElseIf validCodecValue(ee.Value( "acodec" )) Then
1797+ obj.Type = UMTypes.Audio
1798+ obj.Codec = sValue.Split( "." ).First
17871799 Else
1788- sValue = ee.Value( "acodec" )
1789- If validCodecValue(sValue) Then
1790- obj.Type = UMTypes.Audio
1791- obj.Codec = sValue.Split( "." ).First
1792- Else
1793- Continue For
1800+ Dim fd As Boolean = False
1801+ sValue = ee.Value( "format_note" )
1802+ If Not sValue.IsEmptyString Then
1803+ With ListAddList( Nothing , sValue.Split( "," ), CType ( Function (v) CStr (v).StringToLower.StringTrim, Func( Of Object , Object )), EDP.ReturnValue)
1804+ If .ListContains({ "high" , "low" }) Then
1805+ obj.Type = UMTypes.Audio
1806+ obj.Codec = ee.Value( "ext" )
1807+ If obj.Protocol.StringToLower.StartsWith( "m3u8" ) Then obj.Protocol = "m3u8"
1808+ If obj.Bitrate <= 0 Then obj.Bitrate = IIf(.Contains( "high" ), 129 , 53 )
1809+ If obj.Size <= 0 Then obj.Size = 1
1810+ fd = True
1811+ End If
1812+ End With
17941813 End If
1814+ If Not fd Then Continue For
17951815 End If
17961816 MediaObjects.Add(obj)
17971817 Next
@@ -1803,15 +1823,18 @@ Namespace API.YouTube.Objects
18031823 Dim data As New List( Of MediaObject)(MediaObjects.Where( Function (mo) mo.Type = t And mo.Extension = webm))
18041824 If data.Count > 0 Then
18051825 Dim d As MediaObject = Nothing
1806- Dim expWebm As Predicate( Of MediaObject) = Function (mo) mo.Extension = webm
1807- Dim expAVC As Predicate( Of MediaObject) = Function (mo) mo.Codec.IfNullOrEmpty( "/" ).ToLower.StartsWith(avc)
1826+ Dim allWebm As Boolean = False , allAVC As Boolean = False
1827+ Dim expWebm As Predicate( Of MediaObject) = Function (mo) Not allWebm And mo.Extension = webm
1828+ Dim expAVC As Predicate( Of MediaObject) = Function (mo) Not allAVC And mo.Codec.IfNullOrEmpty( "/" ).ToLower.StartsWith(avc)
18081829 Dim comp As Func( Of MediaObject, Predicate( Of MediaObject), Boolean , Boolean , Boolean ) =
18091830 Function (mo, exp, isTrue, checkHttp) mo.Type = t And exp.Invoke(mo) = isTrue And mo.Width = d.Width And
18101831 ( Not checkHttp OrElse mo.ProtocolType = Protocols.https)
18111832 Dim CountWebm As Func( Of MediaObject, Boolean ) = Function (mo) comp.Invoke(mo, expWebm, False , allowWebm)
18121833 Dim RemoveWebm As Predicate( Of MediaObject) = Function (mo) comp.Invoke(mo, expWebm, True , allowWebm)
18131834 Dim CountAVC As Func( Of MediaObject, Boolean ) = Function (mo) comp.Invoke(mo, expAVC, True , False )
18141835 Dim RemoveAVC As Predicate( Of MediaObject) = Function (mo) comp.Invoke(mo, expAVC, False , False )
1836+ allWebm = data.All(FPredicate( Of MediaObject).ToFunc(expWebm))
1837+ allAVC = data.All(FPredicate( Of MediaObject).ToFunc(expAVC))
18151838 For Each d In data
18161839 If MediaObjects.Count = 0 Then Exit For
18171840 If MediaObjects.LongCount(CountWebm) > 0 Then MediaObjects.RemoveAll(RemoveWebm)
0 commit comments