09:54
I am trying to add a text to a video using ffmpeg and python.
I tried to do this in the following ways, but it didn't work.
first
(
ffmpeg
.input(in_video)
.filter('drawtext',
fontsize=30,
fontfile=r"D:\\projects\\python\\editor_bot\\downloads\\Candara.ttf",
text='test test test.',
x='if (eq(mod(t\\\\, 15)\\\\, 0)\\\\, rand(0\\\\, (w-text_w))\\\\, x)',
y='if (eq(mod(t\\\\, 10)\\\\, 0)\\\\, rand(0\\\\, (h-text_h))\\\\, y)')
.output(f'output-final.mp4')
.run()
)
second
fil = (...)
09:48
I want to show the video on the browser streamed by ffmpeg.
Here's the python script which i made but can't find the way to do so since i am not much into javascript. Can anyone help me please ?
import socketio
import subprocess
import uvicorn
sio = socketio.AsyncServer(async_mode='asgi', cors_allowed_origins='*')
app = socketio.ASGIApp(sio)
ⓐsio.event
async def connect(sid, environ):
await sio.enter_room(sid, 'Streaming')
ⓐsio.event
async def stream(cid):
video_path = (...)
08:12
I am trying to use a custom font in the subtitles of a video using ffmpeg, but despite my efforts, the font defaults to Helvetica. Here is the code I am using:
import ffmpeg
import os
import tempfile
def test_subtitle_font(font_path):
# Simple arbitrary video and audio stream
video = ffmpeg.input('color=color=black:size=640x360:duration=5', f='lavfi')
audio = ffmpeg.input('anullsrc=channel_layout=stereo:duration=5', f='lavfi')
# Create arbitrary temp subtitle file
with (...)