
Recherche avancée
Médias (39)
-
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
-
Spoon - Revenge !
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
-
My Morning Jacket - One Big Holiday
15 septembre 2011, par
Mis à jour : Septembre 2011
Langue : English
Type : Audio
Autres articles (13)
-
Librairies et logiciels spécifiques aux médias
10 décembre 2010, parPour un fonctionnement correct et optimal, plusieurs choses sont à prendre en considération.
Il est important, après avoir installé apache2, mysql et php5, d’installer d’autres logiciels nécessaires dont les installations sont décrites dans les liens afférants. Un ensemble de librairies multimedias (x264, libtheora, libvpx) utilisées pour l’encodage et le décodage des vidéos et sons afin de supporter le plus grand nombre de fichiers possibles. Cf. : ce tutoriel ; FFMpeg avec le maximum de décodeurs et (...) -
L’espace de configuration de MediaSPIP
29 novembre 2010, parL’espace de configuration de MediaSPIP est réservé aux administrateurs. Un lien de menu "administrer" est généralement affiché en haut de la page [1].
Il permet de configurer finement votre site.
La navigation de cet espace de configuration est divisé en trois parties : la configuration générale du site qui permet notamment de modifier : les informations principales concernant le site (...) -
Other interesting software
13 avril 2011, parWe don’t claim to be the only ones doing what we do ... and especially not to assert claims to be the best either ... What we do, we just try to do it well and getting better ...
The following list represents softwares that tend to be more or less as MediaSPIP or that MediaSPIP tries more or less to do the same, whatever ...
We don’t know them, we didn’t try them, but you can take a peek.
Videopress
Website : http://videopress.com/
License : GNU/GPL v2
Source code : (...)
Sur d’autres sites (2404)
-
rtpdec : Don’t free the payload context in the .free function
24 février 2015, par Martin Storsjörtpdec : Don’t free the payload context in the .free function
This makes it more consistent with depacketizers that don’t have any
.free function at all, where the payload context is freed by the
surrounding framework. Always free the context in the surrounding
framework, having the individual depacketizers only free any data
they’ve specifically allocated themselves.This is similar to how this works for demuxer/muxers/codecs - a
component shouldn’t free the priv_data that the framework has
allocated for it.Signed-off-by : Martin Storsjö <martin@martin.st>
- [DH] libavformat/rdt.c
- [DH] libavformat/rtpdec.h
- [DH] libavformat/rtpdec_ac3.c
- [DH] libavformat/rtpdec_dv.c
- [DH] libavformat/rtpdec_h261.c
- [DH] libavformat/rtpdec_h263_rfc2190.c
- [DH] libavformat/rtpdec_h264.c
- [DH] libavformat/rtpdec_jpeg.c
- [DH] libavformat/rtpdec_latm.c
- [DH] libavformat/rtpdec_mpa_robust.c
- [DH] libavformat/rtpdec_mpeg4.c
- [DH] libavformat/rtpdec_mpegts.c
- [DH] libavformat/rtpdec_qt.c
- [DH] libavformat/rtpdec_svq3.c
- [DH] libavformat/rtpdec_vp8.c
- [DH] libavformat/rtpdec_xiph.c
- [DH] libavformat/rtsp.c
-
rtpdec : Don’t free the payload context in the .free function
24 février 2015, par Martin Storsjörtpdec : Don’t free the payload context in the .free function
This makes it more consistent with depacketizers that don’t have any
.free function at all, where the payload context is freed by the
surrounding framework. Always free the context in the surrounding
framework, having the individual depacketizers only free any data
they’ve specifically allocated themselves.This is similar to how this works for demuxer/muxers/codecs - a
component shouldn’t free the priv_data that the framework has
allocated for it.Signed-off-by : Martin Storsjö <martin@martin.st>
- [DBH] libavformat/rdt.c
- [DBH] libavformat/rtpdec.h
- [DBH] libavformat/rtpdec_ac3.c
- [DBH] libavformat/rtpdec_dv.c
- [DBH] libavformat/rtpdec_h261.c
- [DBH] libavformat/rtpdec_h263_rfc2190.c
- [DBH] libavformat/rtpdec_h264.c
- [DBH] libavformat/rtpdec_jpeg.c
- [DBH] libavformat/rtpdec_latm.c
- [DBH] libavformat/rtpdec_mpa_robust.c
- [DBH] libavformat/rtpdec_mpeg4.c
- [DBH] libavformat/rtpdec_mpegts.c
- [DBH] libavformat/rtpdec_qt.c
- [DBH] libavformat/rtpdec_svq3.c
- [DBH] libavformat/rtpdec_vp8.c
- [DBH] libavformat/rtpdec_xiph.c
- [DBH] libavformat/rtsp.c
-
How do you properly free a BitStreamFilter (bsf) without getting a double free error ?
19 janvier 2021, par Alexis WilkeI'm trying to write a C++ class handling MP4 movies via ffmpeg.


First I created a couple of functions to use with
std::unique<>()
so that way things get released even on exceptions.

However, I get a double free when I try to free the BitStreamFilter object, yet the documentation clearly says that each
av_bsf_alloc()
must be paired with anav_bsf_free()
call.



@param ctx
a pointer into which the pointer to the newly-allocated context
will be written. It must be freed withav_bsf_free()
after the
filtering is done.



Note : emphasis mine.


However, at the time I call the
avformat_close_input()
I get a double free error, even if I haven't used the two contexts for anything !? I'm thinking that there may be a packet that both allocate and both try to free. But since these two contexts are not directly connected, I really don't understand how they end up freeing something twice.

Below is code which reproduce the error (at least on an amd64 platform). Once compiled, you can just execute it. Make sure to specify a filename as in :


./ffmpeg_demuxer_test mymovie.mp4



I used the following command to compile & link the code :


$ /usr/bin/c++ -std=c++17 -DDEBUG -D_DEBUG -D_GLIBCXX_ASSERTIONS -g -O0 \
 -fsanitize=address -fsanitize=enum -fsanitize=unreachable \
 -o ffmpeg_demuxer_test ffmpeg_demuxer_test.cpp \
 -lavformat -lavcodec



Notice the
-fsanitize=...
options to capture errors such as a double free error.

Here is the code :


extern "C" {
#include <libavformat></libavformat>avformat.h>
#include <libavformat></libavformat>avio.h>
#include <libavcodec></libavcodec>avcodec.h>
}
#include <iostream>
#include <memory>


void ffmpeg_demuxer_avformat_context_free(AVFormatContext * context)
{
 if(context != nullptr) avformat_close_input(&context);
}

void ffmpeg_demuxer_av_bsf_free(AVBSFContext * context)
{
 if(context != nullptr) av_bsf_free(&context);
}


int main(int argc, char * argv [])
{
 if(argc != 2)
 {
 std::cout << "Usage: " << argv[0] << " movie.mp4" << std::endl;
 exit(1);
 }

 // init the AV libraries
 //
 av_register_all();
 avformat_network_init();

 // allocate the AVFormatContext
 //
 AVFormatContext * format_context(nullptr);
 int const r1(avformat_open_input(
 &format_context
 , argv[1]
 , nullptr // input format
 , nullptr)); // options
 if(r1 != 0
 || format_context == nullptr)
 {
 throw std::bad_alloc();
 }

 auto f_format_context = std::unique_ptr<
 AVFormatContext
 , decltype(&ffmpeg_demuxer_avformat_context_free)>(
 format_context
 , &ffmpeg_demuxer_avformat_context_free);


 // now allocate a stream
 //
 if(avformat_find_stream_info(f_format_context.get(), nullptr) < 0)
 {
 throw std::runtime_error("ffmpeg: Could not find stream info");
 }

 auto f_video_stream_index = av_find_best_stream(
 f_format_context.get()
 , AVMEDIA_TYPE_VIDEO
 , -1 // wanted stream (any)
 , -1 // related stream (none)
 , nullptr // AVCodec *
 , 0); // flags
 if(f_video_stream_index < 0)
 {
 throw std::runtime_error("ffmpeg: Could not find stream in input file");
 }
 if(static_cast<unsigned int="int">(f_video_stream_index) >= f_format_context->nb_streams)
 {
 throw std::range_error("ffmpeg: Stream index out of range");
 }

 auto f_stream = f_format_context->streams[f_video_stream_index];

 auto f_video_codec = f_stream->codecpar->codec_id;

 int f_bit_depth(0);
 switch(f_stream->codecpar->format)
 {
 case AV_PIX_FMT_YUV420P10LE:
 f_bit_depth = 10;
 break;

 case AV_PIX_FMT_YUV420P12LE:
 f_bit_depth = 12;
 break;

 default:
 f_bit_depth = 8;
 break;

 }

 bool f_mp4_h264 = f_video_codec == AV_CODEC_ID_H264 && (
 strcmp(f_format_context->iformat->long_name, "QuickTime / MOV") == 0
 || strcmp(f_format_context->iformat->long_name, "FLV (Flash Video)") == 0
 || strcmp(f_format_context->iformat->long_name, "Matroska / WebM") == 0
 );

 if(f_mp4_h264)
 {
 AVBitStreamFilter const * bsf_stream_filter(av_bsf_get_by_name("h264_mp4toannexb"));
 if(bsf_stream_filter == nullptr)
 {
 throw std::runtime_error("av_bsf_get_by_name(\"h264_mp4toannexb\") failed");
 }
 AVBSFContext * bsf_context(nullptr);
 int const r2(av_bsf_alloc(bsf_stream_filter, &bsf_context));
 if(r2 < 0
 || bsf_context == nullptr)
 {
 throw std::bad_alloc();
 }
 auto f_bsf_context = std::unique_ptr<
 AVBSFContext
 , decltype(&ffmpeg_demuxer_av_bsf_free)>(
 bsf_context
 , &ffmpeg_demuxer_av_bsf_free);
 f_bsf_context->par_in = f_stream->codecpar;
 if(av_bsf_init(f_bsf_context.get()) < 0)
 {
 throw std::runtime_error("av_bsf_init() failed");
 }
 }

 return 0;
}
</unsigned></memory></iostream>


So. Am I misreading the documentation or misusing one of the free/close function ? I don't think that the
AVBSFContext
itself gets released when I close theAVFormatContext
, but I may be mistaken ?

I won't put "C" as a tag since it will get removed even though this applies to C. It's not because I use C++ that I get a double free (i.e. it happens in the ffmpeg C library).