Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Directx 自定义视频文件我将提取多少图像?_Directx_Video - Fatal编程技术网

Directx 自定义视频文件我将提取多少图像?

Directx 自定义视频文件我将提取多少图像?,directx,video,Directx,Video,很多人都会建议,为什么不使用Bink或DirectShow来播放视频甚至ffmpeg呢。然而,电影到底是什么?只是把图像和声音放在一起 我已经创建了一个程序,在这个程序中,我获取了一组图像,并将它们放入自定义视频文件中。最酷的是,我可以很容易地把它放在一个四线组上。我遇到的问题是,我只能从自定义视频文件中提取一幅图像。当我有不止一个;我有问题,我完全理解 我有一个索引查找表的所有图像大小,然后原始图像。我的计算如下: offset = NumberOfImages + 1 * sizeof(l

很多人都会建议,为什么不使用Bink或DirectShow来播放视频甚至ffmpeg呢。然而,电影到底是什么?只是把图像和声音放在一起

我已经创建了一个程序,在这个程序中,我获取了一组图像,并将它们放入自定义视频文件中。最酷的是,我可以很容易地把它放在一个四线组上。我遇到的问题是,我只能从自定义视频文件中提取一幅图像。当我有不止一个;我有问题,我完全理解

我有一个索引查找表的所有图像大小,然后原始图像。我的计算如下:

 offset = NumberOfImages + 1 * sizeof(long). 
所以,对于一个图像-如果您执行偏移,那么查找第一个图像将非常容易。在for循环期间,它总是从0开始,并达到图像数1。所以,它可以这样翻译:

  offset = 1 + 1 * 4 = 8.
现在我知道了一幅图像的偏移量,这很好。然而,一个视频是由一堆图像组成的。所以,我一直在想…如果有一种方法可以达到某个点,然后将读取的数据填充到向量中

    currentPosition = 0; //-- Set the current position to zero before looping through images in file.

     for (UINT i = 0; i < elements; i++) {

         long tblSz = (elements + 1) * sizeof(long); // elements + 1 * 4

         long off =  tblSz + currentPosition; // -- Now let's calculate the offset position inside the file knowing the table size.
        // in.seekg(off, std::ios_base::end); //-- Not used.
         long videoSz = sicVideoIndexTable[i]; //-- Let's retreive the image size from the index table that's stored inside the file before we process each image.
        // in.seekg(0, std::ios_base::beg); //-- Not used.
             dataBuf.resize(videoSz); //-- Let's resize the data Buffer vector to fit the image size.
         in.seekg(off, std::ios_base::beg); //-- Let's go to the calculated offset position to retrieve the image data.
         std::streamsize currpos = in.gcount(); //-- Prototype not used.
                 in.read(&dataBuf[0], videoSz); //-- Let's read in the data according to the image size.

                     sVideoDesc.dataPtr = (void*)&dataBuf[0]; //-- Pass what we've read into the temporary structor before pushing it inside a vector to store the collection of images.
         sVideoDesc.fileSize = videoSz;
         sicVideoArray.push_back(sVideoDesc);

         dataBuf.empty(); //-- Now can empty the data vector so it can be reused.
         currentPosition = videoSz; //-- Set the current position to the video size so it can recalculate the offset for the next image.
     }
currentPosition=0;//--在循环文件中的图像之前,将当前位置设置为零。
对于(UINT i=0;i
我相信问题在于seekg和in.read,但这只是我的直觉告诉我的。正如您所看到的,当前位置总是在变化


按钮行的问题是,如果我可以加载一个图像,那么为什么我不能从自定义视频文件加载多个图像?我不确定我是在使用seekg,还是应该只获取每个字符,直到某个点它们将内容转储到数据缓冲向量中。我以为读取数据块就是答案——但我变得非常不确定

我想我终于明白了你的代码的作用了。您确实应该使用更具描述性的变量名。或者至少对每个变量的含义进行解释。无论如何

我相信你的问题在这方面:

currentPosition = videoSz;
应该是什么时候

currentPosition += videoSz;
你基本上不需要浏览你的文件


此外,如果只是按顺序读取图像,则可能需要更改文件格式,以便在图像数据后面直接存储每个图像大小,而不是开始时的图像大小表。这样,您就不需要进行任何偏移计算或搜索。

很抱歉,我没有说清楚。为了自己和他人的利益,我更多地致力于良好的编码道德。另外,我将尝试一下,看看结果如何。我会让你知道结果的。+1谢谢以防万一;出于调试目的,我写下了各个图像,以确保文件确实被正确读取。它就像一个符咒。