
Recherche avancée
Médias (2)
-
Granite de l’Aber Ildut
9 septembre 2011, par
Mis à jour : Septembre 2011
Langue : français
Type : Texte
-
Géodiversité
9 septembre 2011, par ,
Mis à jour : Août 2018
Langue : français
Type : Texte
Autres articles (25)
-
La file d’attente de SPIPmotion
28 novembre 2010, parUne file d’attente stockée dans la base de donnée
Lors de son installation, SPIPmotion crée une nouvelle table dans la base de donnée intitulée spip_spipmotion_attentes.
Cette nouvelle table est constituée des champs suivants : id_spipmotion_attente, l’identifiant numérique unique de la tâche à traiter ; id_document, l’identifiant numérique du document original à encoder ; id_objet l’identifiant unique de l’objet auquel le document encodé devra être attaché automatiquement ; objet, le type d’objet auquel (...) -
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 (...) -
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 (...)
Sur d’autres sites (3034)
-
FFmpeg android images to movie - error while opening encoder [duplicate]
12 juin 2018, par trinadh thatakulaThis question already has an answer here :
I have been working on android-ffmpeg to convert images into videos and I have found the code I was looking(links below) and I have tried to execute this command
val cmd5 = arrayOf("-analyzeduration", "1M", "-probesize", "1M", "-y", "-framerate", "1/3.79", "-i", Utils.outputPath + "image%d.jpg", "-i", audio!!.path, "-c:v", "libx264", "-tune", "stillimage", "-c:a", "aac", "-strict", "experimental", "-b:a", "192k", "-pix_fmt", "yuv420p", "-shortest", outputLocation.path)
and I got error saying
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
can any1 please help me
I have taken code from here -> KotlinFFmpeg and the code snippet is from here -> MovieMaker.kt, please give me a solution, thanks in advance
here are the logs
2018-06-12 18:22:24.000 25364-25664/photo.video.maker D/FFmpeg: Running publishing updates method
2018-06-12 18:22:24.096 25364-25364/photo.video.maker W/System.err: java.io.IOException: ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: built with gcc 4.8 (GCC)
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: libavutil 55. 17.103 / 55. 17.103
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: libavcodec 57. 24.102 / 57. 24.102
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: libavformat 57. 25.100 / 57. 25.100
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: libavdevice 57. 0.101 / 57. 0.101
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: libavfilter 6. 31.100 / 6. 31.100
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: libswscale 4. 0.100 / 4. 0.100
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: libswresample 2. 0.101 / 2. 0.101
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: libpostproc 54. 0.100 / 54. 0.100
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: [mjpeg @ 0xf193d000] Changing bps to 8
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Input #0, image2, from '/storage/emulated/0/Photo Video Maker/image%d.jpg':
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Duration: 00:02:35.39, start: 0.000000, bitrate: N/A
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1440x1919 [SAR 1:1 DAR 1440:1919], 0.26 tbr, 0.26 tbn, 0.26 tbc
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: [mp3 @ 0xf192d600] Skipping 0 bytes of junk at 61264.
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: [mjpeg @ 0xf193dc00] Changing bps to 8
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Input #1, mp3, from '/data/user/0/photo.video.maker/files/audio2.mp3':
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Metadata:
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: album_artist : Various Artists
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: AccurateRipDiscID: 018-002fb7fe-0279b2d7-47111512-2
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: AccurateRipResult: AccurateRip: Accurate (confidence 10) [0A38F342]
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: title : Morning
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: encoded_by : dBpoweramp Release 14.4
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: publisher : EMI Classics
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: composer : Edvard Grieg
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: TMED : CD (Lossless)
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: genre : Classical
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: compilation : 1
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: album : The Most Relaxing Classical Album in the World...Ever!
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: track : 2/18
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: disc : 1/2
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: artist : Edvard Grieg
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Encoder : Lame 3.99.5
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: UPC : 024356665027
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: date : 1999
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Duration: 00:04:18.04, start: 0.025056, bitrate: 321 kb/s
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 320 kb/s
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Metadata:
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: encoder : LAME3.99r
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Stream #1:1: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 747x750 [SAR 1:1 DAR 249:250], 90k tbr, 90k tbn, 90k tbc
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Metadata:
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: comment : Cover (front)
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: [swscaler @ 0xf1125000] deprecated pixel format used, make sure you did set range correctly
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: [libx264 @ 0xf193ec00] height not divisible by 2 (1440x1919)
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Output #0, mp4, to '/storage/emulated/0/Photo Video Maker/video/movie_1528807939616.mp4':
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, SAR 1:1 DAR 0:0, 0.26 fps
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Metadata:
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: encoder : Lavc57.24.102 libx264
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Stream #0:1: Audio: aac, 0 channels, 128 kb/s
2018-06-12 18:22:24.097 25364-25364/photo.video.maker W/System.err: Metadata:
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: encoder : Lavc57.24.102 aac
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: Stream mapping:
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: Stream #0:0 -> #0:0 (mjpeg (native) -> h264 (libx264))
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: Stream #1:0 -> #0:1 (mp3 (native) -> aac (native))
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at photo.video.maker.tools.video.MovieMaker$convert$1.onFailure(MovieMaker.kt:78)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.onPostExecute(FFmpegExecuteAsyncTask.java:70)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at com.github.hiteshsondhi88.libffmpeg.FFmpegExecuteAsyncTask.onPostExecute(FFmpegExecuteAsyncTask.java:10)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at android.os.AsyncTask.finish(AsyncTask.java:695)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at android.os.AsyncTask.-wrap1(Unknown Source:0)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:712)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at android.os.Handler.dispatchMessage(Handler.java:106)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at android.os.Looper.loop(Looper.java:164)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at android.app.ActivityThread.main(ActivityThread.java:6494)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at java.lang.reflect.Method.invoke(Native Method)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
2018-06-12 18:22:24.098 25364-25364/photo.video.maker W/System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) -
C++ ffmpeg lib version 7.0 - noice in exported audio
2 septembre 2024, par Chris PI want to make a C++ lib named cppdub which will mimic the python module pydub.


One main function is to export the AudioSegment to a file with a specific format (example : mp3).


The code is :


AudioSegment AudioSegment::from_file(const std::string& file_path, const std::string& format, const std::string& codec,
 const std::map& parameters, int start_second, int duration) {

 avformat_network_init();
 av_log_set_level(AV_LOG_ERROR); // Adjust logging level as needed

 AVFormatContext* format_ctx = nullptr;
 if (avformat_open_input(&format_ctx, file_path.c_str(), nullptr, nullptr) != 0) {
 std::cerr << "Error: Could not open audio file." << std::endl;
 return AudioSegment(); // Return an empty AudioSegment on failure
 }

 if (avformat_find_stream_info(format_ctx, nullptr) < 0) {
 std::cerr << "Error: Could not find stream information." << std::endl;
 avformat_close_input(&format_ctx);
 return AudioSegment();
 }

 int audio_stream_index = -1;
 for (unsigned int i = 0; i < format_ctx->nb_streams; i++) {
 if (format_ctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
 audio_stream_index = i;
 break;
 }
 }

 if (audio_stream_index == -1) {
 std::cerr << "Error: Could not find audio stream." << std::endl;
 avformat_close_input(&format_ctx);
 return AudioSegment();
 }

 AVCodecParameters* codec_par = format_ctx->streams[audio_stream_index]->codecpar;
 const AVCodec* my_codec = avcodec_find_decoder(codec_par->codec_id);
 AVCodecContext* codec_ctx = avcodec_alloc_context3(my_codec);

 if (avcodec_parameters_to_context(codec_ctx, codec_par) < 0) {
 std::cerr << "Error: Could not initialize codec context." << std::endl;
 avformat_close_input(&format_ctx);
 return AudioSegment();
 }

 if (avcodec_open2(codec_ctx, my_codec, nullptr) < 0) {
 std::cerr << "Error: Could not open codec." << std::endl;
 avcodec_free_context(&codec_ctx);
 avformat_close_input(&format_ctx);
 return AudioSegment();
 }

 SwrContext* swr_ctx = swr_alloc();
 if (!swr_ctx) {
 std::cerr << "Error: Could not allocate SwrContext." << std::endl;
 avcodec_free_context(&codec_ctx);
 avformat_close_input(&format_ctx);
 return AudioSegment();
 }

 av_opt_set_chlayout(swr_ctx, "in_chlayout", &codec_ctx->ch_layout, 0);
 av_opt_set_int(swr_ctx, "in_sample_rate", codec_ctx->sample_rate, 0);
 av_opt_set_sample_fmt(swr_ctx, "in_sample_fmt", codec_ctx->sample_fmt, 0);

 AVChannelLayout dst_ch_layout;
 av_channel_layout_copy(&dst_ch_layout, &codec_ctx->ch_layout);
 av_channel_layout_uninit(&dst_ch_layout);
 av_channel_layout_default(&dst_ch_layout, 2);

 av_opt_set_chlayout(swr_ctx, "out_chlayout", &dst_ch_layout, 0);
 av_opt_set_int(swr_ctx, "out_sample_rate", 48000, 0);
 av_opt_set_sample_fmt(swr_ctx, "out_sample_fmt", AV_SAMPLE_FMT_S16, 0);

 if (swr_init(swr_ctx) < 0) {
 std::cerr << "Error: Failed to initialize the resampling context" << std::endl;
 swr_free(&swr_ctx);
 avcodec_free_context(&codec_ctx);
 avformat_close_input(&format_ctx);
 return AudioSegment();
 }

 AVPacket packet;
 AVFrame* frame = av_frame_alloc();
 if (!frame) {
 std::cerr << "Error: Could not allocate frame." << std::endl;
 swr_free(&swr_ctx);
 avcodec_free_context(&codec_ctx);
 avformat_close_input(&format_ctx);
 return AudioSegment();
 }

 std::vector<char> output;
 while (av_read_frame(format_ctx, &packet) >= 0) {
 if (packet.stream_index == audio_stream_index) {
 if (avcodec_send_packet(codec_ctx, &packet) == 0) {
 while (avcodec_receive_frame(codec_ctx, frame) == 0) {
 if (frame->pts != AV_NOPTS_VALUE) {
 frame->pts = av_rescale_q(frame->pts, codec_ctx->time_base, format_ctx->streams[audio_stream_index]->time_base);
 }

 uint8_t* output_buffer;
 int output_samples = av_rescale_rnd(
 swr_get_delay(swr_ctx, codec_ctx->sample_rate) + frame->nb_samples,
 48000, codec_ctx->sample_rate, AV_ROUND_UP);

 int output_buffer_size = av_samples_get_buffer_size(
 nullptr, 2, output_samples, AV_SAMPLE_FMT_S16, 1);

 output_buffer = (uint8_t*)av_malloc(output_buffer_size);

 if (output_buffer) {
 memset(output_buffer, 0, output_buffer_size); // Zero padding to avoid random noise
 int converted_samples = swr_convert(swr_ctx, &output_buffer, output_samples,
 (const uint8_t**)frame->extended_data, frame->nb_samples);

 if (converted_samples >= 0) {
 output.insert(output.end(), output_buffer, output_buffer + output_buffer_size);
 }
 else {
 std::cerr << "Error: Failed to convert audio samples." << std::endl;
 }

 av_free(output_buffer);
 }
 else {
 std::cerr << "Error: Could not allocate output buffer." << std::endl;
 }
 }
 }
 else {
 std::cerr << "Error: Failed to send packet to codec context." << std::endl;
 }
 }
 av_packet_unref(&packet);
 }

 av_frame_free(&frame);
 swr_free(&swr_ctx);
 avcodec_free_context(&codec_ctx);
 avformat_close_input(&format_ctx);

 std::map metadata = {
 {"sample_width", 2},
 {"frame_rate", 48000},
 {"channels", 2},
 {"frame_width", 4}
 };

 return AudioSegment(static_cast<const>(output.data()), output.size(), metadata);
}


std::ofstream AudioSegment::export_segment(std::string& out_f,
 const std::string& format,
 const std::string& codec,
 const std::string& bitrate,
 const std::vector& parameters,
 const std::map& tags,
 const std::string& id3v2_version,
 const std::string& cover) {
 av_log_set_level(AV_LOG_DEBUG);
 AVCodecContext* codec_ctx = nullptr;
 AVFormatContext* format_ctx = nullptr;
 AVStream* stream = nullptr;
 AVFrame* frame = nullptr;
 AVPacket* pkt = nullptr;
 int ret;

 // Open output file
 std::ofstream out_file(out_f, std::ios::binary);
 if (!out_file) {
 throw std::runtime_error("Failed to open output file.");
 }

 // Initialize format context
 avformat_alloc_output_context2(&format_ctx, nullptr, format.c_str(), out_f.c_str());
 if (!format_ctx) {
 throw std::runtime_error("Could not allocate format context.");
 }

 // Find encoder
 const AVCodec* codec_ptr = avcodec_find_encoder_by_name(codec.c_str());
 if (!codec_ptr) {
 throw std::runtime_error("Codec not found.");
 }

 // Add stream
 stream = avformat_new_stream(format_ctx, codec_ptr);
 if (!stream) {
 throw std::runtime_error("Failed to create new stream.");
 }

 // Allocate codec context
 codec_ctx = avcodec_alloc_context3(codec_ptr);
 if (!codec_ctx) {
 throw std::runtime_error("Could not allocate audio codec context.");
 }

 // Set codec parameters
 codec_ctx->bit_rate = std::stoi(bitrate);
 codec_ctx->sample_fmt = codec_ptr->sample_fmts ? codec_ptr->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;
 codec_ctx->sample_rate = frame_rate_;
 codec_ctx->ch_layout.nb_channels = this->get_channels();
 AVChannelLayout ch_layout_1;
 av_channel_layout_uninit(&ch_layout_1);
 av_channel_layout_default(&ch_layout_1, this->get_channels());
 codec_ctx->ch_layout = ch_layout_1;

 // Open codec
 ret = avcodec_open2(codec_ctx, codec_ptr, nullptr);
 if (ret < 0) {
 throw std::runtime_error("Could not open codec.");
 }

 // Initialize packet
 pkt = av_packet_alloc();
 if (!pkt) {
 throw std::runtime_error("Could not allocate AVPacket.");
 }

 // Initialize frame
 frame = av_frame_alloc();
 if (!frame) {
 throw std::runtime_error("Could not allocate AVFrame.");
 }

 frame->nb_samples = codec_ctx->frame_size;
 frame->format = codec_ctx->sample_fmt;
 frame->ch_layout = codec_ctx->ch_layout;
 frame->sample_rate = codec_ctx->sample_rate;

 // Allocate data buffer
 ret = av_frame_get_buffer(frame, 0);
 if (ret < 0) {
 throw std::runtime_error("Could not allocate audio data buffers.");
 }

 // Encode frames
 int samples_read = 0;
 while (samples_read < data_.size()) {
 ret = av_frame_make_writable(frame);
 if (ret < 0) {
 throw std::runtime_error("Frame not writable.");
 }

 // Determine the number of samples to copy into the frame
 int frame_size = std::min<int>(codec_ctx->frame_size, (data_.size() - samples_read) / frame_width_);
 int buffer_size = frame_size * frame_width_;

 // Clear the frame data to avoid artifacts from previous data
 std::memset(frame->data[0], 0, codec_ctx->frame_size * frame_width_);

 // Copy the actual audio data into the frame
 std::memcpy(frame->data[0], data_.data() + samples_read, buffer_size);
 samples_read += buffer_size;

 // If the frame is partially filled, pad the remaining part with zeros
 if (frame_size < codec_ctx->frame_size) {
 std::memset(frame->data[0] + buffer_size, 0, (codec_ctx->frame_size - frame_size) * frame_width_);
 }

 // Send the frame for encoding
 ret = avcodec_send_frame(codec_ctx, frame);
 if (ret < 0) {
 throw std::runtime_error("Error sending frame for encoding.");
 }

 // Receive and write packets
 while (ret >= 0) {
 ret = avcodec_receive_packet(codec_ctx, pkt);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
 break;
 }
 else if (ret < 0) {
 throw std::runtime_error("Error encoding frame.");
 }

 out_file.write(reinterpret_cast(pkt->data), pkt->size);
 av_packet_unref(pkt);
 }
 }

 // **Explicitly flush the encoder**
 ret = avcodec_send_frame(codec_ctx, nullptr);
 if (ret < 0) {
 throw std::runtime_error("Error flushing the encoder.");
 }

 // Receive and write remaining packets after flushing
 while (ret >= 0) {
 ret = avcodec_receive_packet(codec_ctx, pkt);
 if (ret == AVERROR(EAGAIN) || ret == AVERROR_EOF) {
 break;
 }
 else if (ret < 0) {
 throw std::runtime_error("Error encoding frame during flush.");
 }

 out_file.write(reinterpret_cast(pkt->data), pkt->size);
 av_packet_unref(pkt);
 }

 // Cleanup
 av_frame_free(&frame);
 av_packet_free(&pkt);
 avcodec_free_context(&codec_ctx);
 avformat_free_context(format_ctx);

 return out_file;
}
</int></const></char>


I have no run time error but i see this message in console :


[libmp3lame @ 000002d26b239ac0] Trying to remove 47 more samples than there are in the queue



I can play the exported mp3 file but there is background noise.


-
Revision 33331 : simplifier les petitions : le tableau des signatures utilise les classe ...
27 novembre 2009, par cedric@… — Logsimplifier les petitions : le tableau des signatures utilise les classe generiques table.spip et autre qui lui permet d’etre par defaut dans le theme. Les class specifiques sur chaque element restent utilisables pour affiner si (...)