impl audio layout
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import click
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from .track_type import TrackType
|
from .track_type import TrackType
|
||||||
|
|
||||||
@@ -19,7 +20,7 @@ class AudioLayout(Enum):
|
|||||||
|
|
||||||
def index(self):
|
def index(self):
|
||||||
"""Returns the layout as string"""
|
"""Returns the layout as string"""
|
||||||
return self.value['layout']
|
return self.value['index']
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def fromIndex(index : int):
|
def fromIndex(index : int):
|
||||||
@@ -28,7 +29,8 @@ class AudioLayout(Enum):
|
|||||||
except:
|
except:
|
||||||
return AudioLayout.LAYOUT_UNDEFINED
|
return AudioLayout.LAYOUT_UNDEFINED
|
||||||
|
|
||||||
def identify(self, streamObj):
|
@staticmethod
|
||||||
|
def identify(streamObj):
|
||||||
|
|
||||||
FFPROBE_LAYOUT_KEY = 'channel_layout'
|
FFPROBE_LAYOUT_KEY = 'channel_layout'
|
||||||
FFPROBE_CHANNELS_KEY = 'channels'
|
FFPROBE_CHANNELS_KEY = 'channels'
|
||||||
@@ -40,7 +42,7 @@ class AudioLayout(Enum):
|
|||||||
raise Exception('Not an ffprobe audio stream object')
|
raise Exception('Not an ffprobe audio stream object')
|
||||||
|
|
||||||
if FFPROBE_LAYOUT_KEY in streamObj.keys():
|
if FFPROBE_LAYOUT_KEY in streamObj.keys():
|
||||||
matchingLayouts = [l for l in AudioLayout if l.value['layout'] == streamObj[FFPROBE_LAYOUT_KEY]]
|
matchingLayouts = [l for l in AudioLayout if l.label() == streamObj[FFPROBE_LAYOUT_KEY]]
|
||||||
if matchingLayouts:
|
if matchingLayouts:
|
||||||
return matchingLayouts[0]
|
return matchingLayouts[0]
|
||||||
|
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ class FileProperties():
|
|||||||
|
|
||||||
|
|
||||||
def getMediaDescriptor(self):
|
def getMediaDescriptor(self):
|
||||||
return MediaDescriptor.fromFfprobe(self.getFormatData(), self.getStreamData(), context = self.context)
|
return MediaDescriptor.fromFfprobe(self.getFormatData(), self.getStreamData())
|
||||||
|
|
||||||
|
|
||||||
def getShowId(self) -> int:
|
def getShowId(self) -> int:
|
||||||
|
|||||||
@@ -109,7 +109,7 @@ class MediaDescriptor():
|
|||||||
|
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def fromFfprobe(cls, formatData, streamData, context : dict = None):
|
def fromFfprobe(cls, formatData, streamData):
|
||||||
|
|
||||||
kwargs = {}
|
kwargs = {}
|
||||||
|
|
||||||
|
|||||||
@@ -296,7 +296,7 @@ class MediaDetailsScreen(Screen):
|
|||||||
row = (td.getIndex(),
|
row = (td.getIndex(),
|
||||||
trackType.label(),
|
trackType.label(),
|
||||||
typeCounter[trackType],
|
typeCounter[trackType],
|
||||||
" ",
|
td.getAudioLayout().label() if trackType == TrackType.AUDIO else ' ',
|
||||||
td.getLanguage().label(),
|
td.getLanguage().label(),
|
||||||
td.getTitle(),
|
td.getTitle(),
|
||||||
'Yes' if TrackDisposition.DEFAULT in dispoSet else 'No',
|
'Yes' if TrackDisposition.DEFAULT in dispoSet else 'No',
|
||||||
|
|||||||
@@ -138,7 +138,7 @@ class PatternDetailsScreen(Screen):
|
|||||||
row = (td.getIndex(),
|
row = (td.getIndex(),
|
||||||
trackType.label(),
|
trackType.label(),
|
||||||
typeCounter[trackType],
|
typeCounter[trackType],
|
||||||
td.getAudioLayout().label(),
|
td.getAudioLayout().label() if trackType == TrackType.AUDIO else ' ',
|
||||||
td.getLanguage().label(),
|
td.getLanguage().label(),
|
||||||
td.getTitle(),
|
td.getTitle(),
|
||||||
'Yes' if TrackDisposition.DEFAULT in dispoSet else 'No',
|
'Yes' if TrackDisposition.DEFAULT in dispoSet else 'No',
|
||||||
|
|||||||
@@ -32,7 +32,8 @@ class TrackController():
|
|||||||
track_type = int(trackDescriptor.getType().index()),
|
track_type = int(trackDescriptor.getType().index()),
|
||||||
index = int(trackDescriptor.getIndex()),
|
index = int(trackDescriptor.getIndex()),
|
||||||
source_index = int(trackDescriptor.getSourceIndex()),
|
source_index = int(trackDescriptor.getSourceIndex()),
|
||||||
disposition_flags = int(TrackDisposition.toFlags(trackDescriptor.getDispositionSet())))
|
disposition_flags = int(TrackDisposition.toFlags(trackDescriptor.getDispositionSet())),
|
||||||
|
audio_layout = trackDescriptor.getAudioLayout().index())
|
||||||
|
|
||||||
s.add(track)
|
s.add(track)
|
||||||
s.commit()
|
s.commit()
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import click
|
||||||
|
|
||||||
from .iso_language import IsoLanguage
|
from .iso_language import IsoLanguage
|
||||||
from .track_type import TrackType
|
from .track_type import TrackType
|
||||||
from .audio_layout import AudioLayout
|
from .audio_layout import AudioLayout
|
||||||
@@ -150,7 +152,7 @@ class TrackDescriptor():
|
|||||||
kwargs[TrackDescriptor.DISPOSITION_SET_KEY] = {t for d in (k for (k,v) in streamObj[TrackDescriptor.FFPROBE_DISPOSITION_KEY].items() if v)
|
kwargs[TrackDescriptor.DISPOSITION_SET_KEY] = {t for d in (k for (k,v) in streamObj[TrackDescriptor.FFPROBE_DISPOSITION_KEY].items() if v)
|
||||||
if (t := TrackDisposition.find(d)) if t is not None} if TrackDescriptor.FFPROBE_DISPOSITION_KEY in streamObj.keys() else set()
|
if (t := TrackDisposition.find(d)) if t is not None} if TrackDescriptor.FFPROBE_DISPOSITION_KEY in streamObj.keys() else set()
|
||||||
kwargs[TrackDescriptor.TAGS_KEY] = streamObj[TrackDescriptor.FFPROBE_TAGS_KEY] if TrackDescriptor.FFPROBE_TAGS_KEY in streamObj.keys() else {}
|
kwargs[TrackDescriptor.TAGS_KEY] = streamObj[TrackDescriptor.FFPROBE_TAGS_KEY] if TrackDescriptor.FFPROBE_TAGS_KEY in streamObj.keys() else {}
|
||||||
kwargs[TrackDescriptor.AUDIO_LAYOUT_KEY] = AudioLayout.identify(streamObj) if trackType == TrackType.AUDIO.label() else AudioLayout.LAYOUT_UNDEFINED
|
kwargs[TrackDescriptor.AUDIO_LAYOUT_KEY] = AudioLayout.identify(streamObj) if trackType == TrackType.AUDIO else AudioLayout.LAYOUT_UNDEFINED
|
||||||
|
|
||||||
return cls(**kwargs)
|
return cls(**kwargs)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user