Skip to content

Instantly share code, notes, and snippets.

@youzaka
Created October 12, 2011 15:46
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save youzaka/1281577 to your computer and use it in GitHub Desktop.
Save youzaka/1281577 to your computer and use it in GitHub Desktop.
保存したtsファイルでなく、recpt1から直接Transport Streamをいじる
#/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