Created
October 12, 2011 15:46
-
-
Save youzaka/1281577 to your computer and use it in GitHub Desktop.
保存したtsファイルでなく、recpt1から直接Transport Streamをいじる
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env python | |
# coding: utf-8 | |
from subprocess import Popen, PIPE | |
import array | |
import itertools | |
import shlex | |
def stream(ch): | |
a = Popen(shlex.split("recpt1 {:d} - -".format(ch)), stdout=PIPE) | |
packet = array.array('B') | |
for bytes in iter(a.stdout.readline, ""): | |
for byte in bytes: | |
if byte == 0x47: | |
if len(packet) == 188: | |
yield packet | |
packet = array.array('B') | |
packet.append(byte) | |
# 151: BS-asahi | |
for packet in stream(151): | |
do_something(packet) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment