
Recherche avancée
Médias (91)
-
Chuck D with Fine Arts Militia - No Meaning No
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Paul Westerberg - Looking Up in Heaven
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Le Tigre - Fake French
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Thievery Corporation - DC 3000
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Dan the Automator - Relaxation Spa Treatment
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
Gilberto Gil - Oslodum
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (98)
-
MediaSPIP version 0.1 Beta
16 avril 2011, parMediaSPIP 0.1 beta est la première version de MediaSPIP décrétée comme "utilisable".
Le fichier zip ici présent contient uniquement les sources de MediaSPIP en version standalone.
Pour avoir une installation fonctionnelle, il est nécessaire d’installer manuellement l’ensemble des dépendances logicielles sur le serveur.
Si vous souhaitez utiliser cette archive pour une installation en mode ferme, il vous faudra également procéder à d’autres modifications (...) -
MediaSPIP 0.1 Beta version
25 avril 2011, parMediaSPIP 0.1 beta is the first version of MediaSPIP proclaimed as "usable".
The zip file provided here only contains the sources of MediaSPIP in its standalone version.
To get a working installation, you must manually install all-software dependencies on the server.
If you want to use this archive for an installation in "farm mode", you will also need to proceed to other manual (...) -
Mise à jour de la version 0.1 vers 0.2
24 juin 2013, parExplications des différents changements notables lors du passage de la version 0.1 de MediaSPIP à la version 0.3. Quelles sont les nouveautés
Au niveau des dépendances logicielles Utilisation des dernières versions de FFMpeg (>= v1.2.1) ; Installation des dépendances pour Smush ; Installation de MediaInfo et FFprobe pour la récupération des métadonnées ; On n’utilise plus ffmpeg2theora ; On n’installe plus flvtool2 au profit de flvtool++ ; On n’installe plus ffmpeg-php qui n’est plus maintenu au (...)
Sur d’autres sites (13418)
-
Can x264 be used from Java code via JNI to decrease the resolution of RTMP streams ? [on hold]
5 septembre 2016, par Orr151I would like to implement a custom RTMP transcoder to HLS format in Java. As the repackaging itself seems to be relatively clear and doable in Java, then I found the modification of the video resolution a bit challenging in Java. My plan is to avoid using existing solutions like FFmpeg or at least minimize the amount of 3rd party frameworks/tools integrated with my component.
After some research it seems that reusage of JCodec and Xuggler can be challenging as both project are idle for a while. Also I’m not sure if their performance is acceptable. That’s why I would like to integrate directly with x264 library via JNI from Java code.
Is integration with x264/libx264 from Java code to decrease resolution/bitrate doable and is it a good idea ? Could you please suggest any other solutions ?
Thanks !
-
Fast method for adding text watermark to only first 25 frames using ffmpeg
4 février 2023, par SarkarI am looking to add a text watermark to the first 25 frames of a video using ffmpeg. I have already tried the following command but it takes a long time as it processes the entire video :


ffmpeg -i input.mp4 -vf "drawtext=fontfile=arial.ttf: text='Watermark': fontsize=24: fontcolor=white: x=(w-text_w)/2: y=(h-text_h)/2: enable='between(n,0,24)'" -c:a copy output.mp4



I need the encoding to be fast as I plan to make this change on the fly when streaming the video to the user. Is there a way to do this efficiently, such that the rest of the video remains unedited ?


-
Trying to decode and encode audio files with the FFMPEG C API
1er février 2023, par Giulio IacominoMy ultimate goal will be to split multi channel WAV files into single mono ones, after few days of experiments my plan is the sequence :


- 

- Decode audio file into a frame.
- Convert interleaved frame into a planar one. (in order to separate the data buffer into multiple ones)
- Grab the planar frame buffers and encode each of them into a new file.








So far I'm stuck trying to convert a wav file from interleaved to a planar one, and reprint the wav file.


edit :
I've turned on guard malloc and apparently the error is within the convert function


Here's the code :


AVCodecContext* initializeAndOpenCodecContext(AVFormatContext* formatContext, AVStream* stream){
 // grab our stream, most audio files only have one anyway
 const AVCodec* decoder = avcodec_find_decoder(stream->codecpar->codec_id);
 if (!decoder){
 std::cout << "no decoder, can't go ahead!\n";
 return nullptr;
 }
 AVCodecContext* codecContext = avcodec_alloc_context3(decoder);
 avcodec_parameters_to_context(codecContext, stream->codecpar);
 int err = avcodec_open2(codecContext, decoder, nullptr);
 if (err < 0){
 std::cout << "couldn't open codex!\n";
 }
 return codecContext;
}

void initialiseResampler(SwrContext* resampler, AVFrame* inputFrame, AVFrame* outputFrame){
 av_opt_set_chlayout(resampler, "in_channel_layout", &inputFrame->ch_layout, 0);
 av_opt_set_chlayout(resampler, "out_channel_layout", &outputFrame->ch_layout, 0);
 av_opt_set_int(resampler, "in_sample_fmt", inputFrame->format, 0);
 av_opt_set_int(resampler, "out_sample_fmt", AV_SAMPLE_FMT_FLTP, 0);
 av_opt_set_int(resampler, "in_sample_rate", inputFrame->sample_rate, 0);
 av_opt_set_int(resampler, "out_sample_rate", outputFrame->sample_rate, 0);
}

AVFrame* initialisePlanarFrame(AVFrame* frameToInit, AVFrame* inputFrame){
 //AVFrame *planar_frame = av_frame_alloc();
 frameToInit->nb_samples = inputFrame->nb_samples;
 frameToInit->ch_layout = inputFrame->ch_layout;
 frameToInit->format = AV_SAMPLE_FMT_FLTP;
 frameToInit->sample_rate = inputFrame->sample_rate;
 return nullptr;
}

int main() {
 AVCodecContext *codingContext= NULL;
 const AVCodec *codec;
 codec = avcodec_find_encoder(AV_CODEC_ID_PCM_F32LE);
 codingContext = avcodec_alloc_context3(codec);
 codingContext->bit_rate = 16000;
 codingContext->sample_fmt = AV_SAMPLE_FMT_FLT;
 codingContext->sample_rate = 48000;
 codingContext->ch_layout.nb_channels = 2;
 codingContext->ch_layout.order = (AVChannelOrder)0;
 uint8_t **buffer_ = NULL;
 AVFrame* planar_frame = NULL;
 
 // open input
 AVFormatContext* formatContext = nullptr;
 int err = avformat_open_input(&formatContext, "/Users/tonytorm/Desktop/drum kits/DECAP - Drums That Knock Vol. 9/Kicks/Brash Full Metal Kick.wav", nullptr, nullptr);
 if (err < 0){
 fprintf(stderr, "Unable to open file!\n");
 return;
 }

 // find audio stream
 err = avformat_find_stream_info(formatContext, nullptr);
 if (err > 0){
 fprintf(stderr, "Unable to retrieve stream info!\n");
 return;
 }
 
 int index = av_find_best_stream(formatContext, AVMEDIA_TYPE_AUDIO, -1, -1, nullptr, 0);
 if (index < 0){
 std::cout<< "coudn't find audio stream in this file" << '\n';
 }
 AVStream* stream = formatContext->streams[index];
 
 auto fileName = "/Users/tonytorm/Desktop/newFile.wav";
 FILE* newFile = fopen(fileName, "w+");
 
 // find right codec and open it
 if (auto openCodecContext = initializeAndOpenCodecContext(formatContext, stream)){
 AVPacket* packet = av_packet_alloc();
 AVFrame* frame = av_frame_alloc();
 AVFrame* planar_frame = av_frame_alloc();
 SwrContext *avr = swr_alloc(); //audio resampling context
 AVChannelLayout monoChannelLayout{(AVChannelOrder)0};
 monoChannelLayout.nb_channels = 2;
 

 while (!av_read_frame(formatContext, packet)){
 if (packet->stream_index != stream->index) continue; // we only care about audio
 int ret = avcodec_send_packet(openCodecContext, packet);
 if ( ret < 0) {
 if (ret != AVERROR(EAGAIN)){ // if error is actual error not EAGAIN
 std::cout << "can't do shit\n";
 return;
 }
 }
 while (int bret = avcodec_receive_frame(openCodecContext, frame) == 0){
 initialisePlanarFrame(planar_frame, frame);
 
 
 
 int buffer_size_in = av_samples_get_buffer_size(nullptr,
 frame->ch_layout.nb_channels,
 frame->nb_samples,
 (AVSampleFormat)frame->format,
 0);
 int buffer_size_out = buffer_size_in/frame->ch_layout.nb_channels;

 //planar_frame->linesize[0] = buffer_size_out;
 
 int ret = av_samples_alloc(planar_frame->data,
 NULL,
 planar_frame->ch_layout.nb_channels,
 planar_frame->nb_samples,
 AV_SAMPLE_FMT_FLTP,
 0);
 
 initialiseResampler(avr, frame, planar_frame);
 if (int errRet = swr_init(avr) < 0) {
 fprintf(stderr, "Failed to initialize the resampling context\n");
 }

 if (ret < 0){
 char error_message[AV_ERROR_MAX_STRING_SIZE];
 av_strerror(ret, error_message, AV_ERROR_MAX_STRING_SIZE);
 fprintf(stderr, "Error allocating sample buffer: %s\n", error_message);
 return -1;
 }
 
 int samples_converted = swr_convert(avr,
 planar_frame->data,
 buffer_size_out,
 (const uint8_t **)frame->data,
 buffer_size_in);
 if (samples_converted < 0) {
 // handle error
 std::cout << "error in conversion\n";
 return;
 }
 if (avcodec_open2(codingContext, codec, NULL) < 0) {
 std::cout << "can't encode!\n";
 return;
 }
 AVPacket* nu_packet = av_packet_alloc();
 while (int copy = avcodec_send_frame(codingContext, planar_frame) != 0){
 if (copy == AVERROR(EAGAIN) || copy == AVERROR_EOF){
 std::cout << "can't encode file\n";
 return;
 }
 if (avcodec_receive_packet(codingContext, nu_packet) >=0){
 fwrite(nu_packet->data, 4, nu_packet->size, newFile);
 //av_write_frame(avc, nu_packet);
 }
 }
 av_freep(planar_frame->data);
 av_frame_unref(frame);
 av_frame_unref(planar_frame);
 }
// av_packet_free(&packet);
// av_packet_free(&nu_packet);
 }
 swr_free(&avr);
 avcodec_free_context(&codingContext);
 
 }
 fclose(newFile);
}



I know i should write a header to the new wave file but for now I'm just trying to write the raw audio data. I'm getting always the same error but in different parts of the code (randomly), sometimes the code even compiles (writing the raw audio data, but filling it with some rubbish as well, i end up with a data file that is thrice the original one, sometimes i end up with a slightly smaller file - i guess the raw audio without the headers), results are basically random.


Here are some of the functions that trigger the error :


int ret = av_samples_alloc(); //(this the most common one)
swr_convert()
av_freep();



the error is :


main(64155,0x101b5d5c0) malloc: Incorrect checksum for freed object 0x106802600: probably modified after being freed.
Corrupt value: 0x0
main(64155,0x101b5d5c0) malloc: *** set a breakpoint in malloc_error_break to debug */