
Recherche avancée
Médias (3)
-
Elephants Dream - Cover of the soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
Valkaama DVD Label
4 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Publier une image simplement
13 avril 2011, par ,
Mis à jour : Février 2012
Langue : français
Type : Video
Autres articles (54)
-
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 ;
-
Ecrire une actualité
21 juin 2013, parPrésentez les changements dans votre MédiaSPIP ou les actualités de vos projets sur votre MédiaSPIP grâce à la rubrique actualités.
Dans le thème par défaut spipeo de MédiaSPIP, les actualités sont affichées en bas de la page principale sous les éditoriaux.
Vous pouvez personnaliser le formulaire de création d’une actualité.
Formulaire de création d’une actualité Dans le cas d’un document de type actualité, les champs proposés par défaut sont : Date de publication ( personnaliser la date de publication ) (...) -
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 (8437)
-
High Definition Compatible Digital (HDCD) decoder filter, using libhdcd
26 août 2016, par Burt PHigh Definition Compatible Digital (HDCD) decoder filter, using libhdcd
Signed-off-by : Burt P <pburt0@gmail.com>
Signed-off-by : Diego Biurrun <diego@biurrun.de>
Signed-off-by : Luca Barbato <lu_zero@gentoo.org> -
audiodsp/x86 : clear the high bits of the order parameter on 64bit
9 août 2016, par Anton Khirnov -
Generating mp4 from images with libavformat has really high framerate
13 septembre 2016, par Taylor SouthwickI want to generate video from still shots using libav. I’ve successfully done this when the container is
.avi
, but I would also like to be able to output it into.mp4
. However, when I try to do this, on the initial frame is shown (the.avi
version works fine. I’ve created the following repro of the pertinent code using dummy picture generation.If you run
CreateVideo("test.avi", 600, 300);
It will generate a functional video. However,
CreateVideo("test.mp4", 600, 300);
will generate a video, but only a single frame.
Any thoughts on why it works for
.avi
but not.mp4
? Is there a setting I’m missing ?extern "C" {
#include <libavformat></libavformat>avformat.h>
#include <libavutil></libavutil>avassert.h>
#include <libavutil></libavutil>channel_layout.h>
#include <libavutil></libavutil>opt.h>
#include <libavutil></libavutil>mathematics.h>
#include <libavutil></libavutil>imgutils.h>
#include <libswscale></libswscale>swscale.h>
#include <libswresample></libswresample>swresample.h>
}
using namespace std;
using namespace Ffmpeg;
void AddFrame(AVPacket &pkt, AVCodecContext *codec, AVFormatContext *_avFmtCtx, AVFrame *_frame, int i)
{
// Initialize a packet and clear data as it will be allocated by the encoder
av_init_packet(&pkt);
pkt.data = nullptr;
pkt.size = 0;
i = i % 25;
/* prepare a dummy image */
/* Y */
for (int y = 0; y < _frame->height; y++) {
for (int x = 0; x < _frame->width; x++) {
_frame->data[0][y * _frame->linesize[0] + x] = x + y + i * 3;
}
}
/* Cb and Cr */
for (int y = 0; y < _frame->height / 2; y++) {
for (int x = 0; x < _frame->width / 2; x++) {
_frame->data[1][y * _frame->linesize[1] + x] = 128 + y + i * 2;
_frame->data[2][y * _frame->linesize[2] + x] = 64 + x + i * 5;
}
}
int got_output;
avcodec_encode_video2(codec, &pkt, _frame, &got_output);
_frame->pts++;
if (got_output)
{
av_interleaved_write_frame(_avFmtCtx, &pkt);
av_packet_unref(&pkt);
}
}
static void CreateVideo(string path, int width, int height)
{
// This will quickly exit if registration has already occurred
av_register_all();
AVFormatContext *_avFmtCtx;
avformat_alloc_output_context2(&_avFmtCtx, nullptr, nullptr, path.c_str());
AVCodec *codec = avcodec_find_encoder(_avFmtCtx->oformat->video_codec);
AVStream *_video = avformat_new_stream(_avFmtCtx, codec);
// Customize codec
_video->codec->coder_type = AVMEDIA_TYPE_VIDEO;
_video->codec->bit_rate = 200000;
_video->codec->width = width;
_video->codec->height = height;
_video->codec->time_base.num = 1;
_video->codec->time_base.den = 15;
_video->codec->gop_size = 12;
_video->codec->pix_fmt = AV_PIX_FMT_YUV420P;
if (_video->codec->codec_id == AV_CODEC_ID_MPEG2VIDEO)
{
// Just for testing, add B-frames
#ifdef _DEBUG
_video->codec->max_b_frames = 2;
#endif
}
if (_video->codec->codec_id == AV_CODEC_ID_MPEG1VIDEO)
{
_video->codec->mb_decision = 2;
}
if (_avFmtCtx->oformat->flags & AVFMT_GLOBALHEADER)
{
_video->codec->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
// Open file
avio_open(&_avFmtCtx->pb, path.c_str(), AVIO_FLAG_WRITE);
avformat_write_header(_avFmtCtx, nullptr);
AVFrame *_frame = av_frame_alloc();
_frame->format = _video->codec->pix_fmt;
_frame->width = _video->codec->width;
_frame->height = _video->codec->height;
_frame->pts = 0;
/* the image can be allocated by any means and av_image_alloc() is *
* just the most convenient way if av_malloc() is to be used */
av_image_alloc(_frame->data, _frame->linesize, _video->codec->width, _video->codec->height, _video->codec->pix_fmt, 32);
avcodec_open2(_video->codec, codec, nullptr);
SwsContext *_swsCtx = sws_getContext(width, height,
AV_PIX_FMT_BGRA,
width, height,
AV_PIX_FMT_YUV420P,
0, 0, 0, 0);
AVPacket packet;
for (int i = 0; i < 25; i++)
{
AddFrame(packet, _video->codec, _avFmtCtx, _frame, i);
}
/* get the delayed frames */
int got_output = 1;
while (got_output)
{
// Initialize a packet and clear data as it will be allocated by the encoder
AVPacket pkt;
av_init_packet(&pkt);
pkt.data = nullptr;
pkt.size = 0;
avcodec_encode_video2(_video->codec, &pkt, nullptr, &got_output);
if (got_output)
{
av_interleaved_write_frame(_avFmtCtx, &pkt);
av_packet_unref(&pkt);
}
}
av_write_trailer(_avFmtCtx);
avio_close(_avFmtCtx->pb);
sws_freeContext(_swsCtx);
av_freep(&_frame->data);
av_frame_free(&_frame);
avcodec_close(_video->codec);
avformat_free_context(_avFmtCtx);
}