
Recherche avancée
Autres articles (93)
-
Utilisation et configuration du script
19 janvier 2011, parInformations spécifiques à la distribution Debian
Si vous utilisez cette distribution, vous devrez activer les dépôts "debian-multimedia" comme expliqué ici :
Depuis la version 0.3.1 du script, le dépôt peut être automatiquement activé à la suite d’une question.
Récupération du script
Le script d’installation peut être récupéré de deux manières différentes.
Via svn en utilisant la commande pour récupérer le code source à jour :
svn co (...) -
Configuration spécifique d’Apache
4 février 2011, parModules spécifiques
Pour la configuration d’Apache, il est conseillé d’activer certains modules non spécifiques à MediaSPIP, mais permettant d’améliorer les performances : mod_deflate et mod_headers pour compresser automatiquement via Apache les pages. Cf ce tutoriel ; mode_expires pour gérer correctement l’expiration des hits. Cf ce tutoriel ;
Il est également conseillé d’ajouter la prise en charge par apache du mime-type pour les fichiers WebM comme indiqué dans ce tutoriel.
Création d’un (...) -
MediaSPIP Player : problèmes potentiels
22 février 2011, parLe lecteur ne fonctionne pas sur Internet Explorer
Sur Internet Explorer (8 et 7 au moins), le plugin utilise le lecteur Flash flowplayer pour lire vidéos et son. Si le lecteur ne semble pas fonctionner, cela peut venir de la configuration du mod_deflate d’Apache.
Si dans la configuration de ce module Apache vous avez une ligne qui ressemble à la suivante, essayez de la supprimer ou de la commenter pour voir si le lecteur fonctionne correctement : /** * GeSHi (C) 2004 - 2007 Nigel McNie, (...)
Sur d’autres sites (3361)
-
GA360 Sunset : Is Now the Time to Switch ?
20 mai 2024, par Erin -
The issue of inccorrect duration time of MP4 file generated with FFMPEG SDK
28 avril 2016, par LavenderSsThe purpose of following code is to merge some pictures into a MP4 file with FFMPEG SDK and X265 encoder. The Mp4 file could be generated and played normally, but the duration time is longer than it should be. Eg. I have 8 pictures, and If the fps of MP4 is 2, the duration time shall be 4 seconds. But the actual duration time is 11 secodes. When I played this MP4 file, it will be over after playing 4s.
I am just fresh guy in the field of ffmpeg. I think the root cause of issue may be the incorrect bitrate, but I’ve tried updated the parameter of encoders, doesn’t work. Could any people who is familiar with ffmpeg programming help check this issue ? Really appreciate !!
#define IMAGE_FILE_NUMBER 8
#define MP4_FILE "test_sample_1.mp4"
char* image_file[IMAGE_FILE_NUMBER] =
{
"test_sample_1_1.bmp",
"test_sample_1_2.bmp",
"test_sample_1_3.bmp",
"test_sample_1_4.bmp",
"test_sample_1_5.bmp",
"test_sample_1_6.bmp",
"test_sample_1_7.bmp",
"test_sample_1_8.bmp"
};
void test_image2mp4(const char* output_filename)
{
printf(" Enter %s!!!\n", __FUNCTION__);
FILE *file[IMAGE_FILE_NUMBER]; /*image file handler*/
char *szTxt[IMAGE_FILE_NUMBER]; /*image data*/
int nDataLen[IMAGE_FILE_NUMBER]={0}; /*image data length (exclude header)*/
int nWidth = 0;
int nHeight= 0;
int nLen;
int nHeadLen;
int file_index;
int ret;
BITMAPFILEHEADER bmpFHeader = {0};
BITMAPINFOHEADER bmpIHeader = {0};
//Abstract image data from bmp files
for (file_index = 0; file_index < IMAGE_FILE_NUMBER; file_index ++)
{
file[file_index] = fopen(image_file[file_index], "rb");
av_assert0(file[file_index] != NULL);
/*Read image file*/
fseek(file[file_index],0,SEEK_END);
nLen = ftell(file[file_index]);
szTxt[file_index] = (char *)malloc(nLen);
fseek(file[file_index],0,SEEK_SET);
nLen = fread(szTxt[file_index],1,nLen,file[file_index]);
fclose(file[file_index]);
memcpy(&bmpFHeader, szTxt[file_index], sizeof(BITMAPFILEHEADER));
nHeadLen = bmpFHeader.bfOffBits - sizeof(BITMAPFILEHEADER);
memcpy(&bmpIHeader,szTxt[file_index]+sizeof(BITMAPFILEHEADER),nHeadLen);
nWidth = bmpIHeader.biWidth;
nHeight = bmpIHeader.biHeight;
szTxt[file_index] += bmpFHeader.bfOffBits;
nDataLen[file_index] = nLen-bmpFHeader.bfOffBits;
printf(" Read [%s] width:%d, height:%d, data len:%d.\n", image_file[file_index], nWidth, nHeight, nDataLen[file_index]);
}
av_register_all();
avcodec_register_all();
AVFormatContext *pFmtCtx = NULL;
AVCodec *pCodec;
AVStream *pVideoStream;
AVCodecContext *pCodecCtx;
AVFrame *pFrame;
AVFrame *pRGBFrame;
AVPacket pPkt;
unsigned char *yuv_buff;
unsigned char *rgb_buff;
struct SwsContext * pSwsCtx;
int size;
AVRational sRate;
sRate.num = 2000;
sRate.den = 1000;
pFmtCtx = avformat_alloc_context();
pFmtCtx->oformat = av_guess_format(NULL, output_filename, NULL);
avio_open(&pFmtCtx->pb, output_filename, AVIO_FLAG_WRITE);
pCodec = avcodec_find_encoder(AV_CODEC_ID_HEVC);
printf(" Found h265 codec...\n");
pVideoStream = avformat_new_stream(pFmtCtx, pCodec);
pVideoStream->time_base = sRate;
pVideoStream->avg_frame_rate = sRate;
pCodecCtx = pVideoStream->codec;
if (pFmtCtx->oformat->flags | AVFMT_GLOBALHEADER)
{
pCodecCtx->flags |= CODEC_FLAG_GLOBAL_HEADER;
}
av_opt_set(pCodecCtx->priv_data, "preset", "ultrafast", 0);
av_opt_set(pCodecCtx->priv_data, "tune", "zerolatency", 0);
av_opt_set(pCodecCtx->priv_data, "x265-params", "qp=20", 0);
av_opt_set(pCodecCtx->priv_data, "crf", "18", 0);
pCodecCtx->codec_id = AV_CODEC_ID_HEVC;//from lxh's case
pCodecCtx->codec_type = AVMEDIA_TYPE_VIDEO;
pCodecCtx->ticks_per_frame = 2;
pCodecCtx->max_b_frames = 1;//0
pCodecCtx->bit_rate_tolerance = 1;
pCodecCtx->pix_fmt = AV_PIX_FMT_YUV420P;
pCodecCtx->width = nWidth;
pCodecCtx->height = nHeight;
pCodecCtx->thread_count = 1;
pCodecCtx->time_base.num = pVideoStream->avg_frame_rate.num;
pCodecCtx->time_base.den = pVideoStream->avg_frame_rate.den;
pCodecCtx->gop_size = 10;
pCodecCtx->bit_rate = 3000000;//no use
pCodecCtx->qmin = 1;
pCodecCtx->qmax = 5;
pFrame = av_frame_alloc();
pRGBFrame = av_frame_alloc();
pFrame->width = pCodecCtx->width;
pFrame->height = pCodecCtx->height;
pFrame->format = pCodecCtx->pix_fmt;
ret = avcodec_open2(pCodecCtx, pCodec, NULL);
if (ret < 0)
{
char msg[128];
av_strerror(ret, msg, 128);
printf("err: %s\n", msg);
}
printf(" Create and open codec...\n");
ret = avformat_write_header(pFmtCtx, NULL);
if (ret < 0)
{
static char msg[128];
av_strerror(ret, msg, 128);
av_assert0(ret >= 0);
}
size = avpicture_get_size(pCodecCtx->pix_fmt, pCodecCtx->width, pCodecCtx->height);
yuv_buff = (unsigned char*)av_malloc(size);
pSwsCtx= sws_getContext(pCodecCtx->width,pCodecCtx->height,AV_PIX_FMT_BGR24,
pCodecCtx->width,pCodecCtx->height,AV_PIX_FMT_YUV420P,SWS_POINT,NULL,NULL,NULL);
printf(" Begin encode...\n");
pFrame->pts = 0;
for (file_index = 0; file_index < IMAGE_FILE_NUMBER; file_index ++)
{
rgb_buff = (unsigned char*)av_malloc(nDataLen[file_index]);
memcpy(rgb_buff, szTxt[file_index], nDataLen[file_index]);
avpicture_fill((AVPicture*)pRGBFrame, (unsigned char*)rgb_buff, AV_PIX_FMT_RGB24, nWidth, nHeight);
// av_image_fill_arrays
avpicture_fill((AVPicture*)pFrame, (unsigned char*)yuv_buff, AV_PIX_FMT_YUV420P, nWidth, nHeight);
// rotate image
pRGBFrame->data[0] += pRGBFrame->linesize[0] * (nHeight - 1);
pRGBFrame->linesize[0] *= -1;
pRGBFrame->data[1] += pRGBFrame->linesize[1] * (nHeight / 2 - 1);
pRGBFrame->linesize[1] *= -1;
pRGBFrame->data[2] += pRGBFrame->linesize[2] * (nHeight / 2 - 1);
pRGBFrame->linesize[2] *= -1;
//rgb -> yuv
sws_scale(pSwsCtx,pRGBFrame->data,pRGBFrame->linesize,0,pCodecCtx->height,pFrame->data,pFrame->linesize);
av_init_packet(&pPkt);
pPkt.data = NULL; // packet data will be allocated by the encoder
pPkt.size = 0;
pFrame->pts = (int64_t)file_index * ((pVideoStream->time_base.den * pVideoStream->avg_frame_rate.den)
/ (pVideoStream->time_base.num * pVideoStream->avg_frame_rate.num));
/* encode the image */
int out;
ret = avcodec_encode_video2(pVideoStream->codec, &pPkt, pFrame, &out);
if (ret < 0)
{
static char msg[128];
av_strerror(ret, msg, 128);
av_assert0(ret >= 0);
}
else
{
printf(" [%d]encoding ...\n", file_index);
}
pPkt.stream_index = 0;
ret = av_interleaved_write_frame(pFmtCtx, &pPkt);
if (ret < 0)
{
static char msg[128];
av_strerror(ret, msg, 128);
av_assert0(ret >= 0);
}
av_free_packet(&pPkt);
av_free(rgb_buff);
}
av_write_trailer(pFmtCtx);
printf(" Finish encode... \n");
avcodec_close(pCodecCtx);
av_frame_free(&pFrame);
av_frame_free(&pRGBFrame);
avio_closep(&pFmtCtx->pb);
sws_freeContext(pSwsCtx);
avformat_free_context(pFmtCtx);
return;
}This is encoding information of generated MP4 file, including incorrect duration time.
-
open source CMS and server for video streaming platform
30 mai 2016, par InfiniteI have to propose a platform that allows streaming video services employing the MPEEG-DASH standard. This platform blocks must be implemented with open source tools. I proposed FFmpeg to encode and MP4Box/GPAC tool for encryption and packaging. For the DRM case my propose is to use Widewine (I didn’t find any other open source tool) which is compatible with dash.js (the player proposed by me), it can be integrated to Chrome and according to CastLabs it’s also compatible with MP4Box. So, I have to select an open source CMS, and at the same time I need it to be compatible with dash.js. I read that it’s possible to add any JavaScript to these CMS, that it’s only necessary to create some modules to do so. I’d like to know which one of the following CMS you suggest me : MediaDrop, Drupal or Wordpress.
I also have some doubts about the server. I know that in order to offer this service it only takes a traditional HTTP server. In a first moment I chose Nginx over Apache because the latter presents some problems associated to performance (the server will receive a large amount of simultaneous requests), nevertheless, I discarded Nginx (Nginx-rtmp module) due to its constraints : it’s only for live streaming (I need the service to be offered also on demand) and the inputs must be RTMP. I found something about Nginx-based VOD packager, do you know if this one can be used as a server to offer live and on demand streaming service ?