
Recherche avancée
Médias (3)
-
MediaSPIP Simple : futur thème graphique par défaut ?
26 septembre 2013, par
Mis à jour : Octobre 2013
Langue : français
Type : Video
-
GetID3 - Bloc informations de fichiers
9 avril 2013, par
Mis à jour : Mai 2013
Langue : français
Type : Image
-
GetID3 - Boutons supplémentaires
9 avril 2013, par
Mis à jour : Avril 2013
Langue : français
Type : Image
Autres articles (71)
-
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 (...) -
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 -
Les formats acceptés
28 janvier 2010, parLes commandes suivantes permettent d’avoir des informations sur les formats et codecs gérés par l’installation local de ffmpeg :
ffmpeg -codecs ffmpeg -formats
Les format videos acceptés en entrée
Cette liste est non exhaustive, elle met en exergue les principaux formats utilisés : h264 : H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 m4v : raw MPEG-4 video format flv : Flash Video (FLV) / Sorenson Spark / Sorenson H.263 Theora wmv :
Les formats vidéos de sortie possibles
Dans un premier temps on (...)
Sur d’autres sites (12723)
-
ffmpeg : libavfilter API av_buffersink_get_frame returns alway EAGAIN
29 juin 2024, par aculnaigI want to resize an image with
libavfilter
C API throughzscale
filter andlibplacebo
filter but no matter how I callav_buffersink_get_frame
, it always returnsEAGAIN
and no data is filled in thefiltered_frame
.

#include 
#include 
#include 
#include 
#include 

#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavfilter></libavfilter>avfilter.h>
#include <libavfilter></libavfilter>buffersrc.h>
#include <libavfilter></libavfilter>buffersink.h>
#include <libavutil></libavutil>log.h>

int main(int argc, char **argv)
{
 if (argc != 2) {
 fprintf(stderr, "usage: %s <filename>\n", argv[0]);
 exit(EXIT_FAILURE);
 }

 const char *src_name = argv[1];
 const char *dst_name = basename(src_name);
 int ret = 0;

 const enum AVPixelFormat src_format = AV_PIX_FMT_YUV422P;

 av_log_set_level(AV_LOG_TRACE);

 AVFormatContext *fmt_ctx = avformat_alloc_context();
 if (fmt_ctx == NULL) {
 av_log(NULL, AV_LOG_TRACE, "avformat_alloc_context(): failed.\n");
 exit(EXIT_SUCCESS);
 }
 if ((ret = avformat_open_input(&fmt_ctx, src_name, NULL, NULL)) != 0) {
 av_log(NULL, AV_LOG_TRACE, "avformat_open_input(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }

 AVCodecContext *dec_ctx;
 AVCodec *dec;

 if ((ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &dec, 0)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "av_find_best_stream(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }
 dec_ctx = avcodec_alloc_context3(dec);
 if (dec_ctx == NULL) {
 av_log(NULL, AV_LOG_TRACE, "avcodec_alloc_context3(): failed.\n");
 exit(EXIT_SUCCESS);
 }
 if ((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "avcodec_open2(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }

 AVFrame *frame = av_frame_alloc();
 if (frame == NULL) {
 av_log(NULL, AV_LOG_TRACE, "av_frame_alloc(): failed.\n");
 exit(EXIT_SUCCESS);
 }
 AVPacket *packet = av_packet_alloc();
 if (packet == NULL) {
 av_log(NULL, AV_LOG_TRACE, "av_packet_alloc(): failed.\n");
 exit(EXIT_SUCCESS);
 }

 if ((ret = av_read_frame(fmt_ctx, packet)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "av_read_frame(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }
 ret = avcodec_send_packet(dec_ctx, packet);
 if (ret == AVERROR(EAGAIN)) {
 av_log(NULL, AV_LOG_TRACE, "avcodec_send_packet(): %s.\n", av_err2str(ret));
 avcodec_receive_frame(dec_ctx, frame);
 avcodec_send_packet(dec_ctx, packet);
 }
 
 if ((ret = avcodec_receive_frame(dec_ctx, frame)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "avcodec_receive_frame(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }
 av_packet_unref(packet);

 av_log(NULL, AV_LOG_TRACE, "filename: %s, w: %d, h: %d, fmt: %d\n", src_name, frame->width, frame->height, frame->format);

 AVFilterGraph *filter_graph = avfilter_graph_alloc();

 char buffersrc_args[512];
 snprintf(buffersrc_args, sizeof(buffersrc_args), "video_size=%dx%d:pix_fmt=%d:time_base=1/25", frame->width, frame->height, frame->format); 

 AVFilterContext *buffersrc_ctx;
 if ((ret = avfilter_graph_create_filter(&buffersrc_ctx, avfilter_get_by_name("buffer"), NULL, buffersrc_args, NULL, filter_graph)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "avfilter_graph_create_filter(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }

 char libplacebo_args[512];
 snprintf(libplacebo_args, sizeof(libplacebo_args), "format=yuv420p:colorspace=bt470bg:color_primaries=bt709:color_trc=iec61966-2-1:range=pc:w=(iw/2):h=(ih/2):downscaler=none:dithering=none");
 AVFilterContext *libplacebo_ctx;
 if ((ret = avfilter_graph_create_filter(&libplacebo_ctx, avfilter_get_by_name("libplacebo"), NULL, libplacebo_args, NULL, filter_graph)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "avfilter_graph_create_filter(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }

 AVFilterContext *buffersink_ctx;
 if ((ret = avfilter_graph_create_filter(&buffersink_ctx, avfilter_get_by_name("buffersink"), NULL, NULL, NULL, filter_graph)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "avfilter_graph_create_filter(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }

 if ((ret = avfilter_link(buffersrc_ctx, 0, libplacebo_ctx, 0)) != 0) {
 av_log(NULL, AV_LOG_TRACE, "avfilter_link(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }
 if ((ret = avfilter_link(libplacebo_ctx, 0, buffersink_ctx, 0)) != 0) {
 av_log(NULL, AV_LOG_TRACE, "avfilter_link(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }
 
 if ((ret = avfilter_graph_config(filter_graph, NULL)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "avfilter_graph_config(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }

 AVFrame *filtered_frame = av_frame_alloc();
 if (filtered_frame == NULL) {
 av_log(NULL, AV_LOG_TRACE, "av_frame_alloc(): failed.\n");
 exit(EXIT_SUCCESS);
 }
 if ((ret = av_buffersrc_add_frame(buffersrc_ctx, frame)) < 0) {
 av_log(NULL, AV_LOG_TRACE, "av_buffersrc_add_frame(): %s.\n", av_err2str(ret));
 exit(EXIT_SUCCESS);
 }
 
 while (1) {
 int ret = av_buffersink_get_frame(buffersink_ctx, filtered_frame);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF)
 break;
 if (ret < 0) {
 av_log(NULL, AV_LOG_TRACE, "av_buffersink_get_frame(): %s.\n", av_err2str(ret));
 exit(EXIT_FAILURE);
 } 
 }

 av_log(NULL, AV_LOG_TRACE, "filename: %s, w: %d, h: %d, f: %d\n", dst_name, filtered_frame->width, filtered_frame->height, filtered_frame->format);

 AVCodecContext *enc_ctx;
 AVCodec *enc;
 AVPacket *enc_packet = av_packet_alloc();

 enc = avcodec_find_encoder_by_name("mjpeg");
 enc_ctx = avcodec_alloc_context3(enc);
 enc_ctx->width = filtered_frame->width;
 enc_ctx->height = filtered_frame->height;
 enc_ctx->bit_rate = dec_ctx->bit_rate * 1024;
 enc_ctx->time_base = (AVRational) {1, 25};
 enc_ctx->framerate = (AVRational) {25, 1};
 enc_ctx->pix_fmt = filtered_frame->format;
 enc_ctx->strict_std_compliance = FF_COMPLIANCE_EXPERIMENTAL;
 enc_ctx->compression_level = 0;
 enc_ctx->color_range = AVCOL_RANGE_JPEG;

 avcodec_open2(enc_ctx, enc, NULL);

 avcodec_send_frame(enc_ctx, filtered_frame);
 avcodec_receive_packet(enc_ctx, enc_packet);

 FILE *dst_file = fopen(dst_name, "wb");
 fwrite(enc_packet->data, 1, enc_packet->size, dst_file);
 fclose(dst_file);

 av_packet_unref(enc_packet);
 av_frame_free(&frame);
 av_frame_free(&filtered_frame);
 
 avfilter_graph_free(&filter_graph);

 avformat_close_input(&fmt_ctx);
 avformat_free_context(fmt_ctx);
 
 exit(EXIT_SUCCESS);
}
</filename>


and here are the logs




PS : the logs were so many I could paste in stackoverflow


-
FFmpeg - avcodec_receive_frame returns AVERROR(EAGAIN)
8 novembre 2019, par JinxI’m using an QOpenGL widget to draw frames. However, I’m struggling to get frames by using
avcodec_receive_frame
. It ended within the blockelse if (ret == AVERROR(EAGAIN))
and returned -11. I have no idea what made this happen. Also I checked that codecs were fine, so I guess the problem wasn’t caused by codecs.MyDemux.cpp
AVPacket* MyDemux::allocatePacket()
{
AVPacket* packet = av_packet_alloc();
return packet;
}
AVFrame* MyDemux::allocateFrame()
{
AVFrame* frame = av_frame_alloc();
return frame;
}
int MyDemux::readFrame(AVPacket* packet)
{
mux.lock();
if (!formatCtx) {
std::cout << "formaetCtx is null" << std::endl;
mux.unlock();
return -1;
}
int ret = av_read_frame(formatCtx, packet);
if (ret == AVERROR_EOF) {
return -2;
}
if (ret != 0) {
mux.unlock();
av_packet_free(&packet);
return -1;
}
media_type = packet->stream_index;
mux.unlock();
return 0;
}MyDecode.cpp
void MyDecode::decode(AVFrame* frame, AVPacket* packet)
{
int ret;
ret = avcodec_send_packet(codecCtx, packet); // this returned 0
while (ret == 0) {
ret = avcodec_receive_frame(codecCtx, frame); // this returned -11
if (ret == AVERROR(EINVAL)) {
std::cout << "codec issue" << std::endl;
av_frame_free(&frame);
return;
}
else if (ret == AVERROR(EAGAIN)) { // program ends here
std::cout << "output is not available this state" << std::endl;
av_frame_free(&frame);
return;
}
else if (ret == AVERROR(EINVAL)) {
std::cout << "no more frames" << std::endl;
av_frame_free(&frame);
return;
}
}
}main.cpp
class MyThread : public QThread
{
public:
MyDemux demux;
MyDecode video_decode;
myDecode audio_decode;
MyVideoWidget* videoWidget;
AVPacket* packet;
AVFrame* frame;
void initThread()
{
char* url = "demo.mp4";
demux.openFile(url);
video_decode.openCodec(demux.copy_video_codec_par());
audio_decode.openCodec(demux.copy_audio_codec_par());
packet = demux.allocatePacket();
frame = demux.allocateFrame();
}
void run()
{
while (demux.readFrame(packet) != -2) {
if (demux.get_media_type() == 0) {
video_decode.decode(frame, packet);
videoWidget->paintFrame(frame);
}
else if (demux.get_media_type() == 1) {
}
}
video_decode.decode(frame, nullptr);
demux.clear();
demux.close();
}
}; -
Révision 23837 : Report de r23836 : Meme si _VAR_MODE est deja definie, il faut exclure calcul et ...
14 décembre 2017, par cedric@yterium.com