
Recherche avancée
Médias (1)
-
La conservation du net art au musée. Les stratégies à l’œuvre
26 mai 2011
Mis à jour : Juillet 2013
Langue : français
Type : Texte
Autres articles (49)
-
Personnaliser en ajoutant son logo, sa bannière ou son image de fond
5 septembre 2013, parCertains thèmes prennent en compte trois éléments de personnalisation : l’ajout d’un logo ; l’ajout d’une bannière l’ajout d’une image de fond ;
-
Publier sur MédiaSpip
13 juin 2013Puis-je poster des contenus à partir d’une tablette Ipad ?
Oui, si votre Médiaspip installé est à la version 0.2 ou supérieure. Contacter au besoin l’administrateur de votre MédiaSpip pour le savoir -
Emballe médias : à quoi cela sert ?
4 février 2011, parCe plugin vise à gérer des sites de mise en ligne de documents de tous types.
Il crée des "médias", à savoir : un "média" est un article au sens SPIP créé automatiquement lors du téléversement d’un document qu’il soit audio, vidéo, image ou textuel ; un seul document ne peut être lié à un article dit "média" ;
Sur d’autres sites (6037)
-
Evolution #2633 : Pouvoir modifier _DIR_RESTREINT_ABS
10 juillet 2015, par jluc -Si on enlève les répertoires de tests, il ne reste plus grand chose :
// normal spip.php:14:if (!defined(’_DIR_RESTREINT_ABS’)) define(’_DIR_RESTREINT_ABS’, ’ecrire/’) ; ecrire/inc_version.php:38 : define(’_DIR_RESTREINT_ABS’, ’ecrire/’) ;
// pb ecrire
ecrire/public/debusquer.php:366 : if ($reg[1]==’ecrire/public’)// dist
plugins-dist/forum/prive/modeles/forum-actions-moderer.html:2 :[(#SETretour,[(#REM|test_espace_prive| ?[(#VALecrire/|concat#SELF|replace’./’,’’)],#SELF|ancre_urlforum#ID_FORUM)])]// installation ’normale’
config/ecran_securite.php:113 : OR @file_exists(’ecrire/inc_version.php’))
config/ecran_securite.php:259:if (strpos($_SERVER[’REQUEST_URI’],"ecrire/") !==false)spip_loader.php:44:define(’_SPIP_LOADER_PLUGIN_RETOUR’, "ecrire/ ?exec=admin_plugin&voir=tous") ;
spip_loader.php:923:if (@file_exists(’ecrire/inc_version.php’))
spip_loader.php:924 : define(’_SPIP_LOADER_URL_RETOUR’, "ecrire/ ?exec=accueil") ;
spip_loader.php:925 : include_once ’ecrire/inc_version.php’ ;
spip_loader.php:933 : else define(’_SPIP_LOADER_URL_RETOUR’, "ecrire/ ?exec=install") ; -
Recording of Full HD 60 FPS videos in C#
17 mars 2021, par Alexander NaumovMy application works with a high-speed camera. I am trying to record a videofile using C#.


The task is pretty "simple" : to record the video from the camera. We need to record medium (higher-better) quality videos to save as many details as possible.


- 

- Resolution : 1920 x 1080 (FullHD)
- Frames per second (FPS) : 60
- Bitrate : I've started from 10000*1000 (but now I don't know)
- Mediacontainer : MP4, AVI (does not really matter, we just need to
solve our task)
- Codec : also does not matter, we just need speed and quality.
- Maximum size of videofile : 10 GB/hour














Framerate of the camera can be changed during the recording by the camera itself (not by user), so it's necessary to have something like timestamps for every frame or anything else.


The problem is not fast enough recording.
Example : using AForge libs, generated pictures ("white" noise), duration of test videos is 20 seconds.


Duration of video creating using different codecs (provided by AForge) :


- 

- Codec : MPEG4, Time : 33,703
- Codec : WMV1, Time : 45,338
- Codec : WMV2, Time : 45,530
- Codec : MSMPEG4v2, Time : 43,775
- Codec : MSMPEG4v3, Time : 44,390
- Codec : H263P, Time : 38,894
- Codec : FLV1, Time : 39,151
- Codec : MPEG2, Time : 35,561
- Codec : Raw, Time : 61,456




















Another libs we've tried is not satisfied us.
Accord.FFMPEG is slow because of strange inner exceptions.
EmguCV.FFMPEG has no timestamps, therefore it creates corrupted video.


Recording the video to the SSD drive did not give us any visible acceleration.


Google search gives no clear examples or modern solutions to solve this task. That's the main reason to write here.


There is a code sample of our test :


private static void AForge_test()
 {
 Console.WriteLine("AForge test started...");
 unsafe
 {
 Stopwatch watch = new Stopwatch();

 Console.WriteLine("FPS: {0}, W:{1}, H:{2}, T:{3}", fps, w, h, time);

 AForge.Video.FFMPEG.VideoCodec[] codecs = (AForge.Video.FFMPEG.VideoCodec[]) Enum.GetValues(typeof(AForge.Video.FFMPEG.VideoCodec));

 for(int k = 0; k < codecs.Length; k++)
 {
 /* if (codecs[k] != VideoCodec.MPEG4)
 continue;*/
 try
 {
 watch.Restart();

 Random r2 = new Random(200);
 AForge.Video.FFMPEG.VideoFileWriter vw = new AForge.Video.FFMPEG.VideoFileWriter();
 string name = String.Format("E:\\VideosHDD\\AForge_test_{0}_mid.avi", Enum.GetName(typeof(AForge.Video.FFMPEG.VideoCodec), codecs[k]));
 vw.Open(name, w, h, fps, codecs[k], 10000 * 1000);

 for (int i = 0; i < frames; i++)
 {
 vw.WriteVideoFrame(bmps[i%N]);
 }

 vw.Close();
 vw.Dispose();

 watch.Stop();

 Console.WriteLine("Codec: {0}, Time: {1:F3}", Enum.GetName(typeof(AForge.Video.FFMPEG.VideoCodec), codecs[k]), watch.ElapsedMilliseconds / 1000d);
 }
 catch(Exception ex)
 {
 Console.WriteLine("Error " + codecs[k].ToString());
 }

 }
 
 }

 Console.ReadKey();
 }



Additional :


- 

- We are ready to use not-for-free solutions, but free is preferable.
- One of the supposed reasons for low recording speed : (x86) building of applications. I tried so hard to find x64 Aforge building but failed in this. We really don't know is there any influence of application architecture on recording speed.






I am ensured that I don't know all the background of video recording and another "little" thing, so I would be very pleased to solutions with clear explanations.


-
what is wrong about the I420 render from ffmpeg ?
9 mai 2022, par DLKUNI use glfw render YUV from ffmpeg ;the Y is ok(only use data Y ,and frag texture2D Y is ok ,the color is Grayscale).but when I add U,V ;the display show pink and green ; I try to change frag shader or the imgtexture ,there have no use .


#include <glad></glad>glad.h>
#include <glfw></glfw>glfw3.h>

#include<string>
#include<fstream>
#include<sstream>
#include<iostream>
#include

#include 

// settings
const unsigned int SCR_WIDTH = 544;
const unsigned int SCR_HEIGHT = 960;
const int len = 544 * 960 * 3/2;
BYTE YUVdata [len];//
BYTE Ydata [544 * 960];//
BYTE Udata [272 * 480];//
BYTE Vdata [272 * 480];//
unsigned int VBO = 0;
unsigned int VAO = 0;
unsigned int EBO = 0;
unsigned int texturePIC = 0;
int shaderProgram = 0;

GLuint texIndexarray[3];
GLuint texUniformY = 99;
GLuint texUniformU = 99;
GLuint texUniformV = 99;

void LoadPicture()
{


 glGenTextures(3, texIndexarray);

 glBindTexture(GL_TEXTURE_2D, texIndexarray[0]);
 
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

 glBindTexture(GL_TEXTURE_2D, texIndexarray[1]);
 
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 glBindTexture(GL_TEXTURE_2D, texIndexarray[2]);
 
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);


 glValidateProgram(shaderProgram);

 texUniformY = glGetUniformLocation(shaderProgram, "dataY");//2
 texUniformU = glGetUniformLocation(shaderProgram, "dataU");//0
 texUniformV = glGetUniformLocation(shaderProgram, "dataV");//1

 
 FILE* fp = fopen("./output544_960.yuv","rb+");//I420
 int returns =fread(YUVdata,1,len,fp);
 int w = 544;
 int h = 960;
 int ysize = w*h;
 int uvsize = w * h / 4;

 void* uptr = &YUVdata[ysize];
 void* vptr = &YUVdata[ysize * 5 / 4];

 memcpy(Ydata,YUVdata,ysize);
 memcpy(Udata, uptr,uvsize);
 memcpy(Vdata, vptr,uvsize);
 glActiveTexture(GL_TEXTURE0);
 glBindTexture(GL_TEXTURE_2D, texIndexarray[0]);
 
 glTexImage2D(GL_TEXTURE_2D, 0 , GL_RED, w, h ,0, GL_RED,GL_UNSIGNED_BYTE ,Ydata);
 glUniform1i(texUniformY, texIndexarray[0]); 


 glActiveTexture(GL_TEXTURE1);
 glBindTexture(GL_TEXTURE_2D, texIndexarray[1]);
 glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w/2, h/2, 0, GL_RED, GL_UNSIGNED_BYTE,Udata );

 glUniform1i(texUniformU, texIndexarray[1]);


 glActiveTexture(GL_TEXTURE2);
 glBindTexture(GL_TEXTURE_2D, texIndexarray[2]);
 glTexImage2D(GL_TEXTURE_2D, 0, GL_RED, w/2, h/2, 0, GL_RED, GL_UNSIGNED_BYTE,Vdata);
 glUniform1i(texUniformV, texIndexarray[2]);

}


void render()
{
 glBindVertexArray(VAO);
 glUseProgram(shaderProgram);
 glDrawElements(GL_TRIANGLES,6,GL_UNSIGNED_INT,0);
 //glDrawArrays(GL_TRIANGLE_FAN,0,4);
 glUseProgram(0);
 glBindVertexArray(0);
}

void initmodule()
{
 
 float vertexs[] = {
 
 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 
 1.0f, -1.0f, 0.0f, 1.0f, 1.0f, 
 -1.0f, -1.0f, 0.0f, 0.0f, 1.0f, 
 -1.0f, 1.0f, 0.0f, 0.0f, 0.0f 
 
 
 };
 
 unsigned int indexs[] = {
 0,1,3,
 1,2,3,
 };

 
 glGenVertexArrays(1,&VAO);
 glBindVertexArray(VAO);

 

 glGenBuffers(1, &VBO);
 glBindBuffer(GL_ARRAY_BUFFER, VBO);
 
 glBufferData(GL_ARRAY_BUFFER,sizeof(vertexs), vertexs, GL_STATIC_DRAW);

 
 glGenBuffers(1,&EBO);
 glBindBuffer(GL_ELEMENT_ARRAY_BUFFER,EBO);
 glBufferData(GL_ELEMENT_ARRAY_BUFFER,sizeof(indexs),indexs,GL_STATIC_DRAW);
 
 LoadPicture();

 glVertexAttribPointer(0,3,GL_FLOAT,GL_FALSE,5*sizeof(float),(void*)0);
 
 glEnableVertexAttribArray(0);
 
 glVertexAttribPointer(1,2, GL_FLOAT, GL_FALSE, 5 * sizeof(float), (void*)(3 * sizeof(float)));
 
 glEnableVertexAttribArray(1);

 
 glBindBuffer(GL_ARRAY_BUFFER,0);

 
 glBindVertexArray(0);



}

void initshader(const char* verpath,const char* fragpath)
{
 
 std::string VerCode("");
 std::string fregCode("");
 
 std::ifstream vShaderFile;
 std::ifstream fShaderFile;

 vShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);
 fShaderFile.exceptions(std::ifstream::failbit | std::ifstream::badbit);

 try
 {
 vShaderFile.open(verpath);
 fShaderFile.open(fragpath);

 std::stringstream vsstream, fsstream;
 vsstream << vShaderFile.rdbuf();
 fsstream << fShaderFile.rdbuf();
 VerCode = vsstream.str();
 fregCode = fsstream.str();
 
 }
 catch (const std::exception&)
 {
 std::cout << "read file error" << std::endl;
 }

 const char* vshader = VerCode.c_str();
 const char* fshader = fregCode.c_str();

 
 unsigned int vertexID = 0, fragID = 0;
 char infoLog[512];
 int successflag = 0;
 vertexID = glCreateShader(GL_VERTEX_SHADER);
 glShaderSource(vertexID,1,&vshader,NULL );
 glCompileShader(vertexID);
 
 glGetShaderiv(vertexID,GL_COMPILE_STATUS,&successflag);
 if (!successflag)
 {
 glGetShaderInfoLog(vertexID,512,NULL,infoLog);
 std::string errstr(infoLog);
 std::cout << "v shader err"</frag
 fragID = glCreateShader(GL_FRAGMENT_SHADER);
 glShaderSource(fragID, 1, &fshader, NULL);
 glCompileShader(fragID);
 
 glGetShaderiv(fragID, GL_COMPILE_STATUS, &successflag);
 if (!successflag)
 {
 glGetShaderInfoLog(fragID, 512, NULL, infoLog);
 std::string errstr(infoLog);
 std::cout << "f shader err"</
 initmodule();


 
 while (!glfwWindowShouldClose(window))
 {
 
 processInput(window);

 glClearColor(0.0f,0.0f,0.0f,1.0f);
 glClear(GL_COLOR_BUFFER_BIT);
 render();
 
 
 glfwSwapBuffers(window);
 
 glfwPollEvents();
 }

 
 glfwTerminate();
 return 0;
}
</iostream></sstream></fstream></string>


I get the Y data ,and run the code is ok ;the color is gray ;but when I add the U ,the color is Light green;and when i add the V is pink and green ;


#version 330 core
layout(location = 0) out vec4 FragColor;
in vec2 TexCoord;
uniform sampler2D dataY;
uniform sampler2D dataU;
uniform sampler2D dataV;
vec3 yuv;
vec3 rgb;
void main()
{


 yuv.x = texture2D(dataY, TexCoord).r-0.0625;
 yuv.y = texture2D(dataU, TexCoord).r-0.5;
 yuv.z = texture2D(dataV, TexCoord).r-0.5;

 rgb = mat3(1, 1, 1, 
 0, -0.18732, 1.8556, 
 1.57481, -0.46813, 0) * yuv; 
 FragColor = vec4(rgb.x, rgb.y,rgb.z,1); 
};