
Recherche avancée
Médias (91)
-
Richard Stallman et le logiciel libre
19 octobre 2011, par
Mis à jour : Mai 2013
Langue : français
Type : Texte
-
Stereo master soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Audio
-
Elephants Dream - Cover of the soundtrack
17 octobre 2011, par
Mis à jour : Octobre 2011
Langue : English
Type : Image
-
#7 Ambience
16 octobre 2011, par
Mis à jour : Juin 2015
Langue : English
Type : Audio
-
#6 Teaser Music
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
-
#5 End Title
16 octobre 2011, par
Mis à jour : Février 2013
Langue : English
Type : Audio
Autres articles (105)
-
Encoding and processing into web-friendly formats
13 avril 2011, parMediaSPIP automatically converts uploaded files to internet-compatible formats.
Video files are encoded in MP4, Ogv and WebM (supported by HTML5) and MP4 (supported by Flash).
Audio files are encoded in MP3 and Ogg (supported by HTML5) and MP3 (supported by Flash).
Where possible, text is analyzed in order to retrieve the data needed for search engine detection, and then exported as a series of image files.
All uploaded files are stored online in their original format, so you can (...) -
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. -
Formulaire personnalisable
21 juin 2013, parCette page présente les champs disponibles dans le formulaire de publication d’un média et il indique les différents champs qu’on peut ajouter. Formulaire de création d’un Media
Dans le cas d’un document de type média, les champs proposés par défaut sont : Texte Activer/Désactiver le forum ( on peut désactiver l’invite au commentaire pour chaque article ) Licence Ajout/suppression d’auteurs Tags
On peut modifier ce formulaire dans la partie :
Administration > Configuration des masques de formulaire. (...)
Sur d’autres sites (6795)
-
FFMPEG-Php installation on Amazon EC2 linux AMI
5 mai 2015, par HamzaI have installed FFMPEG on Amazon EC2 Linux AMI using this script now I am trying to install FFMPEG-PHP and after
./configure
it gives me this error onmake
command# make
/bin/sh /opt/ffmpeg-php-0.6.0/libtool --mode=compile cc -I. -I/opt/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/opt/ffmpeg-php-0.6.0/include -I/opt/ffmpeg-php-0.6.0/main -I/opt/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include/ffmpeg -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /opt/ffmpeg-php-0.6.0/ffmpeg-php.c -o ffmpeg-php.lo
libtool: compile: cc -I. -I/opt/ffmpeg-php-0.6.0 -DPHP_ATOM_INC -I/opt/ffmpeg-php-0.6.0/include -I/opt/ffmpeg-php-0.6.0/main -I/opt/ffmpeg-php-0.6.0 -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/usr/local/include/ffmpeg -DHAVE_CONFIG_H -g -O2 -Wall -fno-strict-aliasing -c /opt/ffmpeg-php-0.6.0/ffmpeg-php.c -fPIC -DPIC -o .libs/ffmpeg-php.o
In file included from /opt/ffmpeg-php-0.6.0/ffmpeg-php.c:42:0:
/usr/local/include/ffmpeg/avcodec.h:43:21: fatal error: version.h: No such file or directory
#include "version.h"I have searched this a lot but couldn’t manage to do it, Amazon support officer asked me to use CENTOS AMI instead of Linux AMI but I have everything hosted there, so I will appreciate if someone can help me with this.
Thank you,
Hamza
-
How do I use the FFmpeg libraries to extract every nth frame from a video and save it as a small image file in C++ ?
1er novembre 2022, par PanchsAfter experimenting with the examples on the FFmpeg documentation, I was finally able to create a short program that extracts every nth frame from a video. However, the output files that it produces are huge at over 15mb for each image. How can I change this to produce lower quality images ?


The result I am trying to get is done easily on the command line with :


ffmpeg -i [input video] -vf "select=not(mod(n\,10))" -fps_mode vfr img_%03d.jpg


For a video with about 500 frames, this creates 50 images that are only about 800kb each ; how am would I be able to mimic this in my program ?


My code consists of opening the input file, decoding the packets, then saving the frames :


#include <cstdio>
#include <cstdlib>
#include <iostream>

extern "C" {
#include <libavcodec></libavcodec>avcodec.h>
#include <libavformat></libavformat>avformat.h>
#include <libavfilter></libavfilter>buffersink.h>
#include <libavfilter></libavfilter>buffersrc.h>
#include <libavutil></libavutil>opt.h>
#include <libswscale></libswscale>swscale.h>
}

static AVFormatContext *fmt_ctx;
static AVCodecContext *dec_ctx;
static int video_stream_index = -1;

// OPEN THE INPUT FILE
static int open_input_file(const char *filename) {
 // INIT VARS AND FFMPEG OBJECTS
 int ret;
 const AVCodec *dec;

 // OPEN INPUT FILE
 if((ret = avformat_open_input(&fmt_ctx, filename, NULL, NULL)) < 0) {
 printf("ERROR: failed to open input file\n");
 return ret;
 }

 // FIND STREAM INFO BASED ON INPUT FILE
 if((ret = avformat_find_stream_info(fmt_ctx, NULL)) < 0) {
 printf("ERROR: failed to find stream information\n");
 return ret;
 }

 // FIND THE BEST VIDEO STREAM FOR THE INPUT FILE
 ret = av_find_best_stream(fmt_ctx, AVMEDIA_TYPE_VIDEO, -1, -1, &dec, 0);
 if(ret < 0) {
 printf("ERROR: failed to find a video stream in the input file\n");
 return ret;
 }
 video_stream_index = ret;

 // ALLOCATE THE DECODING CONTEXT FOR THE INPUT FILE
 dec_ctx = avcodec_alloc_context3(dec);
 if(!dec_ctx) {
 printf("ERROR: failed to allocate decoding context\n");
 // CAN NOT ALLOCATE MEMORY ERROR
 return AVERROR(ENOMEM);
 }
 avcodec_parameters_to_context(dec_ctx, fmt_ctx->streams[video_stream_index]->codecpar);

 // INIT THE VIDEO DECODER
 if((ret = avcodec_open2(dec_ctx, dec, NULL)) < 0) {
 printf("ERROR: failed to open video decoder\n");
 return ret;
 }

 return 0;
}

// SAVE THE FILE
static void save(unsigned char *buf, int wrap, int x_size, int y_size, char *file_name) {
 // INIT THE EMPTY FILE
 FILE *file;

 // OPEN AND WRITE THE IMAGE FILE
 file = fopen(file_name, "wb");
 fprintf(file, "P6\n%d %d\n%d\n", x_size, y_size, 255);
 for(int i = 0; i < y_size; i++) {
 fwrite(buf + i * wrap, 1, x_size * 3, file);
 }
 fclose(file);
}

// DECODE FRAME AND CONVERT IT TO AN RGB IMAGE
static void decode(AVCodecContext *cxt, AVFrame *frame, AVPacket *pkt,
 const char *out_file_name, const char *file_ext, int mod=1) {
 // INIT A BLANK CHAR TO HOLD THE FILE NAME AND AN EMPTY INT TO HOLD FUNCTION RETURN VALUES
 char buf[1024];
 int ret;

 // SEND PACKET TO DECODER
 ret = avcodec_send_packet(cxt, pkt);
 if(ret < 0) {
 printf("ERROR: error sending packet for decoding\n");
 exit(1);
 }

 // CREATE A SCALAR CONTEXT FOR CONVERSION
 SwsContext *sws_ctx = sws_getContext(dec_ctx->width, dec_ctx->height, dec_ctx->pix_fmt, dec_ctx->width,
 dec_ctx->height, AV_PIX_FMT_RGB24, SWS_BICUBIC, NULL, NULL, NULL);

 // CREATE A NEW RGB FRAME FOR CONVERSION
 AVFrame* rgb_frame = av_frame_alloc();
 rgb_frame->format = AV_PIX_FMT_RGB24;
 rgb_frame->width = dec_ctx->width;
 rgb_frame->height = dec_ctx->height;

 // ALLOCATE A NEW BUFFER FOR THE RGB CONVERSION FRAME
 av_frame_get_buffer(rgb_frame, 0);

 // WHILE RETURN COMES BACK OKAY (FUNCTION RETURNS >= 0)...
 while(ret >= 0) {
 // GET FRAME BACK FROM DECODER
 ret = avcodec_receive_frame(cxt, frame);
 // IF "RESOURCE TEMP NOT AVAILABLE" OR "END OF FILE" ERROR...
 if(ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
 return;
 } else if(ret < 0) {
 printf("ERROR: error during decoding\n");
 exit(1);
 }

 // IF FRAME NUMBER IF THE (MOD)TH FRAME...
 if(cxt->frame_number % mod == 0){
 // OUTPUT WHICH FRAME IS BEING SAVED
 printf("saving frame %03d\n", cxt->frame_number);
 // REMOVES TEMPORARY BUFFERED DATA
 fflush(stdout);

 // SCALE (CONVERT) THE OLD FRAME TO THE NEW RGB FRAME
 sws_scale(sws_ctx, frame->data, frame->linesize, 0, frame->height,
 rgb_frame->data, rgb_frame->linesize);

 // SET "BUF" TO THE OUTPUT FILE PATH (SAVES TO "out_file_name_###.file_ext")
 snprintf(buf, sizeof(buf), "%s_%03d.%s", out_file_name, cxt->frame_number, file_ext);
 // SAVE THE FRAME
 save(rgb_frame->data[0], rgb_frame->linesize[0], rgb_frame->width, rgb_frame->height, buf);
 }
 }
}

int main() {
 // SIMULATE COMMAND LINE ARGUMENTS
 char argv0[] = "test";
 char argv1[] = "/User/Desktop/frames/test_video.mov";
 char *argv[] = {argv0, argv1, nullptr};

 // INIT VARS AND FFMPEG OBJECTS
 int ret;
 AVPacket *packet;
 AVFrame *frame;

 // ALLOCATE FRAME AND PACKET
 frame = av_frame_alloc();
 packet = av_packet_alloc();
 if (!frame || !packet) {
 fprintf(stderr, "Could not allocate frame or packet\n");
 exit(1);
 }

 // IF FILE DOESN'T OPEN, GO TO THE END
 if((ret = open_input_file(argv[1])) < 0) {
 goto end;
 }
 
 // READ ALL THE PACKETS - simple
 while(av_read_frame(fmt_ctx, packet) >= 0) {
 // IF PACKET INDEX MATCHES VIDEO INDEX...
 if (packet->stream_index == video_stream_index) {
 // SEND PACKET TO THE DECODER and SAVE
 std::string name = "/User/Desktop/frames/img";
 std::string ext = "bmp";
 decode(dec_ctx, frame, packet, name.c_str(), ext.c_str(), 5);
 }

 // UNREFERENCE THE PACKET
 av_packet_unref(packet);
 }

 // END MARKER
 end:
 avcodec_free_context(&dec_ctx);
 avformat_close_input(&fmt_ctx);
 av_frame_free(&frame);
 av_packet_free(&packet);

 // FINAL ERROR CATCH
 if (ret < 0 && ret != AVERROR_EOF) {
 fprintf(stderr, "Error occurred: %s\n", av_err2str(ret));
 exit(1);
 }

 exit(0);
}
</iostream></cstdlib></cstdio>


I am not sure how to go about producing images that are much smaller in size like the ones produced on the command line. I have a feeling that this is possible somehow during the conversion to RGB or the saving of the file but I can't seem to figure out how.


Also, is there any way that I could go about this much more efficiently ? On the command line, this finishes very quickly (no more than a second or two for a 9 sec. movie at 60 fps).


-
Flutter FFmpeg | Concat Multiple Videos From TXT File And Save As A Video
7 mai 2023, par Muhammad HassanI have a text file with all path of video files that I want to concat using
https://pub.dev/packages/ffmpeg_kit_flutter in my flutter app.


For this purpose, I write a file
my_file.txt
with the below data...

/data/user/0/com.example.video_merger/cache/75f72300-1203-4e2c-93cf-65777152f1d16524788775537818173.mp4
/data/user/0/com.example.video_merger/cache/318d5ea7-3e0c-4453-903b-06966aa86f348487775694692938421.mp4



Now I am using the below code to merge all the upper videos.


String outputPath = "/data/user/0/com.example.video_merger/app_flutter/output.mp4";
String commandToExecute = '-f concat -i $rawDocumentPath/my_file.txt -c copy $outputPath';
FFmpegKit.execute(commandToExecute).then((session) async {
 final returnCode = await session.getReturnCode();
 print("FFmpeg Process Exited With ReturnCode = $returnCode");
 GallerySaver.saveVideo(outputPath).then((_) {
 print("Merged Video Saved");
 });
 if (ReturnCode.isSuccess(returnCode)) {
 // SUCCESS
 } else if (ReturnCode.isCancel(returnCode)) {
 // CANCEL
 } else {
 // ERROR
 }
});



But it is giving me error as shown below...


FFmpeg Process Exited With ReturnCode = 1 
E/GallerySaver(31493): /data/user/0/com.example.video_merger/app_flutter/output.mp4: open failed: ENOENT (No such file or directory)



But when I use the below
ffmpeg
command directly without reading from text file works fine and save my video.

String commandToExecute = '-y -i ${_storedVideoOne!.path} -i ${_storedVideoTwo!.path} -r 24000/1001 -filter_complex \'[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[out]\' -map \'[out]\' $outputPath';



Now my question is that I will have dynamic number of videos to concat so I want to use text file where I will write all paths then will make merged video from them. So what is the error in my
ffmpeg
command...???

Log Report :


I used the log reporting as follows to get the below output of errors...


FFmpegKit.executeAsync(
 commandToExecute2,
 (session) async {
 final returnCode = await session.getReturnCode();
 print("FFmpeg Process Exited With ReturnCode = $returnCode");
 GallerySaver.saveVideo(outputPath).then((_) async {
 print("Merged Video Saved");
 });
 if (ReturnCode.isSuccess(returnCode)) {
 // SUCCESS
 } else if (ReturnCode.isCancel(returnCode)) {
 // CANCEL
 } else {
 // ERROR
 }
 },
 (log) {
 print("XXXXXXXXXXXX fFmpeg XXXXXXXXXX ${log.getMessage()}");
 },
 );



And here is the Log Output...


I/flutter ( 5432): Text On File: /data/user/0/com.example.video_merger/cache/75f72300-1203-4e2c-93cf-65777152f1d16524788775537818173.mp4
I/flutter ( 5432): /data/user/0/com.example.video_merger/cache/318d5ea7-3e0c-4453-903b-06966aa86f348487775694692938421.mp4
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX ffmpeg version n5.1.2
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX Copyright (c) 2000-2022 the FFmpeg developers
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX built with Android (7155654, based on r399163b1) clang version 11.0.5 (https://android.googlesource.com/toolchain/llvm-project 87f1315dfbea7c137aa2e6d362dbb457e388158d)
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX configuration: --cross-prefix=aarch64-linux-android- --sysroot=/files/android-sdk/ndk/22.1.7171670/toolchains/llvm/prebuilt/linux-x86_64/sysroot --prefix=/home/taner/Projects/ffmpeg-kit/prebuilt/android-arm64/ffmpeg --pkg-config=/usr/bin/pkg-config --enable-version3 --arch=aarch64 --cpu=armv8-a --target-os=android --enable-neon --enable-asm --enable-inline-asm --ar=aarch64-linux-android-ar --cc=aarch64-linux-android24-clang --cxx=aarch64-linux-android24-clang++ --ranlib=aarch64-linux-android-ranlib --strip=aarch64-linux-android-strip --nm=aarch64-linux-android-nm --extra-libs='-L/home/taner/Projects/ffmpeg-kit/prebuilt/android-arm64/cpu-features/lib -lndk_compat' --disable-autodetect --enable-cross-compile --enable-pic --enable-jni --enable-optimizations --enable-swscale --disable-static --enable-shared --enable-pthreads --enable-v4l2-m2m --disable-outdev=fbdev --disable-indev=fbdev --enable-small --disable-xmm-clobber-test --disable-debug --enable-lto --disable-neon-clobber-t
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX libavutil 57. 28.100 / 57. 28.100
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX libavcodec 59. 37.100 / 59. 37.100
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX libavformat 59. 27.100 / 59. 27.100
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX libavdevice 59. 7.100 / 59. 7.100
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX libavfilter 8. 44.100 / 8. 44.100
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX libswscale 6. 7.100 / 6. 7.100
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX libswresample 4. 7.100 / 4. 7.100
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX [concat @ 0xb400007d62447910] Line 1: unknown keyword '/data/user/0/com.example.video_merger/cache/75f72300-1203-4e2c-93cf-65777152f1d16524788775537818173.mp4'
I/flutter ( 5432): XXXXXXXXXXXX fFmpeg XXXXXXXXXX /data/user/0/com.example.video_merger/app_flutter/my_file.txt: Invalid data found when processing input
I/flutter ( 5432): FFmpeg Process Exited With ReturnCode = 1