
Recherche avancée
Autres articles (34)
-
Des sites réalisés avec MediaSPIP
2 mai 2011, parCette page présente quelques-uns des sites fonctionnant sous MediaSPIP.
Vous pouvez bien entendu ajouter le votre grâce au formulaire en bas de page. -
List of compatible distributions
26 avril 2011, parThe table below is the list of Linux distributions compatible with the automated installation script of MediaSPIP. Distribution nameVersion nameVersion number Debian Squeeze 6.x.x Debian Weezy 7.x.x Debian Jessie 8.x.x Ubuntu The Precise Pangolin 12.04 LTS Ubuntu The Trusty Tahr 14.04
If you want to help us improve this list, you can provide us access to a machine whose distribution is not mentioned above or send the necessary fixes to add (...) -
Submit enhancements and plugins
13 avril 2011If you have developed a new extension to add one or more useful features to MediaSPIP, let us know and its integration into the core MedisSPIP functionality will be considered.
You can use the development discussion list to request for help with creating a plugin. As MediaSPIP is based on SPIP - or you can use the SPIP discussion list SPIP-Zone.
Sur d’autres sites (5780)
-
Reading mp3 file using ffmpeg caues memory leaks, even after freeing it in main
12 août 2020, par leonardltk1i am continuously reading mp3 files and processing them, but the memory keeps getting build up even though i freed it.


At the bottom
read_audio_mp3()
, they are already freeing some variable.
why do i still face a memory build up and how do i deal with it ?

following this code : https://rodic.fr/blog/libavcodec-tutorial-decode-audio-file/, i read mp3 using this function


int read_audio_mp3(string filePath_str, const int sample_rate, 
 double** output_buffer, int &AUDIO_DURATION){
 const char* path = filePath_str.c_str();

 /* Reads the file header and stores information about the file format. */
 AVFormatContext* format = avformat_alloc_context();
 if (avformat_open_input(&format, path, NULL, NULL) != 0) {
 fprintf(stderr, "Could not open file '%s'\n", path);
 return -1;
 }

 /* Check out the stream information in the file. */
 if (avformat_find_stream_info(format, NULL) < 0) {
 fprintf(stderr, "Could not retrieve stream info from file '%s'\n", path);
 return -1;
 }

 /* find an audio stream. */
 int stream_index =- 1;
 for (unsigned i=0; inb_streams; i++) {
 if (format->streams[i]->codec->codec_type == AVMEDIA_TYPE_AUDIO) {
 stream_index = i;
 break;
 }
 }
 if (stream_index == -1) {
 fprintf(stderr, "Could not retrieve audio stream from file '%s'\n", path);
 return -1;
 }
 AVStream* stream = format->streams[stream_index];

 // find & open codec
 AVCodecContext* codec = stream->codec;
 if (avcodec_open2(codec, avcodec_find_decoder(codec->codec_id), NULL) < 0) {
 fprintf(stderr, "Failed to open decoder for stream #%u in file '%s'\n", stream_index, path);
 return -1;
 }

 // prepare resampler
 struct SwrContext* swr = swr_alloc();
 av_opt_set_int(swr, "in_channel_count", codec->channels, 0);
 av_opt_set_int(swr, "out_channel_count", 1, 0);
 av_opt_set_int(swr, "in_channel_layout", codec->channel_layout, 0);
 av_opt_set_int(swr, "out_channel_layout", AV_CH_LAYOUT_MONO, 0);
 av_opt_set_int(swr, "in_sample_rate", codec->sample_rate, 0);
 av_opt_set_int(swr, "out_sample_rate", sample_rate, 0);
 av_opt_set_sample_fmt(swr, "in_sample_fmt", codec->sample_fmt, 0);
 av_opt_set_sample_fmt(swr, "out_sample_fmt", AV_SAMPLE_FMT_DBL, 0);
 swr_init(swr);
 if (!swr_is_initialized(swr)) {
 fprintf(stderr, "Resampler has not been properly initialized\n");
 return -1;
 }

 /* Allocate an audio frame. */
 AVPacket packet;
 av_init_packet(&packet);
 AVFrame* frame = av_frame_alloc();
 if (!frame) {
 fprintf(stderr, "Error allocating the frame\n");
 return -1;
 }

 // iterate through frames
 *output_buffer = NULL;
 AUDIO_DURATION = 0;
 while (av_read_frame(format, &packet) >= 0) {
 // decode one frame
 int gotFrame;
 if (avcodec_decode_audio4(codec, frame, &gotFrame, &packet) < 0) {
 // free packet
 av_free_packet(&packet);
 break;
 }
 if (!gotFrame) {
 // free packet
 av_free_packet(&packet);
 continue;
 }
 // resample frames
 double* buffer;
 av_samples_alloc((uint8_t**) &buffer, NULL, 1, frame->nb_samples, AV_SAMPLE_FMT_DBL, 0);
 int frame_count = swr_convert(swr, (uint8_t**) &buffer, frame->nb_samples, (const uint8_t**) frame->data, frame->nb_samples);
 // append resampled frames to output_buffer
 *output_buffer = (double*) realloc(*output_buffer,
 (AUDIO_DURATION + frame->nb_samples) * sizeof(double));
 memcpy(*output_buffer + AUDIO_DURATION, buffer, frame_count * sizeof(double));
 AUDIO_DURATION += frame_count;
 // free buffer & packet
 av_free_packet(&packet);
 av_free( buffer );
 }

 // clean up
 av_frame_free(&frame);
 swr_free(&swr);
 avcodec_close(codec);
 avformat_free_context(format);

 return 0;
 }



Main Script :
MemoryLeak.cpp


// imports
 #include <fstream>
 #include 
 #include 
 #include 
 #include 
 #include <iostream>
 #include <sstream>
 #include <vector>
 #include <sys></sys>time.h> 
 extern "C"
 {
 #include <libavutil></libavutil>opt.h>
 #include <libavcodec></libavcodec>avcodec.h>
 #include <libavformat></libavformat>avformat.h>
 #include <libswresample></libswresample>swresample.h>
 }
 using namespace std;

 int main (int argc, char ** argv) {
 string wavpath = argv[1];
 printf("wavpath=%s\n", wavpath.c_str());

 printf("\n==== Params =====\n");
 // Init
 int AUDIO_DURATION;
 int sample_rate = 8000;
 av_register_all();

 printf("\n==== Reading MP3 =====\n");
 while (true) {
 // Read mp3
 double* buffer;
 if (read_audio_mp3(wavpath, sample_rate, &buffer, AUDIO_DURATION) != 0) {
 printf("Cannot read %s\n", wavpath.c_str());
 continue;
 }

 /* 
 Process the buffer for down stream tasks.
 */

 // Freeing the buffer
 free(buffer);
 }

 return 0 ;
 }
</vector></sstream></iostream></fstream>


Compiling


g++ -o ./MemoryLeak.out -Ofast -Wall -Wextra \
 -std=c++11 "./MemoryLeak.cpp" \
 -lavformat -lavcodec -lavutil -lswresample



Running, by right my input an argument
wav.scp
that reads text file of all the mp3s.
But for easy to replicate purpose, i only read 1 filesong.mp3
in and i keep re-reading it

./MemoryLeak.out song.mp3



Why do i know i have memory leaks ?


- 

- I was running up 32 jobs in parallel for 14 million files, and when i wake up in the morning, they were abruptly killed.
- I run
htop
and i monitor the progress when i re-run it, and i saw that theVIRT
&RES
&Mem
are continuously increasing.








Edit 1 :
My setup :




ffmpeg version 2.8.15-0ubuntu0.16.04.1
built with gcc 5.4.0



-
Can I Config FFMEG-2.4.3 to use in android windows 64 ?
13 novembre 2014, par Ngo KyI want to build ffmpeg-2.4.3 (lastest c lib) to use it on android for managing video.
my OS is windows 7 Utimate x64
cywin64 in directory : C :/cywin64/ have make installed.
NDK in directory : D :\solfware\Programming\android-ndk-r10ci follow toturial form : http://www.roman10.net/how-to-build-ffmpeg-for-android/comment-page-1/
my project struture like :i create build_android.sh like roman10 as following code :
# ARMv7+Neon (Cortex-A8)
# Customizing:
# 1. Feel free to change ./configure parameters for more features
# 2. To adapt other ARM variants
# set $CPU and $OPTIMIZE_CFLAGS
# call build_one
######################################################
NDK=D:\solfware\Programming\android-ndk-r10c
PLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/prebuilt/windows-x86_64
function build_one
{
./configure --target-os=linux \
--prefix=$PREFIX \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
--disable-shared \
--enable-static \
--extra-ldflags="-Wl,-rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -nostdlib -lc -lm -ldl -llog" \
--disable-everything \
--enable-demuxer=mov \
--enable-demuxer=h264 \
--disable-ffplay \
--enable-protocol=file \
--enable-avformat \
--enable-avcodec \
--enable-decoder=rawvideo \
--enable-decoder=mjpeg \
--enable-decoder=h263 \
--enable-decoder=mpeg4 \
--enable-decoder=h264 \
--enable-parser=h264 \
--disable-network \
--enable-zlib \
--disable-avfilter \
--disable-avdevice \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make -j4 install
$PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
$PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -soname libffmpeg.so -shared -nostdlib -z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a
}
#arm v6
#CPU=armv6
#OPTIMIZE_CFLAGS="-marm -march=$CPU"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
#arm v7vfpv3
CPU=armv7-a
OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=$CPU "
PREFIX=./android/$CPU
ADDITIONAL_CONFIGURE_FLAG=
build_one
#arm v7vfp
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU "
#PREFIX=./android/$CPU-vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_one
#arm v7n
#CPU=armv7-a
#OPTIMIZE_CFLAGS="-mfloat-abi=softfp -mfpu=neon -marm -march=$CPU -mtune=cortex-a8"
#PREFIX=./android/$CPU
#ADDITIONAL_CONFIGURE_FLAG=--enable-neon
#build_one
#arm v6+vfp
#CPU=armv6
#OPTIMIZE_CFLAGS="-DCMP_HAVE_VFP -mfloat-abi=softfp -mfpu=vfp -marm -march=$CPU"
#PREFIX=./android/${CPU}_vfp
#ADDITIONAL_CONFIGURE_FLAG=
#build_onei have set my path like above
I built it in Eclipse Everything is ok. but when i ran it in Android it crashed Unfortunately.
I found the errors in Logcat monitor :E/AndroidRuntime(1931) : java.lang.UnsatisfiedLinkError : Couldn’t load avcodec-55 from loader dalvik.system.PathClassLoader[DexPathList [1]] : findLibrary returned null
E/AndroidRuntime(1931) : at java.lang.Runtime.loadLibrary(Runtime.java:358)
In my activity i just call add Library from C preference like :
static {
//System.loadLibrary("avutil-52");
System.loadLibrary("avcodec-55");
System.loadLibrary("avformat-55");
System.loadLibrary("swscale-2");
System.loadLibrary("tutorial02");
}i check in DDMS in app-lib there is no existing Library in there.
The question is : Can i can compile the ffmpeg on windows ?
if ok. how can i config build_android.sh to point to Android $PREBUILTPLATFORM=$NDK/platforms/android-8/arch-arm/
PREBUILT=$NDK/prebuilt/windows-x86_64
function build_one
{
./configure --target-os=linux \
--prefix=$PREFIX \
--enable-cross-compile \
--extra-libs="-lgcc" \
--arch=arm \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--extra-cflags=" -O3 -fpic -DANDROID -DHAVE_SYS_UIO_H=1 -Dipv6mr_interface=ipv6mr_ifindex -fasm -Wno-psabi -fno-short-enums -fno-strict-aliasing -finline-limit=300 $OPTIMIZE_CFLAGS " \
--disable-shared \i found that in $NDK/prebuilt/windows-x86_64/bin did not exist arm-linux-androideabi-gcc\
How can i config to be suitable to run on windows ?Thank in advanced
-
How to add subtitles using FFmpeg-kit ?
17 novembre 2024, par Mohammed BekeleI'm running a Flutter app with Ffmpeg-kit package to burn a subtitle on a video. I have a words list with the timings and map that to generate an srt and ass file, but when executing this it didn't work.


Firstly, here is how I generated the Ass file.


Future<string> _createAssFile() async {
 String filePath = await getAssOutputFilePath();

 final file = File(filePath);
 final buffer = StringBuffer();

 // Write ASS headers
 buffer.writeln('[Script Info]');
 buffer.writeln('Title: Generated ASS');
 buffer.writeln('ScriptType: v4.00+');
 buffer.writeln('Collisions: Normal');
 buffer.writeln('PlayDepth: 0');
 buffer.writeln('Timer: 100,0000');
 buffer.writeln('[V4+ Styles]');
 buffer.writeln(
 'Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding');
 buffer.writeln(
 'Style: Default,Arial,40,&H00FFFFFF,&H000000FF,&H00000000,&H80000000,1,1,1,1,100,100,0,0,1,1,1,2,10,10,10,1');
 buffer.writeln('[Events]');
 buffer.writeln(
 'Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text');

 // Write events (subtitles)
 for (int i = 0; i < widget.words.length; i++) {
 final word = widget.words[i];
 final startTime = _formatAssTime(word['startTime'].toDouble());
 final endTime = _formatAssTime(word['endTime'].toDouble());
 final text = word['word'];

 buffer.writeln('Dialogue: 0,$startTime,$endTime,Default,,0,0,0,,$text');
 }

 await file.writeAsString(buffer.toString());
 return filePath;
 }

 String _formatAssTime(double seconds) {
 final int hours = seconds ~/ 3600;
 final int minutes = ((seconds % 3600) ~/ 60);
 final int secs = (seconds % 60).toInt();
 final int millis = ((seconds - secs) * 1000).toInt() % 1000;

 return '${hours.toString().padLeft(1, '0')}:${minutes.toString().padLeft(2, '0')}:${secs.toString().padLeft(2, '0')}.${(millis ~/ 10).toString().padLeft(2, '0')}';
 }
</string>


Then I used this command which was the official way of adding ass file to a video.


String newCmd = "-i $videoPath -vf ass=$assFilePath -c:a copy $_outputPath";



Yet when executing this command it did not work. However I changed it to this command


String newCmd = "-i $videoPath -i $assFilePath $_outputPath";



Well, that code works but the styling is not being applied. So I tried yet another command to filter and position the ass file.


String newCmd = "-i $videoPath -i $assFilePath -filter_complex \"[0:v][1:s]ass=\\an5:text='%{event.text}',scale=iw*0.8:ih*0.8,setdar=16/9[outv]\" -map [outv] -c:a copy $_outputPath";



This made it even worse, because the app crashed when I ran this. Also there is a log for this command before crashing


F/libc (19624): Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x19 in tid 21314 (pool-4-thread-7), pid 19624 (ple.caption_app)
*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
Build fingerprint: 'samsung/a15nsxx/a15:14/UP1A.231005.007/A155FXXU1AWKA:user/release-keys'
Revision: '5'
ABI: 'arm64'
Processor: '7'
Timestamp: 2024-07-10 19:27:40.812476860+0300
Process uptime: 1746s
Cmdline: com.example.caption_app
pid: 19624, tid: 21314, name: pool-4-thread-7 >>> com.example.caption_app <<<
uid: 10377
tagged_addr_ctrl: 0000000000000001 (PR_TAGGED_ADDR_ENABLE)
signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0000000000000019
Cause: null pointer dereference
 x0 0000000000000001 x1 b400006ec98d8660 x2 0000000000000000 x3 0000000000000002
 x4 0000006f62d1ea12 x5 b400006e04f745ea x6 352f35372f64352f x7 7f7f7f7f7f7f7f7f
 x8 632ace36577a905e x9 632ace36577a905e x10 0000006e191378c0 x11 0000000000000001
 x12 0000000000000001 x13 0000000000000000 x14 0000000000000004 x15 0000000000000008
 x16 0000006e27ffa358 x17 0000006e27dbfb00 x18 0000006e00d48000 x19 0000006f62d1f0e8
 x20 0000006f62d24000 x21 0000006e27ffc5d0 x22 0000006e27ffc5f0 x23 0000000000000000
 x24 b400006f3f089248 x25 0000006f62d1f220 x26 b400006f3f057b20 x27 0000000000000002
 x28 0000000000000088 x29 0000006f62d1f100
 lr 0000006e27dbfb0c sp 0000006f62d1f0a0 pc 0000006e27dbfb10 pst 0000000060001000
1 total frames
backtrace:
 #00 pc 0000000000121b10 /data/app/~~oWqjrGA2indQhuEw6u_J2A==/com.example.caption_app-u2Ofk54FVtMc5D-i3SLC6g==/base.apk!libavfilter.so (offset 0x10a46000) (avfilter_inout_free+16) 
Lost connection to device.



I tried the normal command in my local machine on Windows, and this is what I used


ffmpeg -i F:\ffmpeg\video.avi -vf subtitles='F\:\\ffmpeg\\caption.srt':force_style='Fontsize=24' F:\ffmpeg\new.mp4



As you can see above when subtitles are used it had an extra backslashes for each path and a pre backslash after the partition letter. But I don't know if this does apply for android devices. How can I make sense of this ?