- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在通过 http google cloud 功能在上传的视频中添加水印,但我的代码在非零的 ffmpeg 上返回。我的python代码
import os
from google.cloud import storage
from subprocess import check_output
from videoprops import get_video_properties
def hello_world(request):
client = storage.Client()
bucket = client.get_bucket('bucket_name')
request_json = request.get_json()
req_data = request.get_json()
name = req_data['file']
videofile_name = req_data['file_name']
os.makedirs('/tmp/'+os.path.dirname(name), exist_ok=True)
file_name = '/tmp/' + name
output_file_name = '/tmp/' + name.split('.')[0] + '_.'+name.split('.')[1]
print(output_file_name)
logo_path = '/temp/watermark.png'
logo_name = 'watermark.png'
print('logo found')
print(file_name)
try:
os.remove(file_name)
except OSError:
pass
try:
os.remove(logo_path)
except OSError:
pass
print("File has been removed")
# Downloading the video to the cloud functions
blob = bucket.get_blob(name)
blob.download_to_filename(file_name)
blob_logo = bucket.get_blob(logo_name)
blob_logo.download_to_filename(logo_path)
print("Video Downloaded")
props = get_video_properties(file_name)
if os.path.exists(file_name):
print("NEW MP4 EXISTS")
# check_output('ffmpeg -itsoffset -4 -i '+file_name+' -vcodec mjpeg -vframes 1 -an -f rawvideo -s '+str(props['width'])+'x'+str(props['height'])+' '+thumbnail_file_name, shell=True)
# thumbnail_blob = bucket.blob(os.path.dirname(name)+'/thumbnail.jpg')
# thumbnail_blob.upload_from_filename(thumbnail_file_name)
# 19-7-2020
check_output('ffmpeg -i '+file_name+' -i '+logo_path +
' -filter_complex overlay=10:10 -codec:a copy -preset ultrafast -async 1 '+output_file_name, shell=True)
thumbnail_blob = bucket.blob(
os.path.dirname(name) + '/'+videofile_name)
thumbnail_blob.upload_from_filename(output_file_name)
# -------------------------------------
else:
print("MP4 not created")
print("uploaded")
在这段访问视频的代码中,添加水印也可以从存储桶访问并使用 ffmpeg 应用并上传。
最佳答案
我已经解决并在谷歌云功能中使用了 http 请求基础触发器。将来可能对某人有所帮助
import os
import os.path
from google.cloud import storage
from subprocess import check_output
from videoprops import get_video_properties
def hello_world(request):
"""Responds to any HTTP request.
Args:
request (flask.Request): HTTP request object.
Returns:
The response text or any set of values that can be turned into a
Response object using
# flask.Flask.make_response>`.
`make_response <http://flask.pocoo.org/docs/1.0/api/
"""
client = storage.Client()
bucket = client.get_bucket('showtalentbucket')
request_json = request.get_json()
req_data = request.get_json()
name = req_data['file']
videofile_name = req_data['file_name']
os.makedirs('/tmp/'+os.path.dirname(name), exist_ok=True)
file_name = '/tmp/' + name
output_file_name = '/tmp/' + name.split('.')[0] + '_.'+name.split('.')[1]
mp4_output_file_name = '/tmp/' + \
name.split('.')[0] + '__.'+name.split('.')[1]
print(output_file_name)
logo_path = '/tmp/watermark.png'
logo_name = 'watermark.png'
print('logo found')
print(file_name)
try:
os.remove(file_name)
except OSError:
pass
try:
os.remove(logo_path)
except OSError:
pass
print("File has been removed")
# Downloading the video to the cloud functions
blob = bucket.get_blob(name)
blob.download_to_filename(file_name)
blob_logo = bucket.get_blob(logo_name)
blob_logo.download_to_filename(logo_path)
print("Video Downloaded")
props = get_video_properties(file_name)
if os.path.exists(file_name):
print("NEW MP4 EXISTS")
check_output('ffmpeg -i '+file_name+' -i '+logo_path +
' -filter_complex overlay=10:10 -codec:a copy -preset ultrafast -async 1 '+output_file_name, shell=True)
if os.path.splitext(name)[1].lower().startswith('.mov'):
check_output('ffmpeg -itsoffset -4 -i '+output_file_name +
' -acodec copy -vcodec copy -f mov '+mp4_output_file_name, shell=True)
thumbnail_blob = bucket.blob(
os.path.dirname(name) + '/'+videofile_name)
thumbnail_blob.upload_from_filename(mp4_output_file_name)
else:
thumbnail_blob = bucket.blob(
os.path.dirname(name) + '/'+videofile_name)
thumbnail_blob.upload_from_filename(output_file_name)
# -------------------------------------
else:
print("MP4 not created")
print("uploaded")
关于python-3.x - 使用 Google Cloud 函数 python 在视频中添加水印,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63180955/
我正在尝试使用水印并使用复杂过滤器应用 Yadif,但我无法弄清楚如何使用以下语法应用 Yadif ffmpeg -i "source:" -i C:\logo.png -c:v libx264 -p
我正在使用 zubrags PHP 水印脚本(附在下面),它工作得很好,除非我尝试使用 PNG-24 作为我的水印。生成的图像有一个乱码、不透明的水印。我想知道是否有人可以帮助解释我需要在下面的脚本中
基本上,我想拍摄用户从照片库中选择的图像,然后应用水印,即右下角的一个三角形,上面有应用程序名称。我已经在 Photoshop 中使用透明层制作了第二张图像。 我尝试了一个函数,我不记得它的确切名称,
Closed. This question needs to be more focused。它当前不接受答案。 想改善这个问题吗?更新问题,使其仅关注editing this post的一个问题。
这个问题我已经发了很多次了,但还是找不到正确的答案。我的目标是加载 PDF(扫描的调查问卷页),用页码标记每个页面,并将每个页面保存在单独的 JPEG 文件中以供以后使用。除了未绘制 NSString
你好,我的代码有问题 $obj = new stdClass(); $obj->cat_id = !empty($_POST['cat_id']) ? $_POST['cat_id']
SO 上有很多类似的问题/答案,但似乎没有一个能解决我的问题。 我的目标是使用 Paperclip 为图像生成“动态水印”(用户头像覆盖在另一张图像上)。我遇到的问题是我无法获得模型的“user_id
我想在我的图片上添加水印,这是我用来截图的代码。有人可以教我如何在图像中添加水印吗?我想在图片的右上角有一个小 Logo 。 我正在尝试研究是否可以实现我在 Canvas 中保留的内容,以便在截取屏幕
我有以下命令: ffmpeg -ss 00:00:30 -i "$i" -i ../audio.mov -map 0:0 -map 1:0 -to 30 -vf "fade=in:0:24, fade
我正在尝试从一些图片以及现有的 mp3(复制)制作幻灯片。图片尺寸不同,但我希望视频输出为 16:9 纵横比和 3840x2160。我也想要水印。重要的是不要拉伸(stretch)图片。 我试过这个代
我已经可以给任何 PDF 加水印,里面的图像,一切正常,但现在我只需要在打印 PDF 时才显示水印......这可能吗?如何? 我当然需要以编程方式执行此操作。 最佳答案 对于 future 的读者,
有没有办法在整个网页上创建浅色透明水印?一个留在屏幕上,即使它滚动?我的想法是创建一个 .PNG 位图并使用带有样式表的 DIV 标签,该样式表将我的 PNG 设置为背景图像,并设置绝对位置。问题是,
是否可以屏蔽应用程序的屏幕截图(电源 + 菜单按钮)?如果没有,此屏幕截图是否有可能收到水印? 问候,克劳迪奥 最佳答案 创建屏幕截图是一种系统行为,您不能覆盖它。 重复 Notification o
所以我一直在寻找如何为图像添加带有 colorBox 的水印,我在谷歌的第一个结果中找到了一个较旧的 colorBox 组,下一个答案是: Jack Moore 10/3/09 Ok, this sh
我有以下 CSS, #duplicateCopy { -webkit-transform:rotate(-20deg); -moz-transform:rotate(-20deg);
我有一个 pdf在它的背景上有水印。当开始扫描以在背景中突出显示带有水印或注释的任何单词时,它会被选中,因为它首先在触摸区域中找到。 我正在使用 CGPDFScanner 扫描文本。 我的问题是如何检
我正在寻找一种在选定字段上放置水印的方法。 那是行不通的-> [select* c_type class:ic watermark "choose type" "a" "b" "c"] 为了放置验证失
我正在尝试向视频添加各种 Gifs/水印,但我无法让它正常工作。 我们假设视频时长为 60 秒,我正在添加一张 Gif 图片。输出看起来正确,声音打开,gif 动画,视频没有停止。这是代码:
我正在尝试使用 FFmpeg 以编程方式将图像或视频叠加在另一个视频的顶部。似乎 AVFilter 可以做到这一点。 有很多关于如何使用命令行执行此操作或类似操作的示例,但是,除了 doc/examp
我正在尝试实现类似 StackOverflow 的水印功能。 我正在使用 jquery-watermark为了这。我遇到的问题是水印文本随着输入元素获得焦点而消失,这在 SO 中不会发生(我也不希望在
我是一名优秀的程序员,十分优秀!