
Recherche avancée
Médias (2)
-
Valkaama DVD Label
4 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Image
-
Podcasting Legal guide
16 mai 2011, par
Mis à jour : Mai 2011
Langue : English
Type : Texte
Autres articles (22)
-
La sauvegarde automatique de canaux SPIP
1er avril 2010, parDans le cadre de la mise en place d’une plateforme ouverte, il est important pour les hébergeurs de pouvoir disposer de sauvegardes assez régulières pour parer à tout problème éventuel.
Pour réaliser cette tâche on se base sur deux plugins SPIP : Saveauto qui permet une sauvegarde régulière de la base de donnée sous la forme d’un dump mysql (utilisable dans phpmyadmin) mes_fichiers_2 qui permet de réaliser une archive au format zip des données importantes du site (les documents, les éléments (...) -
Script d’installation automatique de MediaSPIP
25 avril 2011, parAfin de palier aux difficultés d’installation dues principalement aux dépendances logicielles coté serveur, un script d’installation "tout en un" en bash a été créé afin de faciliter cette étape sur un serveur doté d’une distribution Linux compatible.
Vous devez bénéficier d’un accès SSH à votre serveur et d’un compte "root" afin de l’utiliser, ce qui permettra d’installer les dépendances. Contactez votre hébergeur si vous ne disposez pas de cela.
La documentation de l’utilisation du script d’installation (...) -
Automated installation script of MediaSPIP
25 avril 2011, parTo overcome the difficulties mainly due to the installation of server side software dependencies, an "all-in-one" installation script written in bash was created to facilitate this step on a server with a compatible Linux distribution.
You must have access to your server via SSH and a root account to use it, which will install the dependencies. Contact your provider if you do not have that.
The documentation of the use of this installation script is available here.
The code of this (...)
Sur d’autres sites (3581)
-
Encode images to video by using ffmpeg API?
18 avril 2013, par Super AstroI want to encode some image files into one video file, and play each image for 1 second.
So I wrote a simple function to encode only one image to a video
void PhotoStory::test(char* imagefile,char* videoFile)
{
av_register_all();
avcodec_register_all();
AVCodecContext *pOCtx= NULL;
AVCodec *pOCodex = NULL;
pOCodex = avcodec_find_encoder(CODEC_ID_MPEG1VIDEO);
pOCtx= avcodec_alloc_context3(pOCodex);
pOCtx->bit_rate = 400000;
pOCtx->width = 640;
pOCtx->height = 480;
AVRational rational = {1,25};
pOCtx->time_base= rational;
pOCtx->gop_size = 10; /* emit one intra frame every ten frames */
pOCtx->max_b_frames=1;
pOCtx->pix_fmt = PIX_FMT_YUV420P;
int ret = avcodec_open2(pOCtx,pOCodex,NULL);
if(ret < 0)
{
return;
}
AVFormatContext *pIFormatCtx = NULL;
ret = avformat_open_input(&pIFormatCtx, imagefile, NULL, NULL);
if(ret < 0)
{
//Cant't open jpg file
return;
}
av_dump_format(pIFormatCtx, 0, imagefile, false);
AVCodecContext *pICodecCtx; //output codec context
pICodecCtx = pIFormatCtx->streams[0]->codec;
/*pICodecCtx->width = 640;
pICodecCtx->height = 480;
pICodecCtx->pix_fmt = PIX_FMT_YUV420P;*/
AVCodec *pICodec = avcodec_find_decoder(pICodecCtx->codec_id); //output codec
// Open codec
ret = avcodec_open2(pICodecCtx, pICodec,NULL);
if(ret < 0)
{
//Can't find the decoder
return;
}
AVFrame *pIFrame = avcodec_alloc_frame();
if (!pIFrame)
{
//Can't alloc the input frame
return ;
}
int bufSize = avpicture_get_size(PIX_FMT_YUVJ420P, pICodecCtx->width, pICodecCtx->height);
uint8_t *buffer = (uint8_t *) av_malloc(bufSize * sizeof(uint8_t));
avpicture_fill((AVPicture *) pIFrame, buffer, PIX_FMT_YUVJ420P, pICodecCtx->width, pICodecCtx->height);
FILE *outputFile;
if(fopen_s(&outputFile,videoFile,"wb") < 0)
{
//TODO open file error
}
int outbuf_size = 100000;
outbuf = (uint8_t*)malloc(outbuf_size);
AVPacket packet;
int frameFinished;
int framesNumber = 0;
while (av_read_frame(pIFormatCtx, &packet) >= 0)
{
if(packet.stream_index != 0)
continue;
ret = avcodec_decode_video2(pICodecCtx, pIFrame, &frameFinished, &packet);
if (ret > 0)
{
pIFrame->quality = 4;
for(i=0;i<25;i++) {
fflush(stdout);
/* encode the image */
out_size = avcodec_encode_video(pOCtx, outbuf, outbuf_size, pIFrame);
fwrite(outbuf, 1, out_size, outputFile);
}
}
}
/* get the delayed frames */
for(; out_size; i++) {
fflush(stdout);
out_size = avcodec_encode_video(pOCtx, outbuf, outbuf_size, NULL);
fwrite(outbuf, 1, out_size, outputFile);
}
/* add sequence end code to have a real mpeg file */
outbuf[0] = 0x00;
outbuf[1] = 0x00;
outbuf[2] = 0x01;
outbuf[3] = 0xb7;
fwrite(outbuf, 1, 4, outputFile);
fclose(outputFile);
free(outbuf);
avcodec_close(pOCtx);
av_free(pOCtx);
av_free(pIFrame);
}but, the result seems not correct.
the output file is only 4 bits.Anybody can help me to figure out the problem and correct the function ?
thanks !
-
Concat two mp4 files with ffmpeg without losing quality [migrated]
13 juin 2013, par jeniai have now a problem with concatenating of 2 videos using ffmpeg.
So, i am encoding the source mp4 files to ts withffmpeg -i output1.mp4 -scodec copy -vbsf h264_mp4toannexb i0.ts
but the file i get looks much worse, then the source file.
here is the information about both the files
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'output1.mp4':
Metadata:
major_brand : isom
minor_version : 1
compatible_brands: isom
creation_time : 2013-06-13 15:40:36
Duration: 00:00:15.72, start: 0.000000, bitrate: 2053 kb/s
Stream #0.0(und): Video: h264 (High), yuv420p, 1280x720, 1931 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc
Stream #0.1(und): Audio: aac, 44100 Hz, stereo, s16, 128 kb/s
Input #0, mpegts, from 'i0.ts':
Duration: 00:00:15.64, start: 1.400000, bitrate: 1382 kb/s
Program 1
Metadata:
service_name : Service01
service_provider: Libav
Stream #0.0[0x100]: Video: mpeg2video (Main), yuv420p, 1280x720 [PAR 1:1 DAR 16:9], 104857 kb/s, 25 fps, 25 tbr, 90k tbn, 50 tbc
Stream #0.1[0x101](und): Audio: mp2, 44100 Hz, stereo, s16, 128 kb/sSo, how can i solve this problem ?
Thanks in advance ! -
FFMpeg encoded video will only play in FFPlay
8 novembre 2013, par mohMI've been debugging my program for a couple of weeks now with the output video only showing a blank screen (was testing with VLC, WMP and WMPClassic). I happened to try using FFPlay and lo and behold the video works perfectly. I've read that this is usually caused by an incorrect pixel format, and that switching to PIX_FMT_YUV420P will make it work universally...but I'm already using that pixel format in the encoding process. Is there anything else that is causing this ?
AVCodec* codec;
AVCodecContext* c = NULL;
uint8_t* outbuf;
int i, out_size, outbuf_size;
avcodec_register_all();
printf("Video encoding\n");
// Find the mpeg1 video encoder
codec = avcodec_find_encoder(CODEC_ID_H264);
if (!codec) {
fprintf(stderr, "Codec not found\n");
exit(1);
}
else printf("H264 codec found\n");
c = avcodec_alloc_context3(codec);
c->bit_rate = 400000;
c->width = 1920; // resolution must be a multiple of two (1280x720),(1900x1080),(720x480)
c->height = 1200;
c->time_base.num = 1; // framerate numerator
c->time_base.den = 25; // framerate denominator
c->gop_size = 10; // emit one intra frame every ten frames
c->max_b_frames = 1; // maximum number of b-frames between non b-frames
//c->keyint_min = 1; // minimum GOP size
//c->i_quant_factor = (float)0.71; // qscale factor between P and I frames
//c->b_frame_strategy = 20;
//c->qcompress = (float)0.6;
//c->qmin = 20; // minimum quantizer
//c->qmax = 51; // maximum quantizer
//c->max_qdiff = 4; // maximum quantizer difference between frames
//c->refs = 4; // number of reference frames
//c->trellis = 1; // trellis RD Quantization
c->pix_fmt = PIX_FMT_YUV420P;
c->codec_id = CODEC_ID_H264;
//c->codec_type = AVMEDIA_TYPE_VIDEO;
// Open the encoder
if (avcodec_open2(c, codec,NULL) < 0) {
fprintf(stderr, "Could not open codec\n");
exit(1);
}
else printf("H264 codec opened\n");
outbuf_size = 100000 + c->width*c->height*(32>>3);//*(32>>3); // alloc image and output buffer
outbuf = static_cast(malloc(outbuf_size));
printf("Setting buffer size to: %d\n",outbuf_size);
FILE* f = fopen("example.mpg","wb");
if(!f) printf("x - Cannot open video file for writing\n");
else printf("Opened video file for writing\n");
// encode 5 seconds of video
for(i=0;iwidth, c->height);
uint8_t* outbuffer = (uint8_t*)av_malloc(nbytes*sizeof(uint8_t));
AVFrame* inpic = avcodec_alloc_frame();
AVFrame* outpic = avcodec_alloc_frame();
outpic->pts = (int64_t)((float)i * (1000.0/((float)(c->time_base.den))) * 90);
avpicture_fill((AVPicture*)inpic, (uint8_t*)pPixels, PIX_FMT_RGB32, c->width, c->height); // Fill picture with image
avpicture_fill((AVPicture*)outpic, outbuffer, PIX_FMT_YUV420P, c->width, c->height);
av_image_alloc(outpic->data, outpic->linesize, c->width, c->height, c->pix_fmt, 1);
inpic->data[0] += inpic->linesize[0]*(screenHeight-1); // Flipping frame
inpic->linesize[0] = -inpic->linesize[0]; // Flipping frame
struct SwsContext* fooContext = sws_getContext(screenWidth, screenHeight, PIX_FMT_RGB32, c->width, c->height, PIX_FMT_YUV420P, SWS_FAST_BILINEAR, NULL, NULL, NULL);
sws_scale(fooContext, inpic->data, inpic->linesize, 0, c->height, outpic->data, outpic->linesize);
// encode the image
out_size = avcodec_encode_video(c, outbuf, outbuf_size, outpic);
printf("Encoding frame %3d (size=%5d)\n", i, out_size);
fwrite(outbuf, 1, out_size, f);
delete [] pPixels;
av_free(outbuffer);
av_free(inpic);
av_free(outpic);
}
// get the delayed frames
for(; out_size; i++) {
fflush(stdout);
out_size = avcodec_encode_video(c, outbuf, outbuf_size, NULL);
printf("Writing frame %3d (size=%5d)\n", i, out_size);
fwrite(outbuf, 1, out_size, f);
}
// add sequence end code to have a real mpeg file
outbuf[0] = 0x00;
outbuf[1] = 0x00;
outbuf[2] = 0x01;
outbuf[3] = 0xb7;
fwrite(outbuf, 1, 4, f);
fclose(f);
avcodec_close(c);
free(outbuf);
av_free(c);
printf("Closed codec and Freed\n");