我正在编写一个视频播放器来播放我们的ASIC捕获的帧.它们采用自定义格式,并且我已经提供了解码ASIC状态的功能.视频可以是640x480到2560x1200(!!!)的任何大小.每个状态周期的输出是16x16像素块,我必须将其放入屏幕上的视频中.
每次需要更新屏幕时,我都会收到以下信息:
主要限制:
今天早上我花了一些时间尝试WriteableBitmap,并将它用作Image的源代码,如下所示:
private WriteableBitmap ImageSource;
public MainWindow()
{
InitializeComponent();
ImageSource = new WriteableBitmap(FrameWidth, FrameHeight, 96, 96, PixelFormats.Bgr32, null);
ImagePanel.Source = ImageSource;
}
private void DrawBox(byte Red, byte Green, byte Blue, int X, int Y)
{
int BoxWidth = 16;
int BoxHeight = 16;
int BytesPerPixel = ImageSource.Format.BitsPerPixel / 8;
byte[] Pixels = new byte[BoxWidth * BoxHeight * BytesPerPixel];
for (int i = 0; i < Pixels.Length; i += 4)
{ …Run Code Online (Sandbox Code Playgroud) 我可以在gstreamer的命令行上播放视频gst-launch:
gst-launch gnlfilesource location=file:///tmp/myfile.mov start=0 duration=2000000000 ! autovideosink
Run Code Online (Sandbox Code Playgroud)
这将在/tmp/myfile.mov中播放文件的前2秒,之后视频播放停止.无论如何要让它重复循环?gnlfilesource即将2秒长转为无限长度的视频,一次又一次播放2秒钟?
我正在寻找IOS中的视频编辑库.
编辑任务: - >在视频帧的顶部添加文本或标记.
在我的应用程序中,用户应该能够从视频库中选择视频,并在电影播放器中播放视频.用户可以暂停视频,然后使用空闲手动添加一些文本或标记.我们需要在此视频中合并添加的文字和标记.
我已经安装了当前版本ffmpeg以获得对该-filter_complex选项的访问,希望能够将视频用作覆盖在比视频大的静态背景图像上.
最初我只是试图通过静态背景图像覆盖视频,以使用以下命令(这不起作用):
ffmpeg -loop 1 -i background.png -i overlay.mov -filter_complex overlay -shortest -y output.mov
在output.mov仅有的组成的单个帧background.png,没有视频叠加文件.
如何进行此工作并在背景上添加视频的特定坐标位置?
奖励:使用单一命令,是否可以将叠加视频调整为更大的尺寸,同时将其置于bg图像的顶部?
我正在尝试使用基于Canny过滤器和轮廓查找功能的摄像机/网络摄像头来制作程序来检测任何形状的物体.这是我的计划:
int main( int argc, char** argv )
{
CvCapture *cam;
CvMoments moments;
CvMemStorage* storage = cvCreateMemStorage(0);
CvSeq* contours = NULL;
CvSeq* contours2 = NULL;
CvPoint2D32f center;
int i;
cam=cvCaptureFromCAM(0);
if(cam==NULL){
fprintf(stderr,"Cannot find any camera. \n");
return -1;
}
while(1){
IplImage *img=cvQueryFrame(cam);
if(img==NULL){return -1;}
IplImage *src_gray= cvCreateImage( cvSize(img->width,img->height), 8, 1);
cvCvtColor( img, src_gray, CV_BGR2GRAY );
cvSmooth( src_gray, src_gray, CV_GAUSSIAN, 5, 11);
cvCanny(src_gray, src_gray, 70, 200, 3);
cvFindContours( src_gray, storage, &contours, sizeof(CvContour), CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE, cvPoint(0,0));
if(contours==NULL){ contours=contours2;}
contours2=contours;
cvMoments(contours, &moments, 1); …Run Code Online (Sandbox Code Playgroud) 我正在尝试实现一个能够旋转视频的MFT.旋转本身将在变换函数内完成.为此,我需要更改输出帧大小,但我不知道如何做到这一点.
作为起点,我使用了Microsoft提供的MFT_Grayscale示例.我将此MFT作为转换节点包含在部分拓扑中
HRESULT Player::AddBranchToPartialTopology(
IMFTopology *pTopology,
IMFPresentationDescriptor *pSourcePD,
DWORD iStream
)
{
...
IMFTopologyNode pTransformNode = NULL;
...
hr = CreateTransformNode(CLSID_GrayscaleMFT, &pTransformNode);
...
hr = pSourceNode->ConnectOutput(0, pTransformNode, 0);
hr = pTransformNode->ConnectOutput(0, pOutputNode, 0);
...
}
Run Code Online (Sandbox Code Playgroud)
到目前为止,此代码正在运行.应用灰度mft并按预期工作.无论如何,我想改变这个mft来处理视频旋转.所以我们假设我想将视频旋转90度.为此,必须切换输入框架的宽度和高度.我尝试了不同的东西,但没有一个按预期工作.基于此线程中的第一条注释如何更改Media Foundation Transform输出帧(视频)大小?我开始改变SetOutputType的实现.我在GetOutputType中调用GetAttributeSize来接收实际的frame_size.当我尝试设置新的frame_size时失败(当开始播放时我收到hresult 0xc00d36b4(指定的数据无效,不一致或此对象不支持)
HRESULT CGrayscale::SetOutputType(
DWORD dwOutputStreamID,
IMFMediaType *pType, // Can be NULL to clear the output type.
DWORD dwFlags
)
{ ....
//Receive the actual frame_size of pType (works as expected)
hr = MFGetAttributeSize(
pType,
MF_MT_FRAME_SIZE,
&width,
&height
));
...
//change …Run Code Online (Sandbox Code Playgroud) 我要修剪视频文件。我只想从图库中选择视频并将其转换为15秒的视频。我正在使用Objective C的此 链接。它对我来说很好用,但我是Swift语言的初学者。谁能帮助我在Swift中转换此代码?
以下是我在Objective C中的代码:
-(void)cropVideo:(NSURL*)videoToTrimURL{
AVURLAsset *asset = [AVURLAsset URLAssetWithURL:videoToTrimURL options:nil];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc] initWithAsset:asset presetName:AVAssetExportPresetHighestQuality];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *outputURL = paths[0];
NSFileManager *manager = [NSFileManager defaultManager];
[manager createDirectoryAtPath:outputURL withIntermediateDirectories:YES attributes:nil error:nil];
outputURL = [outputURL stringByAppendingPathComponent:@"output.mp4"];
// Remove Existing File
[manager removeItemAtPath:outputURL error:nil];
//
exportSession.outputURL = [NSURL fileURLWithPath:outputURL];
exportSession.shouldOptimizeForNetworkUse = YES;
exportSession.outputFileType = AVFileTypeQuickTimeMovie;
CMTime start = CMTimeMakeWithSeconds(1.0, 600); // you will modify time range here
CMTime duration = CMTimeMakeWithSeconds(19.0, 600); …Run Code Online (Sandbox Code Playgroud) 最终目标是处理视频的RGB数据.
我试图读取我使用ffmpeg创建的文件的字节.
ffmpeg -video_size 100x100 -framerate 20 -f x11grab -i :0.0 \
-c:v rawvideo -pix_fmt rgb24 -video.nut
Run Code Online (Sandbox Code Playgroud)
我写了一个节点脚本,以便在需要时更容易读取二进制数据.我当前文件的输出是:
Hex Binary Row
47 01000111 0
40 01000000 1
11 00010001 2
10 00010000 3
03 00000011 4
00 00000000 5
00 00000000 6
00 00000000 7
68 01101000 8
Run Code Online (Sandbox Code Playgroud)
我看到了.nut的规格,但我无法弄明白.我希望能够解析每帧的RGB数据,以便为视频流中的每个"图像"留下RGB矩阵.谢谢!
创建图像处理演示,我需要根据从图库中选择的视频内容方向来设置设备方向。所以我用了几行代码来获取方向,请参考下面的代码。
var video_orientation: UIInterfaceOrientation {
guard let transform = tracks(withMediaType: AVMediaType.video).first?.preferredTransform else {
return .portrait
}
switch (transform.tx, transform.ty) {
case (0, 0):
return .landscapeLeft
case (videoFirstFrameSize.width, videoFirstFrameSize.height):
return .landscapeRight
case (0, videoFirstFrameSize.width):
return .portraitUpsideDown
default:
return .portrait
}
}
Run Code Online (Sandbox Code Playgroud)
现在,问题是当我从图库中选择视频(慢动作,正常)时,它的工作正常。但是,当我从画廊方向选择“延时摄影”视频时,我做了太多与此相关的研发工作,最后我得到了一些解决方案,解决方案是,如果我们选择“延时摄影”,我们需要传入AVMediaType.timecode视频类型,但是现在的问题是,如何在选定的资产上设置它。任何帮助都是非常可观的。
注意:- var video_orientation是扩展属性AVAssets
我需要知道如何SeekBar用特定的视频大小来限制a ,而不是像使用什么应用程序那样限制使用时间17 MB,我已经花了一些时间来做一个例子,但是我需要考虑大小。
我在用这个例子