Browse Source

Merge branch 'extract-audio-mediainfo' of xoru/Gazelle into master

spaghetti 1 year ago
parent
commit
f1b788402a
1 changed files with 29 additions and 0 deletions
  1. 29
    0
      static/functions/upload.js

+ 29
- 0
static/functions/upload.js View File

@@ -570,6 +570,35 @@ function MediaInfoExtract() {
570 570
       else if (codecTable[codec]) {
571 571
         codel.value = codecTable[codec]
572 572
       }
573
+    } else if (sel == 'audioformat') {
574
+      var audioFormats = ['MP3', 'OGG', 'OGG 5.1', 'AAC', 'AAC 5.1', 'AC3', 'AC3 5.1', 'DTS 2.0', 'DTS 5.1', 'DTS-ES 6.1', 'FLAC 2.0', 'FLAC 5.1', 'FLAC 6.1', 'PCM 2.0', 'PCM 5.1', 'PCM 6.1', 'WMA', 'Real Audio', 'DTS-HD', 'DTS-HD MA']
575
+      var audioFormatTable = {'AAC LC': 'AAC', 'AAC LC SBR': 'AAC', 'AC-3': 'AC3', 'Vorbis': 'OGG'}
576
+      var format = getval(mi.slice(mi.search(/^Audio$/m)), 'Format')
577
+      var channels = getval(mi.slice(mi.search(/^Audio$/m)), 'Channel\\(s\\)')
578
+      var el = $('[name=audioformat]').raw()
579
+      if (format == 'MPEG Audio') {
580
+        var profile = getval(mi.slice(mi.search(/^Audio$/m)), 'Format profile')
581
+        if (profile == 'Layer 3') {
582
+          el.value = 'MP3'
583
+        }
584
+      }
585
+      else {
586
+        if (audioFormatTable[format]) {
587
+          format = audioFormatTable[format]
588
+        }
589
+        if (channels[0] == 7 && audioFormats.indexOf(format + ' 6.1') !== -1) {
590
+          format += ' 6.1'
591
+        }
592
+        else if (channels[0] == 6 && audioFormats.indexOf(format + ' 5.1') !== -1) {
593
+          format += ' 5.1'
594
+        }
595
+        else if (channels[0] == 2 && audioFormats.indexOf(format + ' 2.0') !== -1) {
596
+          format += ' 2.0'
597
+        }
598
+        if (audioFormats.indexOf(format) !== -1) {
599
+          el.value = format
600
+        }
601
+      }
573 602
     }
574 603
   })
575 604
 }

Loading…
Cancel
Save