
Recherche avancée
Autres articles (89)
-
MediaSPIP v0.2
21 juin 2013, parMediaSPIP 0.2 est la première version de MediaSPIP stable.
Sa date de sortie officielle est le 21 juin 2013 et est annoncée ici.
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Comme pour la version précédente, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
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 (...) -
Soumettre améliorations et plugins supplémentaires
10 avril 2011Si vous avez développé une nouvelle extension permettant d’ajouter une ou plusieurs fonctionnalités utiles à MediaSPIP, faites le nous savoir et son intégration dans la distribution officielle sera envisagée.
Vous pouvez utiliser la liste de discussion de développement afin de le faire savoir ou demander de l’aide quant à la réalisation de ce plugin. MediaSPIP étant basé sur SPIP, il est également possible d’utiliser le liste de discussion SPIP-zone de SPIP pour (...)
Sur d’autres sites (8231)
-
OpenCV cannot read some mp4 files, converting to avi doesn't help either
13 février 2017, par MirandaI’m trying to read some video files that have mp4 format using OpenCV python. I didn’t have any problem with any other mp4 video that I have used so far, but for some reason, videocapture cannot read these mp4 video files. My problem is not like this (I already applied this renaming of mmpeg when I first installed opencv). Besides, as I mentioned earlier videocapture can read other mp4 videos, but not these ones. I also tried to convert the video into avi, but still videocapture cannot read the video (I use other avi files with no problem). The videos that I’m using come from this dataset.
-
Accessing web content with ffmpeg on android
9 janvier 2017, par Pure_eyesI’m using ffmpeg inside my xamarin.android project,by accessing a statically build version for the corresponding architecture of the device.
I’m using https://www.johnvansickle.com/ffmpeg/, static builds which support https protocol.
I’m calling ffmpeg by starting a new process and passing the arguments.Here is a pseudo code for the operation :arguments = {'-i',inputFileName,...}
run('./ffmpeg',arguments,redirectOutput = true,...)
.OnOutput(s) => log(s)Now,I want to access a file in the web, directly with ffmpeg, since from my testing it is more efficient in term of bandwidth, and speed.
The problem i’m facing is that because i’m using a static build of ffmpeg, we need to statically link gclib, which results loss of dns resolution as stated in the readme :
A limitation of statically linking glibc is the loss of DNS resolution. Installing
nscd through your package manager will fix this or you can use
"ffmpeg -i http://<ip address="address" here="here">/"</ip>
instead of"ffmpeg -i http://example.com/"
But the content that i’m trying to get provides strictly only through HTTPS,so there is no way to access it via the ip.
But on Linux systems i had no problem accessing the content(With the same command as for android), thanks to nscd, which isn’t present in android.- Is there anyway to use android’s dns resolution ?
- Or compile ffmpeg
differently, as stated in this
question ?Maybe using android
NDK would default this ?Would ffmpeg even work then ? - Or somehow pipe the content, to
ffmpeg’s stdin, and tell it to input from pipe (Would it still be
more efficient, than downloading and saving the file, then running
ffmpeg ) ?
All suggestions are welcomed !
EDIT
As for SushiHangover advice, i was able to implement it via piping,i came up with two ways :
Process ffmpegProcess = new Process();
ffmpegProcess.StartInfo.FileName = "ffmpeg";
ffmpegProcess.StartInfo.Arguments = ....
ffmpegProcess.StartInfo.UseShellExecute = false;
ffmpegProcess.StartInfo.RedirectStandardInput = true;
ffmpegProcess.Start();
//Way 1
var data = await GetBytesAsync();
await ffmpegProcess.StandardInput.BaseStream.WriteAsync(b, 0,b.Length);
// Way 2
await (await GetStreamAsync()).CopyToAsync(ffmpegProcess.StandardInput.BaseStream);Which both work, but they aren’t efficient in term of bandwidth as ffmpeg itself, i tested the network traffic with NetBalancer.
Way 1 (Fresh Data - First time running program) : 401 KB Upload/ 19.7 MB Download
Way 1 (Second time running program) : 334.3 KB Upload/ 17.7 MB Download
Way 2 (Second time running program) : 370 KB Upload/ 16.6 MB Download
Through FFmpeg Only (Fresh Data - First time running program) : 142.4 KB Upload / 5.3 MB Download
Through FFmpeg Only (Second time running program) : 67.5 KB Upload / 3.7 MB DownloadWho can i overcome the gap ? I speculate that ffmpeg only reads the headers, and able to download only the needed audio stream based on my arguments, rather than the whole video as my snippets do.
-
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.