Skip to content

Commit 4f888e6

Browse files
committed
Fix
1 parent 2c938fa commit 4f888e6

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

.gitmodules

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "examples"]
2-
path = examples
3-
url = https://github.com/JumpCutter/JC-examples.git
1+
[submodule "JC-examples"]
2+
path = JC-examples
3+
url = git@github.com:JumpCutter/JC-examples

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Change Log
22

3+
## [0.0.3](https://github.com/JumpCutter/JC-render/compare/v0.0.2...v0.0.3) (04-01-2021)
4+
5+
### Bug Fixes
6+
- __Pixel Aspect Ratio__: added pixel aspect ratio for xml
7+
8+
39
## [0.0.2](https://github.com/JumpCutter/JC-render/compare/v0.0.1...v0.0.2) (03-22-2021)
410

511
### Bug Fixes

examples

Lines changed: 0 additions & 1 deletion
This file was deleted.

render.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,8 @@ class Render:
105105
"""the current logging socket"""
106106
thread_alloc = 0
107107
"""the number of treads to allocate where 0=all"""
108+
pixel_aspect_ratio = 1.0
109+
"""the calculated pixel aspect ratio"""
108110

109111
def __init__(self, # NOQA
110112
json_file: str,
@@ -278,6 +280,15 @@ def has_stream(self, file_name, stream='v'): # NOQA
278280
select_streams=stream)
279281
if stream == 'v':
280282
self._handle_video_detection(probe_streams)
283+
display_aspect_ratio = probe_all['streams'][0].get('display_aspect_ratio')
284+
sample_aspect_ratio = probe_all['streams'][0].get('sample_aspect_ratio')
285+
if display_aspect_ratio and sample_aspect_ratio:
286+
dar = display_aspect_ratio.split(":")
287+
sar = sample_aspect_ratio.split(":")
288+
res = self.resolution.split("x")
289+
x_pixel_ratio = float(res[1]) * float(dar[0]) / float(sar[0])
290+
y_pixel_ratio = float(res[0]) * float(dar[1]) / float(sar[1])
291+
self.pixel_aspect_ratio = x_pixel_ratio / y_pixel_ratio
281292
if probe_streams['streams']:
282293
hasit = True
283294
except Exception as e:
@@ -1051,6 +1062,8 @@ def export(self, name: str = None): # NOQA
10511062
xml_height.text = height
10521063
xml_width = ET.Element("width")
10531064
xml_width.text = width
1065+
xml_pixel_aspect_ratio = ET.Element("pixelaspectratio")
1066+
xml_pixel_aspect_ratio.text = str(self.pixel_aspect_ratio)
10541067
xml_chars = ET.Element(
10551068
"samplecharacteristics",
10561069
)
@@ -1060,6 +1073,9 @@ def export(self, name: str = None): # NOQA
10601073
xml_chars.append(
10611074
xml_width
10621075
)
1076+
xml_chars.append(
1077+
xml_pixel_aspect_ratio
1078+
)
10631079
# )
10641080
xml_format = ET.Element(
10651081
"format"

tests/test_renderer.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
# import threading
66
import json
77

8+
JSON_EXAMPLE = 'JC-examples/yoga.json'
89

910
@pytest.mark.render
1011
@pytest.mark.ffmpeg
1112
def test_render():
12-
r = Render('output.json', './tmp',
13+
r = Render(JSON_EXAMPLE, './tmp',
1314
no_clean=True,
1415
silent_log=True,
1516
thread_alloc=2,
@@ -28,7 +29,7 @@ def test_render():
2829
@pytest.mark.ffmpeg
2930
@pytest.mark.xml
3031
def test_export_xml():
31-
r = Render('output.json', './tmp',
32+
r = Render(JSON_EXAMPLE, './tmp',
3233
no_clean=True,
3334
# markers=True,
3435
# readable=True,
@@ -40,7 +41,7 @@ def test_export_xml():
4041
@pytest.mark.ffmpeg
4142
@pytest.mark.fcpxml
4243
def test_export_fcpxml():
43-
r = Render('output.json', './tmp',
44+
r = Render(JSON_EXAMPLE, './tmp',
4445
no_clean=True,
4546
# markers=True,
4647
# readable=True,
@@ -52,7 +53,7 @@ def test_export_fcpxml():
5253
@pytest.mark.ffmpeg
5354
@pytest.mark.edl
5455
def test_export_edl():
55-
r = Render('output.json', './tmp',
56+
r = Render(JSON_EXAMPLE, './tmp',
5657
no_clean=True,
5758
# readable=True,
5859
verbose=False, vcodec='edl')
@@ -63,7 +64,7 @@ def test_export_edl():
6364
@pytest.mark.ffmpeg
6465
@pytest.mark.otio
6566
def test_export_otio():
66-
r = Render('output.json', './tmp',
67+
r = Render(JSON_EXAMPLE, './tmp',
6768
no_clean=True,
6869
# readable=True,
6970
verbose=False, vcodec='otio')
@@ -74,7 +75,7 @@ def test_export_otio():
7475
@pytest.mark.ffmpeg
7576
@pytest.mark.aaf
7677
def test_export_aaf():
77-
r = Render('output.json', './tmp',
78+
r = Render(JSON_EXAMPLE, './tmp',
7879
no_clean=True,
7980
# readable=True,
8081
verbose=False, vcodec='aaf')
@@ -84,7 +85,7 @@ def test_export_aaf():
8485
@pytest.mark.probe
8586
@pytest.mark.ffmpeg
8687
def test_probe():
87-
r = Render('output.json', './tmp', True, vcodec='h264')
88+
r = Render(JSON_EXAMPLE, './tmp', True, vcodec='h264')
8889
input_data = r.get_json(r.json_file)
8990
probe_res = ffprobe(input_data['layers'][0][0]['sourceFile'])
9091
print(json.dumps(probe_res, indent=2))
@@ -93,7 +94,7 @@ def test_probe():
9394
@pytest.mark.probe_audio
9495
@pytest.mark.ffmpeg
9596
def test_audio():
96-
r = Render('output.json', './tmp', True, vcodec='h264')
97+
r = Render(JSON_EXAMPLE, './tmp', True, vcodec='h264')
9798
input_data = r.get_json(r.json_file)
9899
layer = input_data['layers'][0][0]['sourceFile']
99100
probe_res = ffprobe(layer, select_streams='a')

0 commit comments

Comments
 (0)