
Recherche avancée
Médias (2)
-
Exemple de boutons d’action pour une collection collaborative
27 février 2013, par
Mis à jour : Mars 2013
Langue : français
Type : Image
-
Exemple de boutons d’action pour une collection personnelle
27 février 2013, par
Mis à jour : Février 2013
Langue : English
Type : Image
Autres articles (72)
-
Configurer la prise en compte des langues
15 novembre 2010, parAccéder à la configuration et ajouter des langues prises en compte
Afin de configurer la prise en compte de nouvelles langues, il est nécessaire de se rendre dans la partie "Administrer" du site.
De là, dans le menu de navigation, vous pouvez accéder à une partie "Gestion des langues" permettant d’activer la prise en compte de nouvelles langues.
Chaque nouvelle langue ajoutée reste désactivable tant qu’aucun objet n’est créé dans cette langue. Dans ce cas, elle devient grisée dans la configuration et (...) -
Participer à sa traduction
10 avril 2011Vous pouvez nous aider à améliorer les locutions utilisées dans le logiciel ou à traduire celui-ci dans n’importe qu’elle nouvelle langue permettant sa diffusion à de nouvelles communautés linguistiques.
Pour ce faire, on utilise l’interface de traduction de SPIP où l’ensemble des modules de langue de MediaSPIP sont à disposition. ll vous suffit de vous inscrire sur la liste de discussion des traducteurs pour demander plus d’informations.
Actuellement MediaSPIP n’est disponible qu’en français et (...) -
Support de tous types de médias
10 avril 2011Contrairement à beaucoup de logiciels et autres plate-formes modernes de partage de documents, MediaSPIP a l’ambition de gérer un maximum de formats de documents différents qu’ils soient de type : images (png, gif, jpg, bmp et autres...) ; audio (MP3, Ogg, Wav et autres...) ; vidéo (Avi, MP4, Ogv, mpg, mov, wmv et autres...) ; contenu textuel, code ou autres (open office, microsoft office (tableur, présentation), web (html, css), LaTeX, Google Earth) (...)
Sur d’autres sites (6994)
-
FFMPEG convert NV12 format to NV12 with the same height and width
7 septembre 2022, par Chun WangI want to use FFmpeg4.2.2 to convert the input NV12 format to output NV12 format with the same height and width. I used sws_scale conversion, but the output frame's colors are all green.


P.S. It seems no need to use swscale to get the same width,same height and same format frame,but it is neccessary in my project for dealing with other frames.


I have successfully converted the input NV12 format to output NV12 format with the different height and width, the output frame's colors were right.But I FAILED to convert NV12 to NV12 with the same height and width. It was so weird, I couldn't know why :(


I want to know what the reason is and what I should do.
The following is my code.swsCtx4 was used for converting NV12 format to output NV12 format. Others were used for other formats converted test.
Thank you for you help


//the main code is 
 AVFrame* frame_nv12 = av_frame_alloc();
 frame_nv12->width = in_width;
 frame_nv12->height = in_height;
 frame_nv12->format = AV_PIX_FMT_NV12;
 uint8_t* frame_buffer_nv12 = (uint8_t*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_NV12, in_width, in_height , 1));
 av_image_fill_arrays(frame_nv12->data, frame_nv12->linesize, frame_buffer_nv12, AV_PIX_FMT_NV12, in_width, in_height, 1);


 AVFrame* frame2_nv12 = av_frame_alloc();
 frame2_nv12->width = in_width1;
 frame2_nv12->height = in_height1;
 frame2_nv12->format = AV_PIX_FMT_NV12;

 uint8_t* frame2_buffer_nv12 = (uint8_t*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_NV12, in_width1, in_height1, 1));
 av_image_fill_arrays(frame2_nv12->data, frame2_nv12->linesize, frame2_buffer_nv12, AV_PIX_FMT_NV12, in_width1, in_height1, 1);
 
 SwsContext* swsCtx4 = nullptr;
 swsCtx4 = sws_getContext(in_width, in_height, AV_PIX_FMT_NV12, in_width1, in_height1, AV_PIX_FMT_NV12,
 SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL);
 printf("swsCtx4\n");
 
 ret = sws_scale(swsCtx4, frame_nv12->data, frame_nv12->linesize, 0, frame_nv12->height, frame2_nv12->data, frame2_nv12->linesize);
 if (ret < 0) {
 printf("sws_4scale failed\n");
 }
 



//the complete code
extern "C" {
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>imgutils.h>
#include <libswscale></libswscale>swscale.h>
}
#include <seeker></seeker>loggerApi.h>
#include "seeker/common.h"
#include <iostream>

//解决原因:pts设置为0,dts设置为0
#define FILE_SRC "testPicFilter.yuv" //源文件
#define FILE_DES "test11.yuv" //源文件

int count = 0;


int main(int argc, char* argv[])
{
 av_register_all();

 int ret = 0;
 
 //std::this_thread::sleep_for(std::chrono::milliseconds(5000));
 int count1 = 1;
 int piccount;
 int align = 1;


 /*打开输入yuv文件*/
 FILE* fp_in = fopen(FILE_SRC, "rb+");
 if (fp_in == NULL)
 {
 printf("文件打开失败\n");
 return 0;
 }
 int in_width = 640;
 int in_height = 360;
 int in_width1 = 640;
 int in_height1 = 360;
 


 /*处理后的文件*/
 FILE* fp_out = fopen(FILE_DES, "wb+");
 if (fp_out == NULL)
 {
 printf("文件创建失败\n");
 return 0;
 }
 char buff[50];

 AVFrame* frame_in = av_frame_alloc();
 unsigned char* frame_buffer_in;
 frame_buffer_in = (unsigned char*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_YUV420P, in_width, in_height, 1));
 /*根据图像设置图像指针和内存对齐方式*/
 av_image_fill_arrays(frame_in->data, frame_in->linesize, frame_buffer_in, AV_PIX_FMT_YUV420P, in_width, in_height, 1);

 frame_in->width = in_width;
 frame_in->height = in_height;
 frame_in->format = AV_PIX_FMT_YUV420P;


 //输入yuv转成frame_nv12
 AVFrame* frame_nv12 = av_frame_alloc();
 frame_nv12->width = in_width;
 frame_nv12->height = in_height;
 frame_nv12->format = AV_PIX_FMT_NV12;
 uint8_t* frame_buffer_nv12 = (uint8_t*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_NV12, in_width, in_height , 1));
 av_image_fill_arrays(frame_nv12->data, frame_nv12->linesize, frame_buffer_nv12, AV_PIX_FMT_NV12, in_width, in_height, 1);


 AVFrame* frame2_nv12 = av_frame_alloc();
 frame2_nv12->width = in_width1;
 frame2_nv12->height = in_height1;
 frame2_nv12->format = AV_PIX_FMT_NV12;

 uint8_t* frame2_buffer_nv12 = (uint8_t*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_NV12, in_width1, in_height1, 1));
 av_image_fill_arrays(frame2_nv12->data, frame2_nv12->linesize, frame2_buffer_nv12, AV_PIX_FMT_NV12, in_width1, in_height1, 1);


 
 //输入rgb转成yuv
 AVFrame* frame_yuv = av_frame_alloc();
 frame_yuv->width = in_width;
 frame_yuv->height = in_height;
 frame_yuv->format = AV_PIX_FMT_YUV420P;
 uint8_t* frame_buffer_yuv = (uint8_t*)av_malloc(av_image_get_buffer_size(AV_PIX_FMT_YUV420P, in_width, in_height, 1));
 av_image_fill_arrays(frame_yuv->data, frame_yuv->linesize, frame_buffer_yuv,
 AV_PIX_FMT_YUV420P, in_width, in_height, 1);



 SwsContext* swsCtx = nullptr;
 swsCtx = sws_getContext(in_width, in_height, AV_PIX_FMT_YUV420P, in_width, in_height, AV_PIX_FMT_NV12,
 SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL);
 printf("swsCtx\n");

 SwsContext* swsCtx4 = nullptr;
 swsCtx4 = sws_getContext(in_width, in_height, AV_PIX_FMT_NV12, in_width1, in_height1, AV_PIX_FMT_NV12,
 SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL);
 printf("swsCtx4\n");

 
 SwsContext* swsCtx2 = nullptr;
 swsCtx2 = sws_getContext(in_width1, in_height1, AV_PIX_FMT_NV12, in_width, in_height, AV_PIX_FMT_YUV420P,
 SWS_BILINEAR | SWS_PRINT_INFO, NULL, NULL, NULL);
 printf("swsCtx2\n");





 while (1)
 {


 count++;

 if (fread(frame_buffer_in, 1, in_width * in_height * 3 / 2, fp_in) != in_width * in_height * 3 / 2)
 {
 break;
 }

 frame_in->data[0] = frame_buffer_in;
 frame_in->data[1] = frame_buffer_in + in_width * in_height;
 frame_in->data[2] = frame_buffer_in + in_width * in_height * 5 / 4;


 //转NV12格式
 int ret = sws_scale(swsCtx, frame_in->data, frame_in->linesize, 0, frame_in->height, frame_nv12->data, frame_nv12->linesize);
 if (ret < 0) {
 printf("sws_scale swsCtx failed\n");
 }


 ret = sws_scale(swsCtx4, frame_nv12->data, frame_nv12->linesize, 0, frame_nv12->height, frame2_nv12->data, frame2_nv12->linesize);
 if (ret < 0) {
 printf("sws_scale swsCtx4 failed\n");
 }
 

 if (ret > 0) {
 
 int ret2 = sws_scale(swsCtx2, frame2_nv12->data, frame2_nv12->linesize, 0, frame2_nv12->height, frame_yuv->data, frame_yuv->linesize);
 if (ret2 < 0) {
 printf("sws_scale swsCtx2 failed\n");
 }
 I_LOG("frame_yuv:{},{}", frame_yuv->width, frame_yuv->height);

 
 //I_LOG("frame_yuv:{}", frame_yuv->format);

 if (frame_yuv->format == AV_PIX_FMT_YUV420P)
 {

 for (int i = 0; i < frame_yuv->height; i++)
 {
 fwrite(frame_yuv->data[0] + frame_yuv->linesize[0] * i, 1, frame_yuv->width, fp_out);
 }
 for (int i = 0; i < frame_yuv->height / 2; i++)
 {
 fwrite(frame_yuv->data[1] + frame_yuv->linesize[1] * i, 1, frame_yuv->width / 2, fp_out);
 }
 for (int i = 0; i < frame_yuv->height / 2; i++)
 {
 fwrite(frame_yuv->data[2] + frame_yuv->linesize[2] * i, 1, frame_yuv->width / 2, fp_out);
 }
 printf("yuv to file\n");
 }
 }

 }


 fclose(fp_in);
 fclose(fp_out);
 av_frame_free(&frame_in);
 av_frame_free(&frame_nv12);
 av_frame_free(&frame_yuv);
 sws_freeContext(swsCtx);
 sws_freeContext(swsCtx2);
 sws_freeContext(swsCtx4);

 //std::this_thread::sleep_for(std::chrono::milliseconds(8000));

 return 0;

}



</iostream>


-
Revert "avfilter/vf_noise : dont corrupt the picture outside width x height"
13 septembre 2013, par Michael NiedermayerRevert "avfilter/vf_noise : dont corrupt the picture outside width x height"
This reverts commit 51dab60c7b91a21ec280c7d3042aa8350aae048f.
this fixed nothing, and was just the result of assuming that the
variable named linesize was the linesize. Its not, its the width
in bytes which was already correct.Found-by : durandal_1707
-
ffmpeg DASH - Include the stream's width and height (WxH) in the outputted filenames
20 juillet 2022, par JaradGiven this :


ffmpeg -i test.mp4 -c:a aac -c:v libx264 ^
-map v:0 -s:0 960x540 -b:v:0 800k ^
-map v:0 -s:1 320x170 -b:v:0 300k ^
-map 0:a ^
-f dash dash/master.mpd



Produces this :


chunk-stream0-00001.m4s
chunk-stream0-00002.m4s
...
chunk-stream0-00044.m4s
chunk-stream0-00045.m4s
chunk-stream1-00001.m4s
chunk-stream1-00002.m4s
...
chunk-stream1-00044.m4s
chunk-stream1-00045.m4s
chunk-stream2-00001.m4s
chunk-stream2-00002.m4s
...
chunk-stream2-00074.m4s
chunk-stream2-00075.m4s
init-stream0.m4s
init-stream1.m4s
init-stream2.m4s
master.mpd



Inspection shows :
ffprobe master.mpd


Input #0, dash, from 'master.mpd':
 Duration: 00:06:11.00, start: -0.021333, bitrate: 0 kb/s
 Program 0
 Stream #0:0: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 960x540 [SAR 1:1 DAR 16:9], 152 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
 Metadata:
 variant_bitrate : 300000
 id : 0
 Stream #0:1: Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 320x170 [SAR 17:18 DAR 16:9], 21 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
 Metadata:
 variant_bitrate : 28227
 id : 1
 Stream #0:2(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 110 kb/s (default)
 Metadata:
 variant_bitrate : 128000
 id : 2



I want output instead like this :


chunk-stream0-960x540-00001.m4s
chunk-stream0-960x540-00002.m4s
...
chunk-stream0-960x540-00044.m4s
chunk-stream0-960x540-00045.m4s
chunk-stream1-320x170-00001.m4s
chunk-stream1-320x170-00002.m4s
...
chunk-stream1-320x170-00044.m4s
chunk-stream1-320x170-00045.m4s
chunk-stream2-???????-00001.m4s
chunk-stream2-???????-00002.m4s
...
chunk-stream2-???????-00074.m4s
chunk-stream2-???????-00075.m4s
init-stream0-960x540.m4s
init-stream1-320x170.m4s
init-stream2-???????.m4s
master.mpd



where
???????
could be justaudio
or48000hz
or whatever.

The Question


Is there a way to include the stream's width and height (its size) in the outputted filenames from the command-line interface ? If no, how could it be accomplished using a shell script for example.