Skip to content

Commit

Permalink
better webui sort, add sort by name
Browse files Browse the repository at this point in the history
  • Loading branch information
luewh committed Nov 27, 2024
1 parent be5df84 commit e9f7b97
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 38 deletions.
2 changes: 2 additions & 0 deletions VideoScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -965,12 +965,14 @@ def merge(self, allVideo:bool=True, allAudio:bool=False, allSubtitle:bool=False)
if index == 0:
commandInputs += f'-i "{path}" '
commandMap += f'-map {index} '
# remove time codec for mp4
commandMap += f'-map -{index}:d '
commandMetadata += f'-metadata:s:v:{index} title="{name}" '
commandMetadata += f'-metadata:s:a:{index} title="{name}" '
commandMetadata += f'-metadata:s:s:{index} title="{name}" '
else:
commandInputs += f'-i "{path}" '
# remove time codec for mp4
commandMap += f'-map -{index}:d '
if allVideo:
commandMap += f'-map {index}:v? '
Expand Down
60 changes: 22 additions & 38 deletions VideoScriptWebUI.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,13 @@
"select":"info",
"unselect":"dark",
}
videoSortBy = ["width", "height", "w x h", "fps", "length", "bit rate"]
videoSortBy = [
"name",
"width", "height", "w x h",
"r_frame_rate",
"duration",
"bitRate"
]


app = Dash(
Expand Down Expand Up @@ -857,49 +863,27 @@ def reverseVideoList(_, children):
)
def sortVideoList(sortBy, allColor):

global vs, allVideoList, videoItemColor
global vs, allVideoList, videoItemColor, videoSortBy

# add color to allVideoList
for index in range(len(allVideoList)):
allVideoList[index]["color"] = allColor[index]
# check dropdown validity
if sortBy not in videoSortBy:
print("Unknow sort selection")
raise PreventUpdate


if sortBy == "width":
allVideoList = sorted(
allVideoList,
key= lambda video: video['width'],
)
elif sortBy == "height":
allVideoList = sorted(
allVideoList,
key= lambda video: video['height'],
)
elif sortBy == "w x h":
# special sort
if sortBy == "w x h":
for index in range(len(allVideoList)):
allVideoList[index]["w x h"] = allVideoList[index]["width"] * allVideoList[index]["height"]
allVideoList = sorted(
allVideoList,
key= lambda video: video['w x h'],
)
elif sortBy == "fps":
allVideoList = sorted(
allVideoList,
key= lambda video: video['r_frame_rate'],
)
elif sortBy == "length":
allVideoList = sorted(
allVideoList,
key= lambda video: video['duration'],
)
elif sortBy == "bit rate":
allVideoList = sorted(
allVideoList,
key= lambda video: video['bitRate'],
)
allVideoList.sort(key= lambda video: video['w x h'],)
# normal sort
else:
print("Unknow sort selection")
raise PreventUpdate
allVideoList.sort(key= lambda video: video[sortBy],)


# add color to allVideoList
for index in range(len(allVideoList)):
allVideoList[index]["color"] = allColor[index]

# re generate list of video items
videoItems = []
vs.vList = []
Expand Down

0 comments on commit e9f7b97

Please sign in to comment.