How to add DataStream to Container #1636
-
Working with mpegts videos that container KLV data. ffprove output: Download video from: https://samples.ffmpeg.org/MPEG2/mpegts-klv/ I am unable to determine the syntax for adding a data stream to a container. Here is the example code I am using to test different codec_name and parameters. python strip_data.py -i day_flight.mpg -o klv.data # strip_data.py
from contextlib import closing, ExitStack
import av
def extract_data_stream(src_file, dst_file):
with ExitStack() as stack:
src_c = stack.enter_context(closing(av.open(src_file, mode="r")))
src_s = src_c.streams.data[0]
# I have tried multiple formats
dst_c = stack.enter_context(closing(av.open(dst_file, format="data", mode="w")))
# How to add "data" stream
dst_s = dst_c.add_stream(codec_name="?", template=src_s)
for src_p in src_c.demux(src_s):
for dst_p in dst_s.encode(src_p):
dst_c.mux(dst_p)
if __name__ == "__main__":
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("-i", type=str, required=True)
parser.add_argument("-o", type=str, required=True)
args = parser.parse_args()
extract_data_stream(args.i, args.o) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
It's not possible to add datastreams in the latest stable version of PyAV right now |
Beta Was this translation helpful? Give feedback.
It's not possible to add datastreams in the latest stable version of PyAV right now