Skip to content

Commit 160dba1

Browse files
committed
fix start_encode2
1 parent 59fdb14 commit 160dba1

4 files changed

Lines changed: 30 additions & 0 deletions

File tree

docs/usage.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,26 @@ VIDEO_CODEC = qencode.x264_video_codec()
8181
DESTINATION.url = "..."
8282
DESTINATION.key = "..."
8383
DESTINATION.secret = "..."
84+
DESTINATION.remove_null_params()
8485
8586
VIDEO_CODEC.vprofile = "baseline"
8687
VIDEO_CODEC.level = 31
8788
VIDEO_CODEC.coder = 0
8889
VIDEO_CODEC.flags2 = "-bpyramid+fastpskip-dct8x8"
8990
VIDEO_CODEC.partitions = "+parti8x8+parti4x4+partp8x8+partb8x8"
9091
VIDEO_CODEC.directpred = 2
92+
VIDEO_CODEC.remove_null_params()
9193
9294
STREAM.profile = "baseline"
9395
STREAM.size = "1920x1080"
9496
STREAM.audio_bitrate = 128
9597
STREAM.video_codec_parameters = VIDEO_CODEC
98+
STREAM.remove_null_params()
9699
97100
FORMAT.stream = [STREAM]
98101
FORMAT.output = "advanced_hls"
99102
FORMAT.destination = DESTINATION
103+
FORMAT.remove_null_params()
100104
101105
params.source = 'your source url'
102106
params.format = [FORMAT]

qencode/custom_params.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
from json import JSONEncoder
3+
from utils import rm_key_if_null
34

45
class CustomTranscodingParams(object):
56
"""CustomTranscodingParams
@@ -12,6 +13,9 @@ def __init__(self):
1213
self.source = None
1314
self.format = None
1415

16+
def remove_null_params(self):
17+
rm_key_if_null(self)
18+
1519
class Format(object):
1620
"""
1721
:var
@@ -25,12 +29,18 @@ def __init__(self):
2529
self.segment_duration = None
2630
self.stream = None
2731

32+
def remove_null_params(self):
33+
rm_key_if_null(self)
34+
2835
class Destination(object):
2936
def __init__(self):
3037
self.url = None
3138
self.key = None
3239
self.secret = None
3340

41+
def remove_null_params(self):
42+
rm_key_if_null(self)
43+
3444
class Stream(object):
3545
def __init__(self):
3646
self.size = None
@@ -52,6 +62,10 @@ def __init__(self):
5262
self.audio_codec = None
5363
self.downmix_mode = None
5464

65+
def remove_null_params(self):
66+
rm_key_if_null(self)
67+
68+
5569

5670
class Libx264_VideoCodecParameters(object):
5771
def __init__(self):
@@ -64,6 +78,9 @@ def __init__(self):
6478
self.directpred = None
6579
self.me_method = None
6680

81+
def remove_null_params(self):
82+
rm_key_if_null(self)
83+
6784
class Libx265_VideoCodecParameters(object):
6885
def __init__(self):
6986
pass

qencode/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ def get_percent(p):
1313
return round(p)
1414
return 0
1515

16+
def rm_key_if_null(class_obj):
17+
for key, val in class_obj.__dict__.items():
18+
if not val:
19+
class_obj.__dict__.pop(key)
20+
1621
def progress_bar(self, custom_message=None):
1722
message = custom_message if custom_message else ''
1823
while 1:

sample-code/start_encode2.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,26 @@
2020
DESTINATION.url = "s3://s3-eu-west-2.amazonaws.com/qencode-test"
2121
DESTINATION.key = "AKIAIKZIPSJ7SDAIWK4A"
2222
DESTINATION.secret = "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"
23+
DESTINATION.remove_null_params()
2324

2425
VIDEO_CODEC.vprofile = "baseline"
2526
VIDEO_CODEC.level = 31
2627
VIDEO_CODEC.coder = 0
2728
VIDEO_CODEC.flags2 = "-bpyramid+fastpskip-dct8x8"
2829
VIDEO_CODEC.partitions = "+parti8x8+parti4x4+partp8x8+partb8x8"
2930
VIDEO_CODEC.directpred = 2
31+
VIDEO_CODEC.remove_null_params()
3032

3133
STREAM.profile = "baseline"
3234
STREAM.size = "1920x1080"
3335
STREAM.audio_bitrate = 128
3436
STREAM.video_codec_parameters = VIDEO_CODEC
37+
STREAM.remove_null_params()
3538

3639
FORMAT.stream = [STREAM]
3740
FORMAT.output = "advanced_hls"
3841
FORMAT.destination = DESTINATION
42+
FORMAT.remove_null_params()
3943

4044
params.source = 'https://qa.qencode.com/static/1.mp4'
4145
params.format = [FORMAT]

0 commit comments

Comments
 (0)