-1

If I have a video file that defines a video image that is 6144 pixels long (x) by 64 pixels high (y) and I want to display that video so that it wraps at the end of the monitor. In other words I want to display the first 1024 pixels of the video starting at position 0,0 on the monitor, then video pixels 1024 to 2047 starting at position 0,64, and repeat this until all 6144 pixels are shown on the monitor. That would mean the video needs to wrap around on a 1024x768 monitor 6 times.

What is the best way to do this? Can DirectX, DirectShow, Media Foundation, or Windows Media Player ActiveX Control handle this wrapping for you automatically? I need to do this preferably in C#, but not opposed to dropping in to C++ native. Or is the only way to do this, is to split the video into 6 separate sections and play them in separate window? If splitting them into 6 separate videos and playing them in 6 separate windows is the only reasonable way, how do you make certain they start at the same time so they are sync'd?

Just thinking about something per comment below could ffmpeg and/or C# transform this 6144 x 64 pixel video file into something like this:

6144 x 64  --->  0-1023 x 64
                 1024-2047 x 64
                 2048-3071 x 64
                 3072-4095 x 64
                 4096-5119 x 64
                 5120-6143 x 64

In other words what looks like it's wrapped but really just one video that's 1024 x 384 ??

Neal Davis
  • 648
  • 6
  • 21
  • you can also use avisynth and their newer relatives like vapoursynth instead of doing such work within your code. When using avisynth, go for the source plugin ffmpegsource (ffms2) and do not forget to use converttoyuy2() at the very end of your script – Harry Nov 16 '17 at 19:05

1 Answers1

2

You need to develop a transformation which converts your 6144x64 video to resolution in question (1024x768 or different) and integrate it with one of the player pipelines. When you convert the video frames to required resolution, the frames can be presented as usual video playback, esp. fullscreen in you need to span in across the entire monitor, and such playback on its presentation end will not differ from play back a regular video file meaning that you can use standard components and APIs.

All video APIs are native: in most, if not all, cases you would be better off implementing the transformation in C++ rather than C#.

With DirectShow you typically develop a transform filter which accept the video frames and rearranges the pixel data respectively to your requirements. With Media Foundation the similar task is achieved by developing a Media Foundation Transform (with the data processing in CPU or GPU domain). In both cases you are packing your transformation step into API defined form factor and extending the standard pipeline.

Otherwise you can also prepare the frames outside of the playback pipelines and inject them already prepared. Even though possible, it is perhaps a more complicated way but it can be preferred by those who are not well familiar with the mentioned APIs.

When you prepare a re-arranged frame for presentation at once you don't need to do additional presentation synchronization. Presumably, this is the way to achieve the mentioned task as the splitting into parts and managing synchronized presentation is a more complicated for now reason alternative.

DirectShow vs. Media Foundation - both APIs let you play video with the same quality and performance (exception might be that you need GPU only processing, in which case Media Foundation might be a better choice, but in your case it's unlikely that you can leverage this advantage).

DirectShow is older and near stop of its development but offers much more online tutorials, discussions, materials, helpers and samples. Windows SDK 7.1 EzRGB24 Filter Sample is a good start point for a transform filter.

Media Foundation is newer and "current" API, presumably a more reasonable choice. Windows SDK 7.1 offers MFT_Grayscale Sample for a starting development point. It is generally possible to implement a C# MFT for Media Foundation (there are good reasons to not do it - 1, 2). Even though DirectShow is notorious for being an API with a step learning curve, for the video effect developer Media Foundation is even a more complicated API.

Generally speaking the API choice should take into consideration, if not even be defined by, your preference for playback pipeline.

Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • Thanks for your input, do you know of any type of example code that I might find to help me get started doing either a DirectShow transform filter or a MF Transform that would wrap a video such as per above? I have been recently experimenting with some MF Player example code. It is my understanding from your message above doing a transform is the best way to handle this type of thing. – Neal Davis Nov 13 '17 at 21:37
  • Could ffmpeg transform the 6144x64 video file into a video file that would play as defined above on one monitor to appear as if it was wrapped? But essentially would be a 1024 x 768 video? – Neal Davis Nov 13 '17 at 21:53
  • I am not sure if you could use ffmpeg with command line arguments ([video filters?](https://ffmpeg.org/ffmpeg-filters.html#Video-Filters)) to rearrange the data respectively, however another question would be that you also need to consume this output programmatically or play by means of ffmpeg/ffplay as well. – Roman R. Nov 13 '17 at 22:02
  • If ffmpeg or something similar could rearrange the video file I would like to be able to play it with windows media player activex control from C# application. But I think I could use ffmpeg/ffplay from C# also I believe to play the video ?? See my edit to original question above, as long as I could get a valid video file - I think WMP axtivex control would play it? – Neal Davis Nov 13 '17 at 22:20
  • With ffmpeg you are to solve a slightly different set of tasks: `1` use video filters to rearrange the data (see link above and look for using multiple filters together), `2` write to a file without losing quality much in reasonable time with reasonable codec, `3` deal with requirement to process file completely before you can actually start playing it back. – Roman R. Nov 13 '17 at 22:37