
Recherche avancée
Médias (1)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
Autres articles (62)
-
Les autorisations surchargées par les plugins
27 avril 2010, parMediaspip core
autoriser_auteur_modifier() afin que les visiteurs soient capables de modifier leurs informations sur la page d’auteurs -
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 -
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...)
Sur d’autres sites (10510)
-
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); 
};



-
Issues with video frame dropout using Accord.NET VideoFileWriter and FFMPEG
9 janvier 2018, par DavidI am testing out writing video files using the Accord.Video library. I have a WPF project created in Visual Studio 2017, and I have installed Accord.Video.FFMPEG as well as Accord.Video.VFW using Nuget, as well as their dependencies.
I have created a very simple video to test basic file output. However, I am running into some issues. My goal is to be able to output videos with a variable frame rate, because in the future I will be using this code to input images from a webcam device that will then be saved to a video file, and video from webcams typically has variable frame rates.
For now, in this example, I am not inputting video from a webcam, but rather I am generating a simple "moving box" image and outputting the frames to a video file. The box changes color every 20 frames : red, green, blue, yellow, and finally white. I also set the frame rate to be 20 fps.
When I use Accord.Video.VFW, the frame rate is correctly set, and all the frames are correctly outputted to the video file. The resulting video looks like this (see the YouTube link) : https://youtu.be/K8E9O7bJIbg
This is just a reference, however. I don’t intend on using Accord.Video.VFW because it outputs uncompressed data to an AVI file, and it doesn’t support variable frame rates. I would like to use Accord.Video.FFMPEG because it is supposed to support variable frame rates.
When I attempt to use the Accord.Video.FFMPEG library, however, the video does not result in how I would expect it to look. Here is a YouTube link : https://youtu.be/cW19yQFUsLI
As you can see, in that example, the box remains the first color for a longer amount of time than the other colors. It also never reaches the final color (white). When I inspect the video file, 100 frames were not outputted to the file. There are 69 or 73 frames typically. And the expected frame rate and duration obviously do not match up.
Here is the code that generates both these videos :
public MainWindow()
{
InitializeComponent();
Accord.Video.VFW.AVIWriter avi_writer = new Accord.Video.VFW.AVIWriter();
avi_writer.FrameRate = 20;
avi_writer.Open("test2.avi", 640, 480);
Accord.Video.FFMPEG.VideoFileWriter k = new Accord.Video.FFMPEG.VideoFileWriter();
k.FrameRate = 20;
k.Width = 640;
k.Height = 480;
k.Open("test.mp4");
for (int i = 0; i < 100; i++)
{
TimeSpan t = new TimeSpan(0, 0, 0, 0, 50 * i);
var b = new System.Drawing.Bitmap(640, 480);
var g = Graphics.FromImage(b);
var br = System.Drawing.Brushes.Blue;
if (t.TotalMilliseconds < 1000)
br = System.Drawing.Brushes.Red;
else if (t.TotalMilliseconds < 2000)
br = System.Drawing.Brushes.Green;
else if (t.TotalMilliseconds < 3000)
br = System.Drawing.Brushes.Blue;
else if (t.TotalMilliseconds < 4000)
br = System.Drawing.Brushes.Yellow;
else
br = System.Drawing.Brushes.White;
g.FillRectangle(br, 50 + i, 50, 100, 100);
System.Console.WriteLine("Frame: " + (i + 1).ToString() + ", Millis: " + t.TotalMilliseconds.ToString());
#region This is the code in question
k.WriteVideoFrame(b, t);
avi_writer.AddFrame(b);
#endregion
}
avi_writer.Close();
k.Close();
System.Console.WriteLine("Finished writing video");
}I have tried changing a few things under the assumption that maybe the "WriteVideoFrame" function isn’t able to finish in time, and so I need to slow down the program so it can complete itself. Under that assumption, I have replaced the "WriteVideoFrame" call with the following code :
Task taskA = new Task(() => k.WriteVideoFrame(b, t));
taskA.Start();
taskA.Wait();And I have tried the following code :
Task.WaitAll(
Task.Run( () =>
{
lock(syncObj)
{
k.WriteVideoFrame(b, t);
}
}
));And even just a standard call where I don’t specify a timestamp :
k.WriteVideoFrame(b);
None of these work. They all result in something similar.
Any suggestions on getting the WriteVideoFrame function to work that is a part of the Accord.Video.FFMPEG.VideoFileWriter class ?
Thanks for any and all help !
[edits below]
I have done some more investigating. I still haven’t found a good solution, but here is what I have found so far. After declaring my VideoFileWriter object, I have tried setting up some options for the video.
When I use an H264 codec with the following options, it correctly saves 100 frames at a frame-rate of 20 fps, however any normal media player (both VLC and Windows Media Player) end up playing a 10-second video instead of a 5-second video. Essentially, it seems like they play it at half-speed. Here is the code that gives that result :
k.VideoCodec = Accord.Video.FFMPEG.VideoCodec.H264;
k.VideoOptions["crf"] = "18";
k.VideoOptions["preset"] = "veryfast";
k.VideoOptions["tune"] = "zerolatency";
k.VideoOptions["x264opts"] = "no-mbtree:sliced-threads:sync-lookahead=0";Additionally, if I use an Mpeg4 codec, I get the same "half-speed" result :
k.VideoCodec = Accord.Video.FFMPEG.VideoCodec.Mpeg4;
However, if I use a WMV codec, then it correctly results in 100 frames at 20 fps, and a 5 second video that is correctly played by both media players :
k.VideoCodec = Accord.Video.FFMPEG.VideoCodec.Wmv1;
Although this is good news, this still doesn’t solve the problem because WMV doesn’t support variable frame rates. Also, this still doesn’t answer the question as to why the problem is happening in the first place.
As always, any help would be appreciated !
-
PowerShell progress bar won't display
23 juillet 2014, par BrettI’m trying to write my first PowerShell GUI. Basically I’m trying to run a
ffmpeg
command which is fine and works, but I cannot get the progress bar to run. (I’m brand new to this.) Here is my attempt.cd C:\Users\brett\Documents\convert
$cmd = 'ffmpeg.exe'
$arg0 = '-i'
$arg1 = 'MASH_01.ts'
$arg2 = '-c:v'
$arg3 = '-c:a'
$arg4 = 'MASH_01.mp4'
$cf = 'copy'
$isFile = 'MASH_01.mp4'
if (-not(Test-Path -Path $isFile) -eq $false) {
echo "Shit Go"
del $isFile
& $cmd $arg0 $arg1 $arg2 $cf $arg3 $cf $arg4
for ($i = 1; $i -le 100; $i++) {
Start-Sleep -m 100
Write-Progress -Activity 'Progress Of The Coversion' -Status "$i Percent Complete" -PercentComplete $i;
}
} else {
& $cmd $arg0 $arg1 $arg2 $cf $arg3 $cf $arg4
for ($i = 1; $i -le 100; $i++) {
Start-Sleep -m 100
Write-Progress -Activity 'Progress Of The Coversion' -Status "$i Percent Complete" -PercentComplete $i;
}
}Update : There is no error output I can see, but the progress bar runs after the file has been processed, not during.
here is my latest attempt.. but now i get ffmpeg saying "m" is not a valid switch
cd C:\Users\brett\Documents\convert
$oldVideo = Get-ChildItem -Include @("*.ts")
Write-Host -ForegroundColor Green -Object $ArgumentList;
# Pause the script until user hits enter
$isFile = 'MASH_01.mp4'
if( -not(Test-Path -Path $isFile) -eq $false) {
echo "Shit Go"
del $isFile
}a
$tool = ffmpeg.exe
$ArgumentList = '`-i'+' '+'MASH_01.ts'+' '+'-c:v'+' '+'copy'+' '+'-c:a'+' '+'copy'+' '+'MASH_01.mp4';
Invoke-Expression $tool $ArgumentList
for($i = 1; $i -le 100; $i++){
ffmpeg $ArgumentList -m 100
Write-Progress -Activity 'Progress Of The Coversion' -Status "$i Percent Complete" -PercentComplete $i
`-SecondsRemaining $a -CurrentOperation
"$i% complete" `
}