我有一个案例,我需要在视频中间插入一帧(或多帧)。我看着做 ffmpeg 切割,插入,然后连接,但不幸的是我有很多切割,“缝合”有很多波动。我的想法是我可以让视频“完整”,然后插入帧作为我需要这样做的确切位置。这样我就可以解决断断续续的问题。
我目前正在使用 ffmpeg,并没有真正看到使用该工具完成此任务的任何方法。谷歌似乎也没有提供太多帮助。
以前有人这样做过吗?你做了什么在特定位置插入帧。
仅供参考 - 我正在用 Java 进行处理,使用 FFMPEG,我的视频文件是 mp4(虽然我可以转换)。
先感谢您。
我正在构建一个 iOS 应用程序,其中需要在后台重新编码和修剪视频。
我不能使用 iOS 库 (AVFoundation),因为它们依赖于 GPU,如果它是后台的,则没有应用程序可以访问 GPU。
由于这个问题,我切换到 FFMpeg 并编译它(与 libx264 一起)并将它集成到我的 iOS 应用程序中。
总结一下我需要的是:
几周后——我经常用头撞墙——我设法:
如果我要通过命令行运行 ffmpeg,我会像这样运行它:
ffmpeg -i input.MOV -ss 0 -t 10 -vf scale=320:240 -c:v libx264 -preset ultrafast -c:a copy output.mkv
Run Code Online (Sandbox Code Playgroud)
我关心的是如何修剪视频?虽然我可以计算我编码/解码的视频帧的数量,并根据 FPS 决定何时停止,但我不能对音频做同样的事情,因为我只是对其进行解复用和重新复用。
理想情况下 - 在缩放视频之前 - 我会运行一个过程,通过将每个流(视频和音频)的 10 秒复制到一个新的视频容器中来修剪视频。
如何通过 AV 库实现这一目标?
我想将 360 度视频从等距柱状投影转换为立方投影。我怎样才能用 ffmpeg 做到这一点?什么是其他有效的开源方法?
我从 URL 在 videoview 中播放视频......一切正常,甚至视频播放
但唯一的问题是视频需要将近 10 秒才能开始播放,这对用户来说可能有点烦人
我尝试了不同的 URL 并且相同,视频是 360p 和 6 秒长
是不是默认的媒体播放器很慢?
我有堆栈溢出但找不到合适的答案并且曾经搜索过各种 3 rd 方视频库但找不到一个
甚至尝试过谷歌的 exoplayer 库,但在我看来文档并不是那么好
有什么解决方案可以克服这个问题吗?
我的代码
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
String videeourl = "http://techslides.com/demos/sample-videos/small.3gp";
VideoView videoView = (FastVideoView)findViewById(R.id.video);
videoView.setMediaController(new MediaController(this));
videoView.setVideoPath(videeourl);
videoView.start();
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个 UIView(参见照片)和一个视频(参见视频),我想将该视图导出为图像(参见“UIView 到 UIImage”代码)并添加到视频(参见“将 UIImage 添加到视频”代码)。但我的结果并不好(见结果)。请帮我解决这个问题,谢谢!
照片
UIView 到 UIImage
UIGraphicsBeginImageContextWithOptions(view.bounds.size, view.opaque, 0.0);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * img = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Run Code Online (Sandbox Code Playgroud)
将 UIImage 添加到视频
- (void)showImage:(UIImage*)img toCompostion:(AVMutableVideoComposition *)composition fromTime:(CGFloat)fromTime toTime:(CGFloat)toTime videoSize:(CGSize)size {
CALayer *parentLayer = [CALayer layer];
CALayer *viLayer = [CALayer layer];
[parentLayer addSublayer:viLayer];
parentLayer.frame = CGRectMake(0, 0, size.width, size.height);
viLayer.frame = CGRectMake(0, 0, size.width, size.height);
// 1 - set up the overlay
CALayer *imgLayer = [CALayer layer];
[imgLayer setContents:(id)[img CGImage]];
imgLayer.frame = CGRectMake(50, 50, img.size.width, img.size.height); // …Run Code Online (Sandbox Code Playgroud) 我正在按照教程提取视频帧。我已经阅读了这个问题,它不起作用,也是来自Open CV Answer 的问题,但解决方案是捕获当前帧。我有一个 120fps 的视频,想提取所有这些视频。这是我的代码
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
#include <string>
#include <sstream>
using namespace cv;
using namespace std;
int c = 0;
string int2str(int &);
int main(int argc, char **argv) {
string s;
VideoCapture cap("test.mp4"); // video
if (!cap.isOpened())
{
cout << "Cannot open the video file" << endl;
return -1;
}
double fps = cap.get(CV_CAP_PROP_FPS); //get the frames per seconds of the video
cout << "Frame per seconds : …Run Code Online (Sandbox Code Playgroud) 我想在将视频输入分类模型之前将其转换为帧。所以我需要从视频转换的每个唯一时间戳上的帧,这里时间戳是视频中的秒数。以下来自 opencv 的代码让我每捕获 10 帧进行一次转换,但我需要视频中每一帧的时间戳。请让我知道,谢谢
import cv2
vidcap = cv2.VideoCapture('testing.mp4');
success,image = vidcap.read()
count = 0
success = True
while success:
success,image = vidcap.read()
print('read a new frame:',success)
if count%10 == 0 :
cv2.imwrite('frame%d.jpg'%count,image)
print('success')
count+=1
Run Code Online (Sandbox Code Playgroud) import boto3
import cv2
import numpy as np
s3 = boto3.resource('s3')
vid = (s3.Object('bucketname', 'video.blob').get()['Body'].read())
cap = cv2.VideoCapture(vid)
Run Code Online (Sandbox Code Playgroud)
这是我的代码。我在 s3 存储桶中有一个视频文件。我想用 OpenCV 对它做一些处理,我不想下载它。所以我试图将该视频文件存储到vid. 现在的问题是这type(vid)是byte导致TypeError: an integer is required (got type bytes)
第 6 行出现此错误的原因。我尝试将其转换为整数或字符串,但无法转换。
在尝试将字节转换为整数时:我提到了这个并且遇到了长度问题。这只是一个示例视频文件。当转换为字节对象时,我想要处理的实际文件会很大。
尝试将对象作为字符串获取,然后将其转换为整数:我提到了this。即使这对我来说似乎也不起作用。
如果有人能帮我解决这个问题,我将不胜感激。如果您对我的问题有任何不确定,请发表评论,我会尽力提供更多详细信息。
我想将动画贴纸添加到 ios 视频并通过 AVVideoComposition 导出。我可以通过 lottie 动画来完成,但问题是在 avvideocoreanimationtool 中将 lottie 动画导出为图层时,它没有与视频时间正确同步。导出时动画速度在不同设备中是可变的。动画实际上无法正确渲染,具体取决于设备等。动画时间空间未链接到视频时间空间。我知道有一个简单的解决方案是截取屏幕截图并将其添加到视频层中,但成本很高。任何建议如何解决这个问题并使用lottie作为图层并有效地导出视频?
video-processing ×10
ffmpeg ×4
ios ×3
opencv ×3
amazon-s3 ×1
android ×1
avfoundation ×1
boto3 ×1
c++ ×1
client ×1
extraction ×1
javascript ×1
libav ×1
libavformat ×1
lottie-ios ×1
mp4 ×1
objective-c ×1
performance ×1
projection ×1
python ×1
python-3.x ×1
video ×1
xuggler ×1