
Recherche avancée
Autres articles (44)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
Websites made with MediaSPIP
2 mai 2011, parThis page lists some websites based on MediaSPIP.
-
Creating farms of unique websites
13 avril 2011, parMediaSPIP platforms can be installed as a farm, with a single "core" hosted on a dedicated server and used by multiple websites.
This allows (among other things) : implementation costs to be shared between several different projects / individuals rapid deployment of multiple unique sites creation of groups of like-minded sites, making it possible to browse media in a more controlled and selective environment than the major "open" (...)
Sur d’autres sites (7722)
-
rtpdec_h263_rfc2190 : Clear the stored bits if discarding buffered data
17 décembre 2014, par Martin Storsjörtpdec_h263_rfc2190 : Clear the stored bits if discarding buffered data
If we throw away the buffered incomplete frame, make sure to also
throw away the buffered bits of an incomplete byte at the same
time.CC : libav-stable@libav.org
Signed-off-by : Martin Storsjö <martin@martin.st> -
conversion from cv::mat to avframe
14 novembre 2014, par danicsi create a method for converting between cv::mat to avframe with PIX_FMT_YUV420P format (oframe format) but _convCtx always return null, whats wrong ? thanks in advance !
void processToFrame(cv::Mat* _mat, AVFrame* oframe)
{
// Create and allocate the conversion frame.
if (_oframe == nullptr) {
_oframe = avcodec_alloc_frame();
if (_oframe == nullptr)
throw std::runtime_error("Matrix Converter: Could not allocate the output frame.");
avpicture_alloc(reinterpret_cast(_oframe),
PIX_FMT_BGR24, _mat->cols, _mat->rows);
}
avpicture_fill(reinterpret_cast(_oframe),
(uint8_t *)_mat->data,
AV_PIX_FMT_BGR24,
_mat->cols,
_mat->rows);
// Convert the image from its native format to BGR.
if (_convCtx == nullptr) {
_convCtx = sws_getContext(
oframe->width, oframe->height, (enum AVPixelFormat) oframe->format,
_oframe->width, _oframe->height, PIX_FMT_BGR24,
SWS_BICUBIC, nullptr, nullptr, nullptr);
}
if (_convCtx == nullptr)
throw std::runtime_error("Matrix Converter: Unable to initialize the conversion context.");
// Scales the source data according to our SwsContext settings.
if (sws_scale(_convCtx,
_oframe->data, _oframe->linesize, 0, _oframe->height,
oframe->data, oframe->linesize) < 0)
throw std::runtime_error("Matrix Converter: Pixel format conversion not supported.");
}edit : create oframe
void createVideoFile(const char* filename, int w, int h, int codec_id, int fps)
{
/* find the mpeg1 video encoder */
if(codec == nullptr)
{
/* find the mpeg1 video encoder */
codec = avcodec_find_encoder((AVCodecID)codec_id);
if (!codec) {
throw std::runtime_error("codec not found\n");
}
}
if(c == nullptr)
{
c = avcodec_alloc_context3(codec);
if(!c)
{
throw std::runtime_error("Could not allocate video codec context\n");
}
/* put sample parameters */
c->bit_rate = 400000;
/* resolution must be a multiple of two */
c->width = 2 * (w / 2);
c->height = 2 * (h / 2);
/* frames per second */
AVRational ar;
ar.den = 1;
ar.num = fps;
c->time_base= ar; //(AVRational){1,25};
c->gop_size = 10; /* emit one intra frame every ten frames */
c->max_b_frames=1;
c->pix_fmt = PIX_FMT_YUV420P;
if(codec_id == AV_CODEC_ID_H264)
av_opt_set(c->priv_data, "preset", "slow", 0);
/* open it */
if (avcodec_open2(c, codec, NULL) < 0) {
throw std::runtime_error("Could not open codec\n");
}
f = fopen(filename, "wb");
if (!f) {
throw std::runtime_error("could not open file\n");
}
frame = avcodec_alloc_frame();
if (!frame) {
throw std::runtime_error("Could not allocate video frame\n");
}
frame->format = c->pix_fmt;
frame->width = c->width;
frame->height = c->height;
/* 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 */
int ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height, c->pix_fmt, 32);
if (ret < 0) {
throw std::runtime_error("Could not allocate raw picture buffer\n");
}
}
}read mat images
void video_encode_example(const cv::Mat& fin)
{
AVPacket pkt;
/* encode 1 second of video */
av_init_packet(&pkt);
pkt.data = NULL; // packet data will be allocated by the encoder
pkt.size = 0;
fflush(stdout);
cv::Mat res;
cv::resize(fin, res, cv::Size(c->width, c->height));
processToFrame(&res, frame);
frame->pts = i;
/* encode the image */
int ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
if (ret < 0) {
throw std::runtime_error("Error encoding frame\n");
}
if (got_output) {
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
i++;
/* get the delayed frames */
/*for (got_output = 1; got_output; i++) {
fflush(stdout);
ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
if (ret < 0) {
throw std::runtime_error("Error encoding frame\n");
}
if (got_output) {
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
}*/
} -
conversion from cv::mat to avframe, encode in h264 dont writing correctly [on hold]
15 novembre 2014, par danicsi create a method for converting between cv::mat to avframe with PIX_FMT_YUV420P format (oframe format) but _convCtx always return null, whats wrong ? thanks in advance ! ((i solve this)) but i have another probelm in end of this question please
void processToFrame(cv::Mat* _mat, AVFrame* oframe)
{
// Create and allocate the conversion frame.
if (_oframe == nullptr) {
_oframe = avcodec_alloc_frame();
if (_oframe == nullptr)
throw std::runtime_error("Matrix Converter: Could not allocate the output frame.");
avpicture_alloc(reinterpret_cast(_oframe),
PIX_FMT_BGR24, _mat->cols, _mat->rows);
}
avpicture_fill(reinterpret_cast(_oframe),
(uint8_t *)_mat->data,
AV_PIX_FMT_BGR24,
_mat->cols,
_mat->rows);
// Convert the image from its native format to BGR.
if (_convCtx == nullptr) {
_convCtx = sws_getContext(
oframe->width, oframe->height, (enum AVPixelFormat) oframe->format,
_oframe->width, _oframe->height, PIX_FMT_BGR24,
SWS_BICUBIC, nullptr, nullptr, nullptr);
}
if (_convCtx == nullptr)
throw std::runtime_error("Matrix Converter: Unable to initialize the conversion context.");
// Scales the source data according to our SwsContext settings.
if (sws_scale(_convCtx,
_oframe->data, _oframe->linesize, 0, _oframe->height,
oframe->data, oframe->linesize) < 0)
throw std::runtime_error("Matrix Converter: Pixel format conversion not supported.");
}create oframe
void createVideoFile(const char* filename, int w, int h, int codec_id, int fps)
{
/* find the mpeg1 video encoder */
if(codec == nullptr)
{
/* find the mpeg1 video encoder */
codec = avcodec_find_encoder((AVCodecID)codec_id);
if (!codec) {
throw std::runtime_error("codec not found\n");
}
}
if(c == nullptr)
{
c = avcodec_alloc_context3(codec);
if(!c)
{
throw std::runtime_error("Could not allocate video codec context\n");
}
/* put sample parameters */
c->bit_rate = 400000;
/* resolution must be a multiple of two */
c->width = 2 * (w / 2);
c->height = 2 * (h / 2);
/* frames per second */
AVRational ar;
ar.den = 1;
ar.num = fps;
c->time_base= ar; //(AVRational){1,25};
c->gop_size = 10; /* emit one intra frame every ten frames */
c->max_b_frames=1;
c->pix_fmt = PIX_FMT_YUV420P;
if(codec_id == AV_CODEC_ID_H264)
av_opt_set(c->priv_data, "preset", "slow", 0);
/* open it */
if (avcodec_open2(c, codec, NULL) < 0) {
throw std::runtime_error("Could not open codec\n");
}
f = fopen(filename, "wb");
if (!f) {
throw std::runtime_error("could not open file\n");
}
frame = avcodec_alloc_frame();
if (!frame) {
throw std::runtime_error("Could not allocate video frame\n");
}
frame->format = c->pix_fmt;
frame->width = c->width;
frame->height = c->height;
/* 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 */
int ret = av_image_alloc(frame->data, frame->linesize, c->width, c->height, c->pix_fmt, 32);
if (ret < 0) {
throw std::runtime_error("Could not allocate raw picture buffer\n");
}
}
}read mat images
void video_encode_example(const cv::Mat& fin)
{
AVPacket pkt;
/* encode 1 second of video */
av_init_packet(&pkt);
pkt.data = NULL; // packet data will be allocated by the encoder
pkt.size = 0;
fflush(stdout);
cv::Mat res;
cv::resize(fin, res, cv::Size(c->width, c->height));
processToFrame(&res, frame);
frame->pts = i;
/* encode the image */
int ret = avcodec_encode_video2(c, &pkt, frame, &got_output);
if (ret < 0) {
throw std::runtime_error("Error encoding frame\n");
}
if (got_output) {
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
i++;
}update :
i can solve the conversion problem by setting of _oframe.width = _mat.cols and _oframe.height = _mat.rows, avpicture_alloc dont set this value itself.
now i have the other problem my videowriting class seems write ok because windows slideshow show one of frames, but i cant view video in my players, this is my release function, i dont know whats wrong endcoding or endcoder structure parameter like pts and else.
void video_release()
{
/* get the delayed frames */
for (got_output = 1; got_output; i++) {
fflush(stdout);
int ret = avcodec_encode_video2(c, &pkt, NULL, &got_output);
if (ret < 0) {
throw std::runtime_error("Error encoding frame\n");
}
if (got_output) {
printf("Write frame %3d (size=%5d)\n", i, pkt.size);
fwrite(pkt.data, 1, pkt.size, f);
av_free_packet(&pkt);
}
}
uint8_t endcode[] = { 0, 0, 1, 0xb7 };
/* add sequence end code to have a real mpeg file */
fwrite(endcode, 1, sizeof(endcode), f);
fclose(f);
avcodec_close(c);
av_free(c);
av_freep(&frame->data[0]);
avcodec_free_frame(&frame);
c = nullptr;
codec = nullptr;
frame = nullptr;
if (_convCtx)
sws_freeContext(_convCtx);
if (_oframe) {
//if (_oframe->data)
//av_free(_oframe->data[0]);
av_free(_oframe);
}
_oframe = nullptr;
_convCtx = nullptr;
}