boris-behav-obs 9.0.2__py2.py3-none-any.whl → 9.0.4__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- boris/__init__.py +1 -1
- boris/__main__.py +1 -1
- boris/about.py +2 -2
- boris/add_modifier.py +1 -1
- boris/add_modifier_ui.py +22 -22
- boris/advanced_event_filtering.py +1 -1
- boris/analysis_plugins/number_of_occurences.py +6 -3
- boris/analysis_plugins/number_of_occurences_by_independent_variable.py +6 -4
- boris/analysis_plugins/time_budget.py +24 -14
- boris/behav_coding_map_creator.py +1 -1
- boris/behavior_binary_table.py +1 -1
- boris/behaviors_coding_map.py +1 -1
- boris/boris_cli.py +1 -1
- boris/cmd_arguments.py +1 -1
- boris/coding_pad.py +1 -1
- boris/config.py +16 -9
- boris/config_file.py +1 -1
- boris/connections.py +1 -1
- boris/converters.py +1 -1
- boris/cooccurence.py +1 -1
- boris/core.py +143 -176
- boris/db_functions.py +1 -1
- boris/dialog.py +10 -277
- boris/edit_event.py +8 -1
- boris/event_operations.py +1 -1
- boris/events_cursor.py +1 -1
- boris/events_snapshots.py +1 -1
- boris/exclusion_matrix.py +1 -1
- boris/export_events.py +1 -1
- boris/export_observation.py +1 -1
- boris/external_processes.py +1 -1
- boris/geometric_measurement.py +1 -1
- boris/gui_utilities.py +1 -1
- boris/image_overlay.py +1 -1
- boris/import_observations.py +1 -1
- boris/irr.py +1 -1
- boris/latency.py +1 -1
- boris/map_creator.py +1 -1
- boris/measurement_widget.py +1 -1
- boris/media_file.py +1 -1
- boris/menu_options.py +1 -1
- boris/modifiers_coding_map.py +1 -1
- boris/observation.py +1 -1
- boris/observation_operations.py +530 -425
- boris/observations_list.py +3 -3
- boris/otx_parser.py +1 -1
- boris/param_panel.py +1 -1
- boris/player_dock_widget.py +13 -9
- boris/plot_data_module.py +1 -1
- boris/plot_events.py +1 -1
- boris/plot_events_rt.py +1 -1
- boris/plot_spectrogram_rt.py +1 -1
- boris/plot_waveform_rt.py +1 -1
- boris/plugins.py +2 -2
- boris/preferences.py +6 -1
- boris/preferences_ui.py +7 -1
- boris/project.py +1 -1
- boris/project_functions.py +73 -76
- boris/project_import_export.py +1 -1
- boris/select_modifiers.py +1 -1
- boris/select_observations.py +6 -6
- boris/select_subj_behav.py +1 -1
- boris/state_events.py +1 -1
- boris/subjects_pad.py +1 -1
- boris/synthetic_time_budget.py +1 -1
- boris/time_budget_functions.py +1 -1
- boris/time_budget_widget.py +5 -5
- boris/transitions.py +1 -1
- boris/utilities.py +1 -1
- boris/version.py +3 -3
- boris/video_equalizer.py +1 -1
- boris/video_operations.py +1 -1
- boris/write_event.py +1 -1
- {boris_behav_obs-9.0.2.dist-info → boris_behav_obs-9.0.4.dist-info}/METADATA +1 -1
- boris_behav_obs-9.0.4.dist-info/RECORD +103 -0
- boris_behav_obs-9.0.2.dist-info/RECORD +0 -103
- {boris_behav_obs-9.0.2.dist-info → boris_behav_obs-9.0.4.dist-info}/LICENSE.TXT +0 -0
- {boris_behav_obs-9.0.2.dist-info → boris_behav_obs-9.0.4.dist-info}/WHEEL +0 -0
- {boris_behav_obs-9.0.2.dist-info → boris_behav_obs-9.0.4.dist-info}/entry_points.txt +0 -0
- {boris_behav_obs-9.0.2.dist-info → boris_behav_obs-9.0.4.dist-info}/top_level.txt +0 -0
boris/observation_operations.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""
|
|
2
2
|
BORIS
|
|
3
3
|
Behavioral Observation Research Interactive Software
|
|
4
|
-
Copyright 2012-
|
|
4
|
+
Copyright 2012-2025 Olivier Friard
|
|
5
5
|
|
|
6
6
|
This program is free software; you can redistribute it and/or modify
|
|
7
7
|
it under the terms of the GNU General Public License as published by
|
|
@@ -24,7 +24,9 @@ import os
|
|
|
24
24
|
import logging
|
|
25
25
|
import time
|
|
26
26
|
import tempfile
|
|
27
|
+
import json
|
|
27
28
|
import subprocess
|
|
29
|
+
import socket
|
|
28
30
|
import sys
|
|
29
31
|
from decimal import Decimal as dec
|
|
30
32
|
import pathlib as pl
|
|
@@ -1234,6 +1236,82 @@ def check_creation_date(self) -> Tuple[int, dict]:
|
|
|
1234
1236
|
return (0, media_creation_time) # OK all media have a 'creation time' tag
|
|
1235
1237
|
|
|
1236
1238
|
|
|
1239
|
+
def init_mpv(self):
|
|
1240
|
+
"""Start mpv process and embed it in the PySide6 application."""
|
|
1241
|
+
|
|
1242
|
+
print("start MPV process")
|
|
1243
|
+
|
|
1244
|
+
"""
|
|
1245
|
+
print(f"{self.winId()=}")
|
|
1246
|
+
print(f"{str(int(self.winId()))=}")
|
|
1247
|
+
"""
|
|
1248
|
+
|
|
1249
|
+
subprocess.Popen(
|
|
1250
|
+
[
|
|
1251
|
+
"mpv",
|
|
1252
|
+
"--no-border",
|
|
1253
|
+
"--ontop", # mpv window on top
|
|
1254
|
+
"--osc=no", # no on screen commands
|
|
1255
|
+
"--input-ipc-server=" + cfg.MPV_SOCKET,
|
|
1256
|
+
# "--wid=" + str(int(self.winId())), # Embed in the widget
|
|
1257
|
+
"--idle", # Keeps mpv running with no video
|
|
1258
|
+
],
|
|
1259
|
+
stdout=subprocess.PIPE,
|
|
1260
|
+
stderr=subprocess.PIPE,
|
|
1261
|
+
)
|
|
1262
|
+
|
|
1263
|
+
# print(f"init mpv: {self.mpv_process=}")
|
|
1264
|
+
|
|
1265
|
+
|
|
1266
|
+
def send_command(command):
|
|
1267
|
+
"""Send a JSON command to the mpv IPC server."""
|
|
1268
|
+
|
|
1269
|
+
print(f"send commnand {command}")
|
|
1270
|
+
# print(f"{self.mpv_process=}")
|
|
1271
|
+
|
|
1272
|
+
try:
|
|
1273
|
+
# Create a Unix socket
|
|
1274
|
+
with socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) as client:
|
|
1275
|
+
# Connect to the MPV IPC server
|
|
1276
|
+
from pathlib import Path
|
|
1277
|
+
|
|
1278
|
+
print(f"{Path(cfg.MPV_SOCKET).is_socket()=}")
|
|
1279
|
+
|
|
1280
|
+
client.connect(cfg.MPV_SOCKET)
|
|
1281
|
+
# Send the JSON command
|
|
1282
|
+
client.sendall(json.dumps(command).encode("utf-8") + b"\n")
|
|
1283
|
+
# Receive the response
|
|
1284
|
+
response = client.recv(2000)
|
|
1285
|
+
|
|
1286
|
+
print()
|
|
1287
|
+
print(f"{response=}")
|
|
1288
|
+
|
|
1289
|
+
# Parse the response as JSON
|
|
1290
|
+
response_splitted = response.split(b"\n")
|
|
1291
|
+
print(f"{response_splitted=}")
|
|
1292
|
+
data = None
|
|
1293
|
+
for r in response_splitted:
|
|
1294
|
+
print(f"{r=}")
|
|
1295
|
+
if not r:
|
|
1296
|
+
continue
|
|
1297
|
+
response_data = json.loads(r.decode("utf-8"))
|
|
1298
|
+
if "data" in response_data:
|
|
1299
|
+
data = response_data.get("data")
|
|
1300
|
+
# response_data = json.loads(response.decode("utf-8"))
|
|
1301
|
+
# print(f"{response_data=}")
|
|
1302
|
+
# return response_data.get("data")
|
|
1303
|
+
|
|
1304
|
+
return data
|
|
1305
|
+
|
|
1306
|
+
except FileNotFoundError:
|
|
1307
|
+
raise
|
|
1308
|
+
print("Error: Socket file not found.")
|
|
1309
|
+
except Exception as e:
|
|
1310
|
+
raise
|
|
1311
|
+
print(f"An error occurred: {e}")
|
|
1312
|
+
return None
|
|
1313
|
+
|
|
1314
|
+
|
|
1237
1315
|
def initialize_new_media_observation(self) -> bool:
|
|
1238
1316
|
"""
|
|
1239
1317
|
initialize new observation from media file(s)
|
|
@@ -1262,6 +1340,12 @@ def initialize_new_media_observation(self) -> bool:
|
|
|
1262
1340
|
self.playerType = cfg.VIEWER_MEDIA
|
|
1263
1341
|
return True
|
|
1264
1342
|
|
|
1343
|
+
if sys.platform.startswith(cfg.MACOS_CODE):
|
|
1344
|
+
pass
|
|
1345
|
+
init_mpv(self)
|
|
1346
|
+
|
|
1347
|
+
# print(f"{self.process=}")
|
|
1348
|
+
|
|
1265
1349
|
self.playerType = cfg.MEDIA
|
|
1266
1350
|
self.fps = 0
|
|
1267
1351
|
|
|
@@ -1299,566 +1383,586 @@ def initialize_new_media_observation(self) -> bool:
|
|
|
1299
1383
|
"""
|
|
1300
1384
|
|
|
1301
1385
|
# create dock widgets for players
|
|
1302
|
-
for i in range(cfg.N_PLAYER):
|
|
1303
|
-
n_player = str(i + 1)
|
|
1304
|
-
if (
|
|
1305
|
-
n_player not in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.FILE]
|
|
1306
|
-
or not self.pj[cfg.OBSERVATIONS][self.observationId][cfg.FILE][n_player]
|
|
1307
|
-
):
|
|
1308
|
-
continue
|
|
1309
1386
|
|
|
1310
|
-
|
|
1387
|
+
if not sys.platform.startswith(cfg.MACOS_CODE):
|
|
1388
|
+
for i in range(cfg.N_PLAYER):
|
|
1389
|
+
n_player = str(i + 1)
|
|
1390
|
+
if (
|
|
1391
|
+
n_player not in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.FILE]
|
|
1392
|
+
or not self.pj[cfg.OBSERVATIONS][self.observationId][cfg.FILE][n_player]
|
|
1393
|
+
):
|
|
1394
|
+
continue
|
|
1395
|
+
|
|
1396
|
+
# Not pretty but the unique solution I have found to capture the click signal for each player
|
|
1311
1397
|
|
|
1312
|
-
|
|
1313
|
-
|
|
1398
|
+
if i == 0: # first player
|
|
1399
|
+
p0 = player_dock_widget.DW_player(0, self)
|
|
1314
1400
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1401
|
+
@p0.player.property_observer("time-pos")
|
|
1402
|
+
def time_observer(_name, value):
|
|
1403
|
+
if value is not None:
|
|
1404
|
+
self.time_observer_signal.emit(value)
|
|
1319
1405
|
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1406
|
+
@p0.player.property_observer("eof-reached")
|
|
1407
|
+
def eof_reached(_name, value):
|
|
1408
|
+
if value is not None:
|
|
1409
|
+
self.mpv_eof_reached_signal.emit(value)
|
|
1324
1410
|
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1411
|
+
@p0.player.on_key_press("MBTN_LEFT")
|
|
1412
|
+
def mbtn_left0():
|
|
1413
|
+
self.video_click_signal.emit(0, "MBTN_LEFT")
|
|
1328
1414
|
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1415
|
+
@p0.player.on_key_press("MBTN_RIGHT")
|
|
1416
|
+
def mbtn_right0():
|
|
1417
|
+
self.video_click_signal.emit(0, "MBTN_RIGHT")
|
|
1332
1418
|
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1419
|
+
@p0.player.on_key_press("MBTN_LEFT_DBL")
|
|
1420
|
+
def mbtn_left_dbl0():
|
|
1421
|
+
self.video_click_signal.emit(0, "MBTN_LEFT_DBL")
|
|
1336
1422
|
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1423
|
+
@p0.player.on_key_press("MBTN_RIGHT_DBL")
|
|
1424
|
+
def mbtn_right_dbl0():
|
|
1425
|
+
self.video_click_signal.emit(0, "MBTN_RIGHT_DBL")
|
|
1340
1426
|
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1427
|
+
@p0.player.on_key_press("Ctrl+WHEEL_UP")
|
|
1428
|
+
def ctrl_wheel_up0():
|
|
1429
|
+
self.video_click_signal.emit(0, "Ctrl+WHEEL_UP")
|
|
1344
1430
|
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1431
|
+
@p0.player.on_key_press("Ctrl+WHEEL_DOWN")
|
|
1432
|
+
def ctrl_wheel_down0():
|
|
1433
|
+
self.video_click_signal.emit(0, "Ctrl+WHEEL_DOWN")
|
|
1348
1434
|
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1435
|
+
@p0.player.on_key_press("WHEEL_UP")
|
|
1436
|
+
def wheel_up0():
|
|
1437
|
+
self.video_click_signal.emit(0, "WHEEL_UP")
|
|
1352
1438
|
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1439
|
+
@p0.player.on_key_press("WHEEL_DOWN")
|
|
1440
|
+
def wheel_down0():
|
|
1441
|
+
self.video_click_signal.emit(0, "WHEEL_DOWN")
|
|
1356
1442
|
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1443
|
+
@p0.player.on_key_press("Shift+WHEEL_UP")
|
|
1444
|
+
def shift_wheel_up0():
|
|
1445
|
+
self.video_click_signal.emit(0, "Shift+WHEEL_UP")
|
|
1360
1446
|
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1447
|
+
@p0.player.on_key_press("Shift+WHEEL_DOWN")
|
|
1448
|
+
def shift_wheel_down0():
|
|
1449
|
+
self.video_click_signal.emit(0, "Shift+WHEEL_DOWN")
|
|
1364
1450
|
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1451
|
+
@p0.player.on_key_press("Shift+MBTN_LEFT")
|
|
1452
|
+
def shift_mbtn_left0():
|
|
1453
|
+
self.video_click_signal.emit(0, "Shift+MBTN_LEFT")
|
|
1368
1454
|
|
|
1369
|
-
|
|
1455
|
+
self.dw_player.append(p0)
|
|
1370
1456
|
|
|
1371
|
-
|
|
1372
|
-
|
|
1457
|
+
if i == 1: # second player
|
|
1458
|
+
p1 = player_dock_widget.DW_player(1, self)
|
|
1373
1459
|
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1460
|
+
@p1.player.on_key_press("MBTN_LEFT")
|
|
1461
|
+
def mbtn_left1():
|
|
1462
|
+
self.video_click_signal.emit(1, "MBTN_LEFT")
|
|
1377
1463
|
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1464
|
+
@p1.player.on_key_press("MBTN_RIGHT")
|
|
1465
|
+
def mbtn_right1():
|
|
1466
|
+
self.video_click_signal.emit(1, "MBTN_RIGHT")
|
|
1381
1467
|
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1468
|
+
@p1.player.on_key_press("MBTN_LEFT_DBL")
|
|
1469
|
+
def mbtn_left_dbl1():
|
|
1470
|
+
self.video_click_signal.emit(1, "MBTN_LEFT_DBL")
|
|
1385
1471
|
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1472
|
+
@p1.player.on_key_press("MBTN_RIGHT_DBL")
|
|
1473
|
+
def mbtn_right_dbl1():
|
|
1474
|
+
self.video_click_signal.emit(1, "MBTN_RIGHT_DBL")
|
|
1389
1475
|
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1476
|
+
@p1.player.on_key_press("Ctrl+WHEEL_UP")
|
|
1477
|
+
def ctrl_wheel_up1():
|
|
1478
|
+
self.video_click_signal.emit(1, "Ctrl+WHEEL_UP")
|
|
1393
1479
|
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1480
|
+
@p1.player.on_key_press("Ctrl+WHEEL_DOWN")
|
|
1481
|
+
def ctrl_wheel_down1():
|
|
1482
|
+
self.video_click_signal.emit(1, "Ctrl+WHEEL_DOWN")
|
|
1397
1483
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1484
|
+
@p1.player.on_key_press("WHEEL_UP")
|
|
1485
|
+
def wheel_up1():
|
|
1486
|
+
self.video_click_signal.emit(1, "WHEEL_UP")
|
|
1401
1487
|
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1488
|
+
@p1.player.on_key_press("WHEEL_DOWN")
|
|
1489
|
+
def wheel_down1():
|
|
1490
|
+
self.video_click_signal.emit(1, "WHEEL_DOWN")
|
|
1405
1491
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1492
|
+
@p1.player.on_key_press("Shift+WHEEL_UP")
|
|
1493
|
+
def shift_wheel_up1():
|
|
1494
|
+
self.video_click_signal.emit(1, "Shift+WHEEL_UP")
|
|
1409
1495
|
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1496
|
+
@p1.player.on_key_press("Shift+WHEEL_DOWN")
|
|
1497
|
+
def shift_wheel_down1():
|
|
1498
|
+
self.video_click_signal.emit(1, "Shift+WHEEL_DOWN")
|
|
1413
1499
|
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1500
|
+
@p1.player.on_key_press("Shift+MBTN_LEFT")
|
|
1501
|
+
def shift_mbtn_left1():
|
|
1502
|
+
self.video_click_signal.emit(1, "Shift+MBTN_LEFT")
|
|
1417
1503
|
|
|
1418
|
-
|
|
1504
|
+
self.dw_player.append(p1)
|
|
1419
1505
|
|
|
1420
|
-
|
|
1421
|
-
|
|
1506
|
+
if i == 2:
|
|
1507
|
+
p2 = player_dock_widget.DW_player(2, self)
|
|
1422
1508
|
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1509
|
+
@p2.player.on_key_press("MBTN_LEFT")
|
|
1510
|
+
def mbtn_left2():
|
|
1511
|
+
self.video_click_signal.emit(2, "MBTN_LEFT")
|
|
1426
1512
|
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1513
|
+
@p2.player.on_key_press("MBTN_RIGHT")
|
|
1514
|
+
def mbtn_right2():
|
|
1515
|
+
self.video_click_signal.emit(2, "MBTN_RIGHT")
|
|
1430
1516
|
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1517
|
+
@p2.player.on_key_press("MBTN_LEFT_DBL")
|
|
1518
|
+
def mbtn_left_dbl2():
|
|
1519
|
+
self.video_click_signal.emit(2, "MBTN_LEFT_DBL")
|
|
1434
1520
|
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1521
|
+
@p2.player.on_key_press("MBTN_RIGHT_DBL")
|
|
1522
|
+
def mbtn_right_dbl2():
|
|
1523
|
+
self.video_click_signal.emit(2, "MBTN_RIGHT_DBL")
|
|
1438
1524
|
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1525
|
+
@p2.player.on_key_press("Ctrl+WHEEL_UP")
|
|
1526
|
+
def ctrl_wheel_up2():
|
|
1527
|
+
self.video_click_signal.emit(2, "Ctrl+WHEEL_UP")
|
|
1442
1528
|
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1529
|
+
@p2.player.on_key_press("Ctrl+WHEEL_DOWN")
|
|
1530
|
+
def ctrl_wheel_down2():
|
|
1531
|
+
self.video_click_signal.emit(2, "Ctrl+WHEEL_DOWN")
|
|
1446
1532
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1533
|
+
@p2.player.on_key_press("WHEEL_UP")
|
|
1534
|
+
def wheel_up2():
|
|
1535
|
+
self.video_click_signal.emit(2, "WHEEL_UP")
|
|
1450
1536
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1537
|
+
@p2.player.on_key_press("WHEEL_DOWN")
|
|
1538
|
+
def wheel_down2():
|
|
1539
|
+
self.video_click_signal.emit(2, "WHEEL_DOWN")
|
|
1454
1540
|
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1541
|
+
@p2.player.on_key_press("Shift+WHEEL_UP")
|
|
1542
|
+
def shift_wheel_up2():
|
|
1543
|
+
self.video_click_signal.emit(2, "Shift+WHEEL_UP")
|
|
1458
1544
|
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1545
|
+
@p2.player.on_key_press("Shift+WHEEL_DOWN")
|
|
1546
|
+
def shift_wheel_down2():
|
|
1547
|
+
self.video_click_signal.emit(2, "Shift+WHEEL_DOWN")
|
|
1462
1548
|
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1549
|
+
@p2.player.on_key_press("Shift+MBTN_LEFT")
|
|
1550
|
+
def shift_mbtn_left2():
|
|
1551
|
+
self.video_click_signal.emit(2, "Shift+MBTN_LEFT")
|
|
1466
1552
|
|
|
1467
|
-
|
|
1553
|
+
self.dw_player.append(p2)
|
|
1468
1554
|
|
|
1469
|
-
|
|
1470
|
-
|
|
1555
|
+
if i == 3:
|
|
1556
|
+
p3 = player_dock_widget.DW_player(3, self)
|
|
1471
1557
|
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1558
|
+
@p3.player.on_key_press("MBTN_LEFT")
|
|
1559
|
+
def mbtn_left3():
|
|
1560
|
+
self.video_click_signal.emit(3, "MBTN_LEFT")
|
|
1475
1561
|
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1562
|
+
@p3.player.on_key_press("MBTN_RIGHT")
|
|
1563
|
+
def mbtn_right3():
|
|
1564
|
+
self.video_click_signal.emit(3, "MBTN_RIGHT")
|
|
1479
1565
|
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1566
|
+
@p3.player.on_key_press("MBTN_LEFT_DBL")
|
|
1567
|
+
def mbtn_left_dbl3():
|
|
1568
|
+
self.video_click_signal.emit(3, "MBTN_LEFT_DBL")
|
|
1483
1569
|
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1570
|
+
@p3.player.on_key_press("MBTN_RIGHT_DBL")
|
|
1571
|
+
def mbtn_right_dbl3():
|
|
1572
|
+
self.video_click_signal.emit(3, "MBTN_RIGHT_DBL")
|
|
1487
1573
|
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1574
|
+
@p3.player.on_key_press("Ctrl+WHEEL_UP")
|
|
1575
|
+
def ctrl_wheel_up3():
|
|
1576
|
+
self.video_click_signal.emit(3, "Ctrl+WHEEL_UP")
|
|
1491
1577
|
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1578
|
+
@p3.player.on_key_press("Ctrl+WHEEL_DOWN")
|
|
1579
|
+
def ctrl_wheel_down3():
|
|
1580
|
+
self.video_click_signal.emit(3, "Ctrl+WHEEL_DOWN")
|
|
1495
1581
|
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1582
|
+
@p3.player.on_key_press("WHEEL_UP")
|
|
1583
|
+
def wheel_up3():
|
|
1584
|
+
self.video_click_signal.emit(3, "WHEEL_UP")
|
|
1499
1585
|
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1586
|
+
@p3.player.on_key_press("WHEEL_DOWN")
|
|
1587
|
+
def wheel_down3():
|
|
1588
|
+
self.video_click_signal.emit(3, "WHEEL_DOWN")
|
|
1503
1589
|
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1590
|
+
@p3.player.on_key_press("Shift+WHEEL_UP")
|
|
1591
|
+
def shift_wheel_up3():
|
|
1592
|
+
self.video_click_signal.emit(3, "Shift+WHEEL_UP")
|
|
1507
1593
|
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1594
|
+
@p3.player.on_key_press("Shift+WHEEL_DOWN")
|
|
1595
|
+
def shift_wheel_down3():
|
|
1596
|
+
self.video_click_signal.emit(3, "Shift+WHEEL_DOWN")
|
|
1511
1597
|
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1598
|
+
@p3.player.on_key_press("Shift+MBTN_LEFT")
|
|
1599
|
+
def shift_mbtn_left3():
|
|
1600
|
+
self.video_click_signal.emit(3, "Shift+MBTN_LEFT")
|
|
1515
1601
|
|
|
1516
|
-
|
|
1602
|
+
self.dw_player.append(p3)
|
|
1517
1603
|
|
|
1518
|
-
|
|
1519
|
-
|
|
1604
|
+
if i == 4:
|
|
1605
|
+
p4 = player_dock_widget.DW_player(4, self)
|
|
1520
1606
|
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1607
|
+
@p4.player.on_key_press("MBTN_LEFT")
|
|
1608
|
+
def mbtn_left4():
|
|
1609
|
+
self.video_click_signal.emit(4, "MBTN_LEFT")
|
|
1524
1610
|
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1611
|
+
@p4.player.on_key_press("MBTN_RIGHT")
|
|
1612
|
+
def mbtn_right4():
|
|
1613
|
+
self.video_click_signal.emit(4, "MBTN_RIGHT")
|
|
1528
1614
|
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1615
|
+
@p4.player.on_key_press("MBTN_LEFT_DBL")
|
|
1616
|
+
def mbtn_left_dbl4():
|
|
1617
|
+
self.video_click_signal.emit(4, "MBTN_LEFT_DBL")
|
|
1532
1618
|
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1619
|
+
@p4.player.on_key_press("MBTN_RIGHT_DBL")
|
|
1620
|
+
def mbtn_right_dbl4():
|
|
1621
|
+
self.video_click_signal.emit(4, "MBTN_RIGHT_DBL")
|
|
1536
1622
|
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1623
|
+
@p4.player.on_key_press("Ctrl+WHEEL_UP")
|
|
1624
|
+
def ctrl_wheel_up4():
|
|
1625
|
+
self.video_click_signal.emit(4, "Ctrl+WHEEL_UP")
|
|
1540
1626
|
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1627
|
+
@p4.player.on_key_press("Ctrl+WHEEL_DOWN")
|
|
1628
|
+
def ctrl_wheel_down4():
|
|
1629
|
+
self.video_click_signal.emit(4, "Ctrl+WHEEL_DOWN")
|
|
1544
1630
|
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1631
|
+
@p4.player.on_key_press("WHEEL_UP")
|
|
1632
|
+
def wheel_up4():
|
|
1633
|
+
self.video_click_signal.emit(4, "WHEEL_UP")
|
|
1548
1634
|
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1635
|
+
@p4.player.on_key_press("WHEEL_DOWN")
|
|
1636
|
+
def wheel_down4():
|
|
1637
|
+
self.video_click_signal.emit(4, "WHEEL_DOWN")
|
|
1552
1638
|
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1639
|
+
@p4.player.on_key_press("Shift+WHEEL_UP")
|
|
1640
|
+
def shift_wheel_up4():
|
|
1641
|
+
self.video_click_signal.emit(4, "Shift+WHEEL_UP")
|
|
1556
1642
|
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1643
|
+
@p4.player.on_key_press("Shift+WHEEL_DOWN")
|
|
1644
|
+
def shift_wheel_down4():
|
|
1645
|
+
self.video_click_signal.emit(4, "Shift+WHEEL_DOWN")
|
|
1560
1646
|
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1647
|
+
@p4.player.on_key_press("Shift+MBTN_LEFT")
|
|
1648
|
+
def shift_mbtn_left4():
|
|
1649
|
+
self.video_click_signal.emit(4, "Shift+MBTN_LEFT")
|
|
1564
1650
|
|
|
1565
|
-
|
|
1651
|
+
self.dw_player.append(p4)
|
|
1566
1652
|
|
|
1567
|
-
|
|
1568
|
-
|
|
1653
|
+
if i == 5:
|
|
1654
|
+
p5 = player_dock_widget.DW_player(5, self)
|
|
1569
1655
|
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1656
|
+
@p5.player.on_key_press("MBTN_LEFT")
|
|
1657
|
+
def mbtn_left5():
|
|
1658
|
+
self.video_click_signal.emit(5, "MBTN_LEFT")
|
|
1573
1659
|
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1660
|
+
@p5.player.on_key_press("MBTN_RIGHT")
|
|
1661
|
+
def mbtn_right5():
|
|
1662
|
+
self.video_click_signal.emit(5, "MBTN_RIGHT")
|
|
1577
1663
|
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1664
|
+
@p5.player.on_key_press("MBTN_LEFT_DBL")
|
|
1665
|
+
def mbtn_left_dbl5():
|
|
1666
|
+
self.video_click_signal.emit(5, "MBTN_LEFT_DBL")
|
|
1581
1667
|
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1668
|
+
@p5.player.on_key_press("MBTN_RIGHT_DBL")
|
|
1669
|
+
def mbtn_right_dbl5():
|
|
1670
|
+
self.video_click_signal.emit(5, "MBTN_RIGHT_DBL")
|
|
1585
1671
|
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1672
|
+
@p5.player.on_key_press("Ctrl+WHEEL_UP")
|
|
1673
|
+
def ctrl_wheel_up5():
|
|
1674
|
+
self.video_click_signal.emit(5, "Ctrl+WHEEL_UP")
|
|
1589
1675
|
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1676
|
+
@p5.player.on_key_press("Ctrl+WHEEL_DOWN")
|
|
1677
|
+
def ctrl_wheel_down5():
|
|
1678
|
+
self.video_click_signal.emit(5, "Ctrl+WHEEL_DOWN")
|
|
1593
1679
|
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1680
|
+
@p5.player.on_key_press("WHEEL_UP")
|
|
1681
|
+
def wheel_up5():
|
|
1682
|
+
self.video_click_signal.emit(5, "WHEEL_UP")
|
|
1597
1683
|
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1684
|
+
@p5.player.on_key_press("WHEEL_DOWN")
|
|
1685
|
+
def wheel_down5():
|
|
1686
|
+
self.video_click_signal.emit(5, "WHEEL_DOWN")
|
|
1601
1687
|
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1688
|
+
@p5.player.on_key_press("Shift+WHEEL_UP")
|
|
1689
|
+
def shift_wheel_up5():
|
|
1690
|
+
self.video_click_signal.emit(5, "Shift+WHEEL_UP")
|
|
1605
1691
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1692
|
+
@p5.player.on_key_press("Shift+WHEEL_DOWN")
|
|
1693
|
+
def shift_wheel_down5():
|
|
1694
|
+
self.video_click_signal.emit(5, "Shift+WHEEL_DOWN")
|
|
1609
1695
|
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1696
|
+
@p5.player.on_key_press("Shift+MBTN_LEFT")
|
|
1697
|
+
def shift_mbtn_left5():
|
|
1698
|
+
self.video_click_signal.emit(5, "Shift+MBTN_LEFT")
|
|
1613
1699
|
|
|
1614
|
-
|
|
1700
|
+
self.dw_player.append(p5)
|
|
1615
1701
|
|
|
1616
|
-
|
|
1617
|
-
|
|
1702
|
+
if i == 6:
|
|
1703
|
+
p6 = player_dock_widget.DW_player(6, self)
|
|
1618
1704
|
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1705
|
+
@p6.player.on_key_press("MBTN_LEFT")
|
|
1706
|
+
def mbtn_left6():
|
|
1707
|
+
self.video_click_signal.emit(6, "MBTN_LEFT")
|
|
1622
1708
|
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1709
|
+
@p6.player.on_key_press("MBTN_RIGHT")
|
|
1710
|
+
def mbtn_right6():
|
|
1711
|
+
self.video_click_signal.emit(6, "MBTN_RIGHT")
|
|
1626
1712
|
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1713
|
+
@p6.player.on_key_press("MBTN_LEFT_DBL")
|
|
1714
|
+
def mbtn_left_dbl6():
|
|
1715
|
+
self.video_click_signal.emit(6, "MBTN_LEFT_DBL")
|
|
1630
1716
|
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1717
|
+
@p6.player.on_key_press("MBTN_RIGHT_DBL")
|
|
1718
|
+
def mbtn_right_dbl6():
|
|
1719
|
+
self.video_click_signal.emit(6, "MBTN_RIGHT_DBL")
|
|
1634
1720
|
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1721
|
+
@p6.player.on_key_press("Ctrl+WHEEL_UP")
|
|
1722
|
+
def ctrl_wheel_up6():
|
|
1723
|
+
self.video_click_signal.emit(6, "Ctrl+WHEEL_UP")
|
|
1638
1724
|
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1725
|
+
@p6.player.on_key_press("Ctrl+WHEEL_DOWN")
|
|
1726
|
+
def ctrl_wheel_down6():
|
|
1727
|
+
self.video_click_signal.emit(6, "Ctrl+WHEEL_DOWN")
|
|
1642
1728
|
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1729
|
+
@p6.player.on_key_press("WHEEL_UP")
|
|
1730
|
+
def wheel_up6():
|
|
1731
|
+
self.video_click_signal.emit(6, "WHEEL_UP")
|
|
1646
1732
|
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1733
|
+
@p6.player.on_key_press("WHEEL_DOWN")
|
|
1734
|
+
def wheel_down6():
|
|
1735
|
+
self.video_click_signal.emit(6, "WHEEL_DOWN")
|
|
1650
1736
|
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1737
|
+
@p6.player.on_key_press("Shift+WHEEL_UP")
|
|
1738
|
+
def shift_wheel_up6():
|
|
1739
|
+
self.video_click_signal.emit(6, "Shift+WHEEL_UP")
|
|
1654
1740
|
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1741
|
+
@p6.player.on_key_press("Shift+WHEEL_DOWN")
|
|
1742
|
+
def shift_wheel_down6():
|
|
1743
|
+
self.video_click_signal.emit(6, "Shift+WHEEL_DOWN")
|
|
1658
1744
|
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1745
|
+
@p6.player.on_key_press("Shift+MBTN_LEFT")
|
|
1746
|
+
def shift_mbtn_left6():
|
|
1747
|
+
self.video_click_signal.emit(6, "Shift+MBTN_LEFT")
|
|
1662
1748
|
|
|
1663
|
-
|
|
1749
|
+
self.dw_player.append(p6)
|
|
1664
1750
|
|
|
1665
|
-
|
|
1666
|
-
|
|
1751
|
+
if i == 7:
|
|
1752
|
+
p7 = player_dock_widget.DW_player(7, self)
|
|
1667
1753
|
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1754
|
+
@p7.player.on_key_press("MBTN_LEFT")
|
|
1755
|
+
def mbtn_left7():
|
|
1756
|
+
self.video_click_signal.emit(7, "MBTN_LEFT")
|
|
1671
1757
|
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1758
|
+
@p7.player.on_key_press("MBTN_RIGHT")
|
|
1759
|
+
def mbtn_right7():
|
|
1760
|
+
self.video_click_signal.emit(7, "MBTN_RIGHT")
|
|
1675
1761
|
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1762
|
+
@p7.player.on_key_press("MBTN_LEFT_DBL")
|
|
1763
|
+
def mbtn_left_dbl7():
|
|
1764
|
+
self.video_click_signal.emit(7, "MBTN_LEFT_DBL")
|
|
1679
1765
|
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1766
|
+
@p7.player.on_key_press("MBTN_RIGHT_DBL")
|
|
1767
|
+
def mbtn_right_dbl7():
|
|
1768
|
+
self.video_click_signal.emit(7, "MBTN_RIGHT_DBL")
|
|
1683
1769
|
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1770
|
+
@p7.player.on_key_press("Ctrl+WHEEL_UP")
|
|
1771
|
+
def ctrl_wheel_up7():
|
|
1772
|
+
self.video_click_signal.emit(7, "Ctrl+WHEEL_UP")
|
|
1687
1773
|
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1774
|
+
@p7.player.on_key_press("Ctrl+WHEEL_DOWN")
|
|
1775
|
+
def ctrl_wheel_down7():
|
|
1776
|
+
self.video_click_signal.emit(7, "Ctrl+WHEEL_DOWN")
|
|
1691
1777
|
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1778
|
+
@p7.player.on_key_press("WHEEL_UP")
|
|
1779
|
+
def wheel_up7():
|
|
1780
|
+
self.video_click_signal.emit(7, "WHEEL_UP")
|
|
1695
1781
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1782
|
+
@p7.player.on_key_press("WHEEL_DOWN")
|
|
1783
|
+
def wheel_down7():
|
|
1784
|
+
self.video_click_signal.emit(7, "WHEEL_DOWN")
|
|
1699
1785
|
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1786
|
+
@p7.player.on_key_press("Shift+WHEEL_UP")
|
|
1787
|
+
def shift_wheel_up7():
|
|
1788
|
+
self.video_click_signal.emit(7, "Shift+WHEEL_UP")
|
|
1703
1789
|
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1790
|
+
@p7.player.on_key_press("Shift+WHEEL_DOWN")
|
|
1791
|
+
def shift_wheel_down7():
|
|
1792
|
+
self.video_click_signal.emit(7, "Shift+WHEEL_DOWN")
|
|
1707
1793
|
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1794
|
+
@p7.player.on_key_press("Shift+MBTN_LEFT")
|
|
1795
|
+
def shift_mbtn_left7():
|
|
1796
|
+
self.video_click_signal.emit(7, "Shift+MBTN_LEFT")
|
|
1711
1797
|
|
|
1712
|
-
|
|
1798
|
+
self.dw_player.append(p7)
|
|
1713
1799
|
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1800
|
+
self.dw_player[-1].setFloating(False)
|
|
1801
|
+
self.dw_player[-1].setVisible(False)
|
|
1802
|
+
self.dw_player[-1].setFeatures(QDockWidget.DockWidgetFloatable | QDockWidget.DockWidgetMovable)
|
|
1717
1803
|
|
|
1718
|
-
|
|
1719
|
-
|
|
1804
|
+
# place 4 players at the top of the main window and 4 at the bottom
|
|
1805
|
+
self.addDockWidget(Qt.TopDockWidgetArea if i < 4 else Qt.BottomDockWidgetArea, self.dw_player[-1])
|
|
1720
1806
|
|
|
1721
|
-
|
|
1807
|
+
self.dw_player[i].setVisible(True)
|
|
1722
1808
|
|
|
1723
|
-
|
|
1724
|
-
|
|
1809
|
+
# for receiving mouse event from frame viewer
|
|
1810
|
+
self.dw_player[i].frame_viewer.mouse_pressed_signal.connect(self.frame_image_clicked)
|
|
1725
1811
|
|
|
1726
|
-
|
|
1727
|
-
|
|
1812
|
+
# for receiving key event from dock widget
|
|
1813
|
+
self.dw_player[i].key_pressed_signal.connect(self.signal_from_widget)
|
|
1728
1814
|
|
|
1729
|
-
|
|
1730
|
-
|
|
1815
|
+
# for receiving event from volume slider
|
|
1816
|
+
self.dw_player[i].volume_slider_moved_signal.connect(self.set_volume)
|
|
1731
1817
|
|
|
1732
|
-
|
|
1733
|
-
|
|
1818
|
+
# for receiving event from mute toolbutton
|
|
1819
|
+
self.dw_player[i].mute_action_triggered_signal.connect(self.set_mute)
|
|
1734
1820
|
|
|
1735
|
-
|
|
1736
|
-
|
|
1821
|
+
# for receiving resize event from dock widget
|
|
1822
|
+
self.dw_player[i].resize_signal.connect(self.resize_dw)
|
|
1737
1823
|
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1824
|
+
# add durations list
|
|
1825
|
+
self.dw_player[i].media_durations: list = []
|
|
1826
|
+
self.dw_player[i].cumul_media_durations: List[int] = [0] # [idx for idx,x in enumerate(l) if l[idx-1]<pos<=x]
|
|
1741
1827
|
|
|
1742
|
-
|
|
1743
|
-
|
|
1828
|
+
# add fps list
|
|
1829
|
+
self.dw_player[i].fps = {}
|
|
1744
1830
|
|
|
1745
|
-
|
|
1746
|
-
|
|
1831
|
+
for mediaFile in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.FILE][n_player]:
|
|
1832
|
+
logging.debug(f"media file: {mediaFile}")
|
|
1747
1833
|
|
|
1748
|
-
|
|
1834
|
+
media_full_path = project_functions.full_path(mediaFile, self.projectFileName)
|
|
1749
1835
|
|
|
1750
|
-
|
|
1836
|
+
logging.debug(f"media_full_path: {media_full_path}")
|
|
1751
1837
|
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1838
|
+
# media duration
|
|
1839
|
+
try:
|
|
1840
|
+
mediaLength = self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.LENGTH][mediaFile] * 1000
|
|
1841
|
+
mediaFPS = self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.FPS][mediaFile]
|
|
1842
|
+
except Exception:
|
|
1843
|
+
logging.debug("media_info key not found in project")
|
|
1758
1844
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1845
|
+
r = util.accurate_media_analysis(self.ffmpeg_bin, media_full_path)
|
|
1846
|
+
if "error" not in r:
|
|
1847
|
+
if cfg.MEDIA_INFO not in self.pj[cfg.OBSERVATIONS][self.observationId]:
|
|
1848
|
+
self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO] = {
|
|
1849
|
+
cfg.LENGTH: {},
|
|
1850
|
+
cfg.FPS: {},
|
|
1851
|
+
}
|
|
1852
|
+
if cfg.LENGTH not in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1853
|
+
self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.LENGTH] = {}
|
|
1854
|
+
if cfg.FPS not in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1855
|
+
self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.FPS] = {}
|
|
1770
1856
|
|
|
1771
|
-
|
|
1772
|
-
|
|
1857
|
+
self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.LENGTH][mediaFile] = r["duration"]
|
|
1858
|
+
self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.FPS][mediaFile] = r[cfg.FPS]
|
|
1773
1859
|
|
|
1774
|
-
|
|
1775
|
-
|
|
1860
|
+
mediaLength = r["duration"] * 1000
|
|
1861
|
+
mediaFPS = r[cfg.FPS]
|
|
1776
1862
|
|
|
1777
|
-
|
|
1863
|
+
self.project_changed()
|
|
1778
1864
|
|
|
1779
|
-
|
|
1780
|
-
|
|
1865
|
+
self.dw_player[i].media_durations.append(int(mediaLength))
|
|
1866
|
+
self.dw_player[i].cumul_media_durations.append(self.dw_player[i].cumul_media_durations[-1] + int(mediaLength))
|
|
1781
1867
|
|
|
1782
|
-
|
|
1868
|
+
self.dw_player[i].fps[mediaFile] = mediaFPS
|
|
1783
1869
|
|
|
1784
|
-
|
|
1785
|
-
|
|
1870
|
+
# add media file to playlist
|
|
1871
|
+
self.dw_player[i].player.playlist_append(media_full_path)
|
|
1786
1872
|
|
|
1787
|
-
|
|
1788
|
-
|
|
1873
|
+
# add media file name to player window title
|
|
1874
|
+
self.dw_player[i].setWindowTitle(f"Player #{i + 1} ({pl.Path(media_full_path).name})")
|
|
1789
1875
|
|
|
1790
|
-
|
|
1791
|
-
|
|
1876
|
+
# media duration cumuled in seconds
|
|
1877
|
+
self.dw_player[i].cumul_media_durations_sec = [round(dec(x / 1000), 3) for x in self.dw_player[i].cumul_media_durations]
|
|
1792
1878
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1879
|
+
# check if BORIS is running on a Windows VM with the 'WMIC COMPUTERSYSTEM GET SERIALNUMBER' command
|
|
1880
|
+
# because "auto" or "auto-safe" crash in Windows VM
|
|
1881
|
+
# see https://superuser.com/questions/1128339/how-can-i-detect-if-im-within-a-vm-or-not
|
|
1796
1882
|
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1883
|
+
flag_vm = False
|
|
1884
|
+
if sys.platform.startswith("win"):
|
|
1885
|
+
p = subprocess.Popen(
|
|
1886
|
+
["WMIC", "BIOS", "GET", "SERIALNUMBER"],
|
|
1887
|
+
stdout=subprocess.PIPE,
|
|
1888
|
+
stderr=subprocess.PIPE,
|
|
1889
|
+
shell=True,
|
|
1890
|
+
)
|
|
1891
|
+
out, _ = p.communicate()
|
|
1892
|
+
flag_vm = b"SerialNumber \r\r\n0 " in out
|
|
1893
|
+
logging.debug(f"Running on Windows VM: {flag_vm}")
|
|
1808
1894
|
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
# position media
|
|
1830
|
-
if cfg.OBSERVATION_TIME_INTERVAL in self.pj[cfg.OBSERVATIONS][self.observationId]:
|
|
1831
|
-
self.seek_mediaplayer(int(self.pj[cfg.OBSERVATIONS][self.observationId][cfg.OBSERVATION_TIME_INTERVAL][0]), player=i)
|
|
1832
|
-
|
|
1833
|
-
# restore video zoom level
|
|
1834
|
-
if cfg.ZOOM_LEVEL in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1835
|
-
self.dw_player[i].player.video_zoom = log2(
|
|
1836
|
-
self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.ZOOM_LEVEL].get(n_player, 0)
|
|
1895
|
+
if not flag_vm:
|
|
1896
|
+
self.dw_player[i].player.hwdec = self.config_param.get(cfg.MPV_HWDEC, cfg.MPV_HWDEC_DEFAULT_VALUE)
|
|
1897
|
+
else:
|
|
1898
|
+
self.dw_player[i].player.hwdec = cfg.MPV_HWDEC_NO
|
|
1899
|
+
|
|
1900
|
+
logging.debug(f"Player hwdec of player #{i} set to: {self.dw_player[i].player.hwdec}")
|
|
1901
|
+
self.config_param[cfg.MPV_HWDEC] = self.dw_player[i].player.hwdec
|
|
1902
|
+
|
|
1903
|
+
self.dw_player[i].player.playlist_pos = 0
|
|
1904
|
+
self.dw_player[i].player.wait_until_playing()
|
|
1905
|
+
self.dw_player[i].player.pause = True
|
|
1906
|
+
time.sleep(0.2)
|
|
1907
|
+
# self.dw_player[i].player.wait_until_paused()
|
|
1908
|
+
self.dw_player[i].player.seek(0, "absolute")
|
|
1909
|
+
# do not close when playing finished
|
|
1910
|
+
self.dw_player[i].player.keep_open = True
|
|
1911
|
+
self.dw_player[i].player.keep_open_pause = False
|
|
1912
|
+
|
|
1913
|
+
self.dw_player[i].player.image_display_duration = self.pj[cfg.OBSERVATIONS][self.observationId].get(
|
|
1914
|
+
cfg.IMAGE_DISPLAY_DURATION, 1
|
|
1837
1915
|
)
|
|
1838
1916
|
|
|
1839
|
-
|
|
1840
|
-
|
|
1841
|
-
|
|
1842
|
-
if cfg.PAN_Y in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1843
|
-
self.dw_player[i].player.video_pan_y = self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.PAN_Y].get(n_player, 0)
|
|
1917
|
+
# position media
|
|
1918
|
+
if cfg.OBSERVATION_TIME_INTERVAL in self.pj[cfg.OBSERVATIONS][self.observationId]:
|
|
1919
|
+
self.seek_mediaplayer(int(self.pj[cfg.OBSERVATIONS][self.observationId][cfg.OBSERVATION_TIME_INTERVAL][0]), player=i)
|
|
1844
1920
|
|
|
1845
|
-
|
|
1846
|
-
|
|
1847
|
-
|
|
1848
|
-
|
|
1849
|
-
|
|
1921
|
+
# restore video zoom level
|
|
1922
|
+
if cfg.ZOOM_LEVEL in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1923
|
+
self.dw_player[i].player.video_zoom = log2(
|
|
1924
|
+
self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.ZOOM_LEVEL].get(n_player, 0)
|
|
1925
|
+
)
|
|
1850
1926
|
|
|
1851
|
-
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1927
|
+
# restore video pan
|
|
1928
|
+
if cfg.PAN_X in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1929
|
+
self.dw_player[i].player.video_pan_x = self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.PAN_X].get(
|
|
1930
|
+
n_player, 0
|
|
1931
|
+
)
|
|
1932
|
+
if cfg.PAN_Y in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1933
|
+
self.dw_player[i].player.video_pan_y = self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.PAN_Y].get(
|
|
1934
|
+
n_player, 0
|
|
1935
|
+
)
|
|
1856
1936
|
|
|
1857
|
-
|
|
1858
|
-
|
|
1859
|
-
|
|
1860
|
-
|
|
1861
|
-
|
|
1937
|
+
# restore rotation angle
|
|
1938
|
+
if cfg.ROTATION_ANGLE in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1939
|
+
self.dw_player[i].player.video_rotate = self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][
|
|
1940
|
+
cfg.ROTATION_ANGLE
|
|
1941
|
+
].get(n_player, 0)
|
|
1942
|
+
|
|
1943
|
+
# restore subtitle visibility
|
|
1944
|
+
if cfg.DISPLAY_MEDIA_SUBTITLES in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1945
|
+
self.dw_player[i].player.sub_visibility = self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][
|
|
1946
|
+
cfg.DISPLAY_MEDIA_SUBTITLES
|
|
1947
|
+
].get(n_player, True)
|
|
1948
|
+
|
|
1949
|
+
# restore overlays
|
|
1950
|
+
if cfg.OVERLAY in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO]:
|
|
1951
|
+
if n_player in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.MEDIA_INFO][cfg.OVERLAY]:
|
|
1952
|
+
self.overlays[i] = self.dw_player[i].player.create_image_overlay()
|
|
1953
|
+
self.resize_dw(i)
|
|
1954
|
+
|
|
1955
|
+
else: # macos
|
|
1956
|
+
print(self.pj[cfg.OBSERVATIONS][self.observationId][cfg.FILE])
|
|
1957
|
+
|
|
1958
|
+
for mediaFile in self.pj[cfg.OBSERVATIONS][self.observationId][cfg.FILE]["1"]:
|
|
1959
|
+
logging.debug(f"media file: {mediaFile}")
|
|
1960
|
+
|
|
1961
|
+
media_full_path = project_functions.full_path(mediaFile, self.projectFileName)
|
|
1962
|
+
send_command({"command": ["loadfile", media_full_path]})
|
|
1963
|
+
# pause
|
|
1964
|
+
send_command({"command": ["set_property", "pause", True]})
|
|
1965
|
+
send_command({"command": ["set_property", "time-pos", 0]})
|
|
1862
1966
|
|
|
1863
1967
|
menu_options.update_menu(self)
|
|
1864
1968
|
|
|
@@ -2049,8 +2153,9 @@ def initialize_new_media_observation(self) -> bool:
|
|
|
2049
2153
|
self.load_tw_events(self.observationId)
|
|
2050
2154
|
|
|
2051
2155
|
# initial synchro
|
|
2052
|
-
|
|
2053
|
-
|
|
2156
|
+
if not sys.platform.startswith(cfg.MACOS_CODE):
|
|
2157
|
+
for n_player in range(1, len(self.dw_player)):
|
|
2158
|
+
self.sync_time(n_player, 0)
|
|
2054
2159
|
|
|
2055
2160
|
self.mpv_timer_out(value=0.0)
|
|
2056
2161
|
|