
Recherche avancée
Médias (1)
-
The Slip - Artworks
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Texte
Autres articles (89)
-
Organiser par catégorie
17 mai 2013, parDans MédiaSPIP, une rubrique a 2 noms : catégorie et rubrique.
Les différents documents stockés dans MédiaSPIP peuvent être rangés dans différentes catégories. On peut créer une catégorie en cliquant sur "publier une catégorie" dans le menu publier en haut à droite ( après authentification ). Une catégorie peut être rangée dans une autre catégorie aussi ce qui fait qu’on peut construire une arborescence de catégories.
Lors de la publication prochaine d’un document, la nouvelle catégorie créée sera proposée (...) -
Récupération d’informations sur le site maître à l’installation d’une instance
26 novembre 2010, parUtilité
Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...) -
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
Sur d’autres sites (10474)
-
Decoded YUV shows green edge when rendered with OpenGL
2 février 2023, par AlexAny idea, why decoded YUV -> RGB(shader conversion) has that extra green edge on the right side ?

Almost any 1080X1920 video seems to have this issue.



A screen recording of the issue is uploaded here https://imgur.com/a/JtUZq4h


Once I manually scale up the texture width, I can see it fills up to the viewport, but it would be nice if I could fix the actual cause. Is it some padding that's part of YUV colorspace ? What else could it be ?


My model is -1 to 1, filling the entire width

The texture coordinates are also 0 to 1 ratio

float vertices[] = {
 -1.0, 1.0f, 0.0f, 0.0, // top left
 1.0f, 1.0f, 1.0, 0.0, // top right
 -1.0f, -1.0f, 0.0f, 1.0f, // bottom left
 1.0f, -1.0f, 1.0f, 1.0f // bottom right
};



Fragment Shader


#version 330 core

in vec2 TexCoord;

out vec4 FragColor;
precision highp float;
uniform sampler2D textureY;
uniform sampler2D textureU;
uniform sampler2D textureV;
uniform float alpha;
uniform vec2 texScale;


void main()
{
 float y = texture(textureY, TexCoord / texScale).r;
 float u = texture(textureU, TexCoord / texScale).r - 0.5; 
 float v = texture(textureV, TexCoord / texScale).r - 0.5;
 
 vec3 rgb;
 
 //yuv - 709
 rgb.r = clamp(y + (1.402 * v), 0, 255);
 rgb.g = clamp(y - (0.2126 * 1.5748 / 0.7152) * u - (0.0722 * 1.8556 / 0.7152) * v, 0, 255);
 rgb.b = clamp(y + (1.8556 * u), 0,255);

 FragColor = vec4(rgb, 1.0);
} 



Texture Class


class VideoTexture {
 public:
 VideoTexture(Decoder *dec) : decoder(dec) {
 glGenTextures(1, &texture1);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 glBindTexture(GL_TEXTURE_2D, texture1);
 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, decoder->frameQueue.first().linesize[0], decoder->frameQueue.first().height, 0, format, GL_UNSIGNED_BYTE, 0);
 glGenerateMipmap(GL_TEXTURE_2D);

 glGenTextures(1, &texture2);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 glBindTexture(GL_TEXTURE_2D, texture2);
 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, decoder->frameQueue.first().linesize[1], decoder->frameQueue.first().height / 2, 0, format, GL_UNSIGNED_BYTE, 0);
 glGenerateMipmap(GL_TEXTURE_2D);

 glGenTextures(1, &texture3);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
 glBindTexture(GL_TEXTURE_2D, texture3);
 glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, decoder->frameQueue.first().linesize[2], decoder->frameQueue.first().height / 2, 0, format, GL_UNSIGNED_BYTE, 0);
 glGenerateMipmap(GL_TEXTURE_2D);
 }

 void Render(Shader *shader, Gui *gui) {
 if (decoder->frameQueue.isEmpty()) {
 return;
 }

 glActiveTexture(GL_TEXTURE0);
 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, decoder->frameQueue.first().linesize[0], decoder->frameQueue.first().height, format, GL_UNSIGNED_BYTE, decoder->frameQueue.at(currentFrame).data[0]);
 glBindTexture(GL_TEXTURE_2D, texture1);
 shader->setInt("textureY", 0);

 glActiveTexture(GL_TEXTURE1);
 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, decoder->frameQueue.first().linesize[1], decoder->frameQueue.first().height / 2, format, GL_UNSIGNED_BYTE, decoder->frameQueue.at(currentFrame).data[1]);
 glBindTexture(GL_TEXTURE_2D, texture2);
 shader->setInt("textureU", 1);

 glActiveTexture(GL_TEXTURE2);
 glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, decoder->frameQueue.first().linesize[2], decoder->frameQueue.first().height / 2, format, GL_UNSIGNED_BYTE, decoder->frameQueue.at(currentFrame).data[2]);
 glBindTexture(GL_TEXTURE_2D, texture3);
 shader->setInt("textureV", 2);
 }

 ~VideoTexture() {
 printf("\nVideo texture destructor");
 glDeleteTextures(1, &texture1);
 glDeleteTextures(1, &texture2);
 glDeleteTextures(1, &texture3);
 }

 private:
 GLuint texture1;
 GLuint texture2;
 GLuint texture3;
 GLint internalFormat = GL_RG8;
 GLint format = GL_RED;
 int currentFrame = 0;
 Decoder *decoder;
}



-
how can i use the sox library to process the audio frame decoded by ffmpeg ?
14 juin 2023, par bishop使用sox音频处理库处理经过ffmpeg解码得到的音频帧,


//使用sox处理音频
 int sox_count = 9;
 if (StreamType::AUDIO == stream_type_ ) {
 sox_init();

 sox_signalinfo_t* in_signal = new sox_signalinfo_t();
 in_signal->rate = frame->sample_rate;
 in_signal->channels = frame->ch_layout.nb_channels;
 in_signal->length = frame->nb_samples * in_signal->channels;
 in_signal->precision = av_get_bytes_per_sample(static_cast<avsampleformat>(frame->format)) * 8;

 //= new sox_format_t();
 sox_encodinginfo_t* in_encoding = new sox_encodinginfo_t ();
 in_encoding->encoding = SOX_ENCODING_SIGN2 ;
 sox_format_t* tempFormat = sox_open_mem_read(frame->data[0],
 frame->linesize[0],
 in_signal, in_encoding, "raw");

 //sox_write(tempFormat, reinterpret_cast<const>(frame->data[0]), frame->nb_samples);

 sox_signalinfo_t* out_signal = in_signal; // 输出音频的参数与输入音频相同
 //out_signal->rate = new_sample_rate; // 新的采样率,根据需要进行修改

 sox_encodinginfo_t* out_encoding = in_encoding; // 输出音频的编码格式与输入音频相同

 sox_format_t* outputFormat = sox_open_mem_write(frame->data[0],
 frame->linesize[0],
 out_signal, out_encoding, "raw", nullptr);

 // 3. 使用SoX处理临时文件中的音频数据
 sox_effects_chain_t* chain = sox_create_effects_chain(&tempFormat->encoding, &outputFormat->encoding);
 sox_effect_t* effect;
 char* args[10];

 effect = sox_create_effect(sox_find_effect("input"));
 args[0] = (char*)tempFormat; // 变调参数,可以根据需求进行修改
 assert(sox_effect_options(effect, 1, args) ==SOX_SUCCESS);
 assert(sox_add_effect(chain, effect, &tempFormat->signal, &tempFormat->signal) == SOX_SUCCESS);
 free(effect);


 effect = sox_create_effect(sox_find_effect("vol"));
 args[0] = "200dB", assert(sox_effect_options(effect, 1, args) == SOX_SUCCESS);
 /* Add the effect to the end of the effects processing chain: */
 assert(sox_add_effect(chain, effect, &tempFormat->signal, &tempFormat->signal) == SOX_SUCCESS);
 free(effect);

 /*
 effect = sox_create_effect(sox_find_effect("pitch"));
 args[0] = {"50.0"}; // 变调参数,可以根据需求进行修改
 assert(sox_effect_options(effect, 1, args) == SOX_SUCCESS);
 assert(sox_add_effect(chain, effect, &tempFormat->signal, &outputFormat->signal) == SOX_SUCCESS);
 free(effect);
 */

 effect = sox_create_effect(sox_find_effect("output"));
 args[0] = (char*)outputFormat; // 变调参数,可以根据需求进行修改
 assert(sox_effect_options(effect, 1, args) == SOX_SUCCESS);
 if(sox_add_effect(chain, effect, &tempFormat->signal, &outputFormat->signal) == SOX_SUCCESS) {
 std::cout<<"true"</assert(sox_add_effect(chain, effect, &tempFormat->signal, &outputFormat->signal) == SOX_SUCCESS);
 free(effect);

 // 4. 处理音频数据
 sox_flow_effects(chain, nullptr, nullptr);

 fflush((FILE*)outputFormat->fp); 
 memcpy(frame->data[1], frame->data[0], frame->linesize[0]);

 // 释放资源
 sox_delete_effects_chain(chain);
 sox_close(tempFormat);
 sox_close(outputFormat);
 sox_quit();

 }
</const></avsampleformat>


error :"input : : this handler does not support this data size"


when execute in the line of "sox_flow_effects(chain, nullptr, nullptr) ;"


how can i fixed this problem ?


i have changed the val of "sox_format_t* tempFormat = sox_open_mem_read(frame->data[0],
frame->linesize[0],
in_signal, in_encoding, "raw") ;" buffer_size,but also not right.


-
lavfi/vf_libvmaf : add warning when color ranges differ
1er avril 2023, par Chema Gonzalezlavfi/vf_libvmaf : add warning when color ranges differ
The VMAF filter uses the pixel values without considering
the color ranges. This is incorrect. Patch adds a warning
so at least the user knows it.Let's see an example.
(1) Let's get FR and LR versions of the same image.
```
$ ffmpeg -y -i /tmp/lena.490x490.ppm -vf scale="out_range=full" -pix_fmt yuv420p /tmp/lena.full.y4m
$ xxd /tmp/lena.full.y4m |head
00000000 : 5955 5634 4d50 4547 3220 5734 3930 2048 YUV4MPEG2 W490 H
00000010 : 3439 3020 4632 353a 3120 4970 2041 303a 490 F25:1 Ip A0 :
00000020 : 3020 4334 3230 6a70 6567 2058 5953 4353 0 C420jpeg XYSCS
00000030 : 533d 3432 304a 5045 4720 5843 4f4c 4f52 S=420JPEG XCOLOR
00000040 : 5241 4e47 453d 4655 4c4c 0a46 5241 4d45 RANGE=FULL.FRAME
00000050 : 0a72 7271 7070 706f 6f6e 6d6d 6c6d 6d6d .rrqpppoonmmlmmm
00000060 : 6c6e 6e6d 6d6e 6e6e 6d6c 6d6d 6d6d 6d6d lnnmmnnnmlmmmmmm
00000070 : 6d6e 6d6b 6c6d 6e6e 6d6c 6d6d 6e6e 6f6f mnmklmnnmlmmnnoo
00000080 : 6f6f 6e6e 6e6e 6f70 7172 7375 7676 7370 oonnnnopqrsuvvsp
00000090 : 6d69 6662 5e59 534d 4845 3d35 302e 2d2c mifb^YSMHE=50.-,
``````
$ ffmpeg -y -i /tmp/lena.490x490.ppm -vf scale="out_range=limited" -pix_fmt yuv420p /tmp/lena.limited.y4m
$ xxd /tmp/lena.limited.y4m | head
00000000 : 5955 5634 4d50 4547 3220 5734 3930 2048 YUV4MPEG2 W490 H
00000010 : 3439 3020 4632 353a 3120 4970 2041 303a 490 F25:1 Ip A0 :
00000020 : 3020 4334 3230 6a70 6567 2058 5953 4353 0 C420jpeg XYSCS
00000030 : 533d 3432 304a 5045 4720 5843 4f4c 4f52 S=420JPEG XCOLOR
00000040 : 5241 4e47 453d 4c49 4d49 5445 440a 4652 RANGE=LIMITED.FR
00000050 : 414d 450a 7272 7170 7070 6f6f 6e6e 6e6d AME.rrqpppoonnnm
00000060 : 6e6e 6e6d 6f6e 6e6e 6e6e 6e6e 6d6e 6e6e nnnmonnnnnnnmnnn
00000070 : 6e6e 6e6e 6f6e 6c6d 6e6f 6e6e 6d6e 6e6f nnnnonlmnonnmnno
00000080 : 6f6f 6f6f 6f6f 6f6f 6f6f 7071 7273 7576 oooooooooopqrsuv
00000090 : 7673 706e 6a68 6461 5c57 524e 4b44 3d39 vspnjhda\WRNKD=9
```Note that the 2x images are the same. Only difference is the range,
and the precision issues related to range conversion.(2) Let's calculate the VMAF score :
```
$ ./ffmpeg -filter_threads 1 -filter_complex_threads 1 -i /tmp/lena.full.y4m -i /tmp/lena.limited.y4m -lavfi libvmaf="model=path=/usr/share/model/vmaf_v0.6.1neg.json" -report -f null -
...
[Parsed_libvmaf_0 @ 0x3cc9b40] VMAF score : 85.530109
```As we are comparing an image with itself, we expect the score to
be close to 100. Issue here is that the VMAF filter just uses the
pixel values, ignoring the color ranges.Proposed solution is to add a warning.
```
$ ./ffmpeg -filter_threads 1 -filter_complex_threads 1 -i /tmp/lena.full.y4m -i /tmp/lena.limited.y4m -lavfi libvmaf="model=path=/us
r/share/model/vmaf_v0.6.1neg.json" -report -f null -
...
[Parsed_libvmaf_0 @ 0x3cc9b40] distorted and reference frames use different color ranges (pc != tv)
...
[Parsed_libvmaf_0 @ 0x3cc9b40] VMAF score : 85.530109
```Tested :
Ran fate.
```
$ make fate -j
...
TEST seek-lavf-ppmpipe
TEST seek-lavf-pgmpipe
TEST seek-lavf-mxf_opatom
```