| 1 |
import av |
| 2 |
|
| 3 |
av.logging.set_level(av.logging.VERBOSE) |
| 4 |
|
| 5 |
input_ = av.open("resources/webvtt.mkv") |
| 6 |
output = av.open("remuxed.vtt", "w") |
| 7 |
|
| 8 |
in_stream = input_.streams.subtitles[0] |
| 9 |
out_stream = output.add_stream_from_template(in_stream) |
| 10 |
|
| 11 |
for packet in input_.demux(in_stream): |
| 12 |
if packet.size == 0: |
| 13 |
continue |
| 14 |
packet.stream = out_stream |
| 15 |
output.mux(packet) |
| 16 |
|
| 17 |
input_.close() |
| 18 |
output.close() |
| 19 |
|
| 20 |
print("Remuxing done") |
| 21 |
|
| 22 |
with av.open("remuxed.vtt") as f: |
| 23 |
for subset in f.decode(subtitles=0): |
| 24 |
for sub in subset: |
| 25 |
print(sub.ass) |