06:21
I am currently working on a project where I need to stream video from an RTSP source, convert it to FLV format using FFmpeg, and then send the FLV stream to clients upon request. The code I have written to achieve this is as follows:
import subprocess
from flask import Flask, Response, stream_with_context
app = Flask(__name__)
flv_header = b''
def update_stream(ffmpeg_path="ffmpeg", rtsp_url='rtsp://192.168.1.168/0', rtsp_id="rtsp01"):
global flv_header
command = [
ffmpeg_path,
'-i', rtsp_url,
(...)
05:47
On ffmpeg version 7.0, using sendcmd doesn't work with instance names.
Ideally I wouldn't use the PARSED_x_filter syntax
Simple repro
import subprocess
input_vid = "../input_file.mp4"
output_vid = "/tmp/output.mp4"
send_cmd_file = "/tmp/face_follow_cmd.txt"
duration = 17
with open(send_cmd_file, "w") as f:
for i in range(duration):
f.write(f"i crop_4 x i*10;\\n")
(9/16):in_h:0:0[pad_a];[0:v]cropⓐcrop_1=in_h*(9/16):in_h:0:0,sendcmd=f=send_cmd_file' -c:v h264_videotoolbox output_vid"
command = f"ffmpeg -y -i input_vid (...)