
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 (35)
-
Supporting all media types
13 avril 2011, parUnlike most software and media-sharing platforms, MediaSPIP aims to manage as many different media types as possible. The following are just a few examples from an ever-expanding list of supported formats : images : png, gif, jpg, bmp and more audio : MP3, Ogg, Wav and more video : AVI, MP4, OGV, mpg, mov, wmv and more text, code and other data : OpenOffice, Microsoft Office (Word, PowerPoint, Excel), web (html, CSS), LaTeX, Google Earth and (...)
-
Ajouter notes et légendes aux images
7 février 2011, parPour pouvoir ajouter notes et légendes aux images, la première étape est d’installer le plugin "Légendes".
Une fois le plugin activé, vous pouvez le configurer dans l’espace de configuration afin de modifier les droits de création / modification et de suppression des notes. Par défaut seuls les administrateurs du site peuvent ajouter des notes aux images.
Modification lors de l’ajout d’un média
Lors de l’ajout d’un média de type "image" un nouveau bouton apparait au dessus de la prévisualisation (...) -
HTML5 audio and video support
13 avril 2011, parMediaSPIP uses HTML5 video and audio tags to play multimedia files, taking advantage of the latest W3C innovations supported by modern browsers.
The MediaSPIP player used has been created specifically for MediaSPIP and can be easily adapted to fit in with a specific theme.
For older browsers the Flowplayer flash fallback is used.
MediaSPIP allows for media playback on major mobile platforms with the above (...)
Sur d’autres sites (6253)
-
avcodec/vvcdec : misc, remove unused ALFParams.applied
17 juin 2024, par Nuo Mi -
When using ffmpeg api, the encoded gif is output to the dynamically applied buffer
5 septembre 2023, par yangjinhui2936Purpose:I want to use ffmpeg to encode data from rbg8 to gif format.Currently can be encoded into file output.


But I don't know how to store the gif directly in the buffer instead of saving it in the file.


Below is the text of the code:
input_w560_h1280.rgb8


#include 
#include 
#include 
#include 
#include <libavcodec></libavcodec>avcodec.h>
#include <libavutil></libavutil>imgutils.h>
#include <libavformat></libavformat>avformat.h>
#include <libswscale></libswscale>swscale.h>
#include <libavdevice></libavdevice>avdevice.h>

#define CONFIG_FBDEV_OUTDEV 1
#define GET_DATA_TO_BUFF 0

int readFileToBuffer(uint8_t *dst, const char* filename, long* fileSize) {
 FILE* file = fopen(filename, "rb");
 if (!file || dst == NULL) {
 fprintf(stderr, "cannot open file: %s %p\n", filename, dst);
 return -1;
 }

 fseek(file, 0, SEEK_END);
 *fileSize = ftell(file);
 fseek(file, 0, SEEK_SET);

 uint8_t *buffer = NULL;
 buffer = dst;
 if (!buffer) {
 fprintf(stderr, "buffer error\n");
 fclose(file);
 return -1;
 }

 // fread file to buffer
 if (fread(buffer, 1, *fileSize, file) != *fileSize) {
 fprintf(stderr, "read file failed size %ld\n", *fileSize);
 fclose(file);
 free(buffer);
 return -1;
 }

 fclose(file);
 return 0;
}

int writeBufferToFile(const char* filename, uint8_t* buffer, long bufferSize) {
 FILE* file = fopen(filename, "wb");
 if (!file) {
 fprintf(stderr, "cannot open: %s\n", filename);
 return -1;
 }

 if (fwrite(buffer, 1, bufferSize, file) != bufferSize) {
 fprintf(stderr, "cannot fwrite\n");
 fclose(file);
 return -1;
 }

 fclose(file);
 return 0;
}

int main() {
 const char *output_filename = "output.gif";
 const char *input_filename = "input_w560_h1280.rgb8";
 int width = 560;
 int height = 1280;

 avcodec_register_all();
 avdevice_register_all();
 av_register_all();

 av_log_set_level(AV_LOG_MAX_OFFSET);

 AVCodec *codec = avcodec_find_encoder(AV_CODEC_ID_GIF);
 if (!codec) {
 printf("GIF encoder not found.\n");
 return 1;
 }
 
 AVCodecContext *codecContext = avcodec_alloc_context3(codec);
 if (!codecContext) {
 printf("Could not allocate codec codecContext.\n");
 return 1;
 }

 codecContext->width = width;
 codecContext->height = height;
 codecContext->pix_fmt = AV_PIX_FMT_RGB8;
 codecContext->time_base = (AVRational){1, 25};
 
 if (avcodec_open2(codecContext, codec, NULL) < 0) {
 printf("Could not open codec.\n");
 return 1;
 }

 AVFormatContext *outputFormatContext = NULL;
 if (avformat_alloc_output_context2(&outputFormatContext, NULL, NULL, output_filename) < 0) {
 printf("Could not allocate output format codecContext.\n");
 return 1;
 }

 AVStream *stream = avformat_new_stream(outputFormatContext, NULL);
 if (!stream) {
 printf("Could not create stream.\n");
 return 1;
 }

 AVCodecParameters *codec_params = stream->codecpar;
 avcodec_parameters_from_context(codec_params, codecContext);

 if (avio_open(&outputFormatContext->pb, output_filename, AVIO_FLAG_WRITE) < 0) {
 printf("Could not open output file.\n");
 return 1;
 }

 /* write header for output */
 if(avformat_write_header(outputFormatContext, NULL) < 0)
 {
 printf("avformat_write_header failed\n");
 }

 // creat and init frame
 AVFrame *frame = av_frame_alloc();
 frame->format = AV_PIX_FMT_RGB8;
 frame->width = width;
 frame->height = height;
 /* check frame buff */
 if (av_frame_get_buffer(frame, 0) < 0) {
 printf("Failed to allocate frame buffer.\n");
 return -1;
 }

 /* read rgb data to frame->data[0] */
 uint8_t *rgb8data = (uint8_t *)av_malloc(width * height * 3);
 long read_size = 0;
 int ret = readFileToBuffer(rgb8data, input_filename, &read_size);
 if (ret != 0 || read_size == 0)
 {
 printf("error argbData %p read_size %ld\n", rgb8data, read_size);
 }
 /* cp input data to frame */
 av_image_copy_plane(frame->data[0], frame->linesize[0], rgb8data, width, width, height);

 // Init IOcontext (try to get the gif stream)
 #if GET_DATA_TO_BUFF
 AVIOContext *outputIoContext = NULL;

 if (avio_open_dyn_buf(&outputIoContext) < 0) {
 printf("Failed to open output buffer.\n");
 return -1;
 }
 #endif
 // Encoding loop (simulated frames)
 AVPacket pkt;
 av_init_packet(&pkt);
 pkt.data = NULL;
 pkt.size = 0;
 avcodec_send_frame(codecContext, frame);

 while (avcodec_receive_packet(codecContext, &pkt) == 0) {
 pkt.stream_index = stream->index;
 #if GET_DATA_TO_BUFF // try to get the gif stream
 avio_write(outputIoContext, pkt.data, pkt.size);
 #endif
 av_write_frame(outputFormatContext, &pkt);
 av_packet_unref(&pkt);
 }
 /* write end */
 av_write_trailer(outputFormatContext);
 // try to get the gif stream
 #if GET_DATA_TO_BUFF
 uint8_t *outputBuffer;
 int outputBufferSize = avio_close_dyn_buf(outputIoContext, &outputBuffer);
 writeBufferToFile("bf_1.gif", outputBuffer, outputBufferSize);
 #endif
 /* free */
 avformat_close_input(&outputFormatContext);
 av_frame_free(&frame);
 avcodec_free_context(&codecContext);
 av_free(rgb8data);

 return 0;
}



MAKEFILE


CC = gcc
CFLAGS = -Wall -g
CFLAGS += -I ../output/include
CFLAGS += -L ../output/lib
LIBS = -l:libavdevice.a -l:libavformat.a -l:libavcodec.a -lavfilter -lswresample -lswscale -l:libavutil.a -lpthread -lz -lbz2 -lm -ldl

all: encode_to_gif

encode_to_gif: encode_to_gif.c
 $(CC) $(CFLAGS) -o $@ $< $(LIBS)



Tried The content in the macro definition is the relevant solution I found online. Unfortunately, the data I got is in original rgb8 format, not in gif format.ffmpeg writes data to file and Data dumped from buffer
The data dumped from the buffer seems to have no gif header


My expected result I want to output the encoded gif directly to the buffer,but i don't know what to do.




-
I want to create a video from images with transition applied
29 mars 2023, par Kaleem AbbasI want to load images and create video with transition applied. I was able to create video but transitions are not being applied.


ffmpeg -framerate 1/5 -start_number 1 -i "D :\video\photo\images%%d.jpg" -filter_complex "[0:v]split=5[0a][0b][0c][0d][0e] ;[0a]format=yuva420p,hflip[flip0] ;[0b]format=yuva420p[bg] ;[0c]format=yuva420p[bg1] ;[0d]format=yuva420p[bg2] ;[0e]format=yuva420p,hflip[flip1] ;[bg][flip0]overlay=x='min(-w*(t-1.5),0)':shortest=1[bg0] ;[bg0][bg1]overlay=x='min(-w*(t-0.5),0)':shortest=1,drawbox=t=fade:enable='between(t,0,1)':color=white[bg01] ;[bg01][flip1]overlay=x='min(-w*(t),0)':shortest=1,drawbox=t=fade:enable='between(t,0,1)':color=white[bg1] ;[bg1][bg2]overlay=x='min(-w*(t+0.5),0)':shortest=1,drawbox=t=fade:enable='between(t,0,1)':color=white[bg12] ;[bg12][1:v]overlay=shortest=1:x='if(gte(t,1),0,-w+(tw))':y=0,drawbox=t=fade:enable='between(t,0,1)':color=white[video]" -map "[video]" -c:v libx264 -crf 18 -preset veryfast -t 5 -vf "fade=t=out:st=4:d=1:alpha=1, wipe=w=0.5:h=0:y='H/2':x='if(gte(t,1),0,W-wt/2)':d=1" output.mp4