Allow player to exit cleanly

- can't emit Terminate opcode in the middle of the bytestream
- pad the TCP stream to next 2k boundary when emitting terminate opcode,
  since the player will block until receiving this much data.
This commit is contained in:
kris
2019-03-23 21:46:35 +00:00
parent 8ffc8efaac
commit 531a6ae345
2 changed files with 15 additions and 9 deletions

View File

@ -29,12 +29,12 @@ def main(args):
m = movie.Movie(
filename,
every_n_video_frames=args.every_n_video_frames,
audio_normalization=args.audio_normalization)
audio_normalization=args.audio_normalization,
max_bytes_out = 1024. * 1024 * args.max_output_mb
)
print("Input frame rate = %f" % m.video.input_frame_rate)
max_bytes_out = 1024. * 1024 * args.max_output_mb
if args.output:
out_filename = args.output
else:
@ -45,11 +45,6 @@ def main(args):
for bytes_out, b in enumerate(m.emit_stream(m.encode())):
out.write(bytearray([b]))
if max_bytes_out and bytes_out >= max_bytes_out:
break
out.write(bytes(m.done()))
if __name__ == "__main__":
main(parser.parse_args())