
Recherche avancée
Médias (91)
-
Corona Radiata
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Lights in the Sky
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Head Down
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Echoplex
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Discipline
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Letting You
26 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (68)
-
Contribute to a better visual interface
13 avril 2011MediaSPIP is based on a system of themes and templates. Templates define the placement of information on the page, and can be adapted to a wide range of uses. Themes define the overall graphic appearance of the site.
Anyone can submit a new graphic theme or template and make it available to the MediaSPIP community. -
Récupération d’informations sur le site maître à l’installation d’une instance
26 novembre 2010, parUtilité
Sur le site principal, une instance de mutualisation est définie par plusieurs choses : Les données dans la table spip_mutus ; Son logo ; Son auteur principal (id_admin dans la table spip_mutus correspondant à un id_auteur de la table spip_auteurs)qui sera le seul à pouvoir créer définitivement l’instance de mutualisation ;
Il peut donc être tout à fait judicieux de vouloir récupérer certaines de ces informations afin de compléter l’installation d’une instance pour, par exemple : récupérer le (...) -
Les tâches Cron régulières de la ferme
1er décembre 2010, parLa gestion de la ferme passe par l’exécution à intervalle régulier de plusieurs tâches répétitives dites Cron.
Le super Cron (gestion_mutu_super_cron)
Cette tâche, planifiée chaque minute, a pour simple effet d’appeler le Cron de l’ensemble des instances de la mutualisation régulièrement. Couplée avec un Cron système sur le site central de la mutualisation, cela permet de simplement générer des visites régulières sur les différents sites et éviter que les tâches des sites peu visités soient trop (...)
Sur d’autres sites (8789)
-
mp4 video file generated using ffmpeg, play on desktop but doesn't play on device
9 mai 2014, par NikeshI am generating a video that converts images into .mp4 video file. Every thing works fine. File is also generated as mp4 but the file doesn’t run on android device, says cannot play video.
Please find the attached sample code which convert single jpeg file into video (.mp4)
Please help me to resolve this issue. Thanks.
JNIEXPORT void JNICALL Java_roman10_ffmpegtst_VideoBrowser_videoExample(JNIEnv *pEnv, jobject pObj, char* imagefile,char* videoFile)
{
avcodec_init();
av_register_all();
avcodec_register_all();
AVCodecContext *pOCtx= NULL;
AVCodec *pOCodex = NULL;
LOGE(10,"Start videoExample");
pOCodex = avcodec_find_encoder(AV_CODEC_ID_MPEG1VIDEO);
if (!pOCodex) {
LOGE(10,"Cannot find encoder %s", pOCodex);
exit(1);
}
pOCtx= avcodec_alloc_context3(pOCodex);
uint8_t *outbuf;
int i, out_size;
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 = AV_PIX_FMT_YUV420P;
LOGE(10,"Start avcodec_open2");
int ret = avcodec_open2(pOCtx,pOCodex,NULL);
if(ret < 0)
{
return;
}
LOGE(10,"End avcodec_open2");
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, 0);
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(AV_PIX_FMT_YUVJ420P, pICodecCtx->width, pICodecCtx->height);
uint8_t *buffer = (uint8_t *) av_malloc(bufSize * sizeof(uint8_t));
avpicture_fill((AVPicture *) pIFrame, buffer, AV_PIX_FMT_YUVJ420P, pICodecCtx->width, pICodecCtx->height);
FILE *outputFile;
outputFile = fopen(videoFile, "w+");
if (!outputFile) {
LOGE(10,"could not open ");
exit(1);
}
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);
} -
FFMPEG HLS stream for Android and IOS
26 février 2015, par PodaI’m trying to stream to mobile devices with ffmpeg and apache2.2 but I haven’t been successful.
I used this command to create the segments and the playlist :
ffmpeg -i http://x.x.x.x:8080 -codec:v libx264 -r 25 -pix_fmt yuv420p -profile:v baseline -level 3 -b:v 500k -s 640x480 -codec:a aac -strict experimental -ac 2 -b:a 128k -movflags faststart -flags -global_header -map 0 -f hls -hls_time 10 -hls_list_size 5 -hls_allow_cache 0 -sc_threshold 0 -hls_flags delete_segments -hls_segment_filename out%05d.ts list.m3u8
The source is a http stream which is streamed by VLC media player.
Example content of the list.m3u8 file :
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-ALLOW-CACHE:NO
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:89
#EXTINF:10.000000,
out00089.ts
#EXTINF:10.000000,
out00090.ts
#EXTINF:10.000000,
out00091.ts
#EXTINF:10.000000,
out00092.ts
#EXTINF:9.000000,
out00093.ts
#EXT-X-ENDLISTI created another playlist file - playlist.m3u8 :
#EXTM3U
#EXT-X-STREAM-INF:PROGRAM-ID=1,BANDWIDTH=512000
http://x.x.x.x/list.m3u8If I open this (playlist.m3u8) file in VLC media player then it plays.
It also works in desktop chrome and desktop firefox browsers with Video-js plugin flash fallback.I set the correct MIME types to the .ts and .m3u8 files in .htaccess file :
AddType application/x-mpegURL .m3u8
AddType video/MP2T .tsFFprobe output for playlist.m3u8 :
Input #0, hls,applehttp, from 'playlist.m3u8':
Duration: N/A, start: 1.400000, bitrate: N/A
Program 0
Metadata: variant_bitrate : 512000
Stream #0:0: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 640x480 [SAR 1:1 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
Metadata: variant_bitrate : 512000
Stream #0:1: Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, stereo, fltp, 128 kb/s
Metadata: variant_bitrate : 512000What should I do to make it work ?
UPDATE
It works if I provide a link to list.m3u8 file (created by ffmpeg).
-
avcodec_open segmentation fault
24 juin 2014, par user3715403Good afternoon,
I got a copy of the ffmpeg’s api-example.c (https://www.ffmpeg.org/doxygen/0.6/api-example_8c-source.html). I tested the function video_encode_example() and got the code working as expected.
I then re-factored this function into different class methods and now I get a seg fault with the call to avcodev_open(). I then changed the code to call the original video_encode_example() from a class method and the calls to avcodec... were successful.
It appears that when called from a function (eg video_encode_example()), the behaviour is as expected, but avcodev_open fails when called from a class method. I traced the code and in both cases the values for the avcodev_open() arguments are assigned (and similar) pointer values. cgdb reports that the seg fault occurs in avcodev_open2()
Any suggestions ?
The code was compiled and tested on a Ubuntu 12.04 64 bit machine) using the libav package available thru apt-get (libavcodec.so.53.35.0)Regards,
DanielAdded comment following the first response :
From the link above, I copied the function video_encode_example() and placed the call inside a class constructor. This part is working.
VideoEncoder::VideoEncoder( const std::string& aFileName)
: mCodec( NULL)
, mCodecContext( NULL)
, picture (NULL)
, mFileName( aFileName)
, mFileHandler( NULL)
{
// must be called before using avcodec lib
::avcodec_init();
// register all the codecs
::avcodec_register_all();
video_encode_example( aFileName.c_str());
return;
...
}The re-factored part includes splitting the avcodev call (from the original video_encode_example() function) to different VideoEncoder methods. The constructor now looks like :
VideoEncoder::VideoEncoder( const std::string& aFileName)
: mCodec( NULL)
, mCodecContext( NULL)
, picture (NULL)
, mFileName( aFileName)
, mFileHandler( NULL)
{
// must be called before using avcodec lib
::avcodec_init();
// register all the codecs
::avcodec_register_all();
// find the mpeg1 video encoder
mCodec = ::avcodec_find_encoder( CODEC_ID_MPEG1VIDEO);
if (!mCodec) {
fprintf( stderr, "codec not found\n");
exit( 1);
}
mCodecContext = ::avcodec_alloc_context3( mCodec);
picture = ::avcodec_alloc_frame();
// put sample parameters
mCodecContext->bit_rate = 400000;
// frames per second
mCodecContext->time_base = (AVRational){1,25};
mCodecContext->gop_size = 10; // emit one intra frame every ten frames
mCodecContext->max_b_frames = 1;
mCodecContext->pix_fmt = PIX_FMT_YUV420P;
// open it
// Initializes the AVCodecContext to use the given AVCodec. Prior to using this function the context has to be allocated.
if (::avcodec_open( mCodecContext, mCodec) < 0) {
fprintf(stderr, "could not open codec\n");
exit( 1);
}
mFileHandler = fopen( mFileName.c_str(), "wb");
if (!mFileHandler) {
fprintf( stderr, "could not open %s\n", mFileName.c_str());
exit( 1);
}
}The call to avcodec_open causes the seg fault. In addition, the fault occurs whether using avcodev_.. or ::avcodev_...