[Ffmpeg-devel-irc] ffmpeg.log.20181127

burek burek021 at gmail.com
Wed Nov 28 03:05:01 EET 2018


[08:56:21 CET] <skident> hi, does anybody have build an ffmpeg library for windows 10 using MSVC 2017?
[09:01:38 CET] <skident> I tried to use this guide https://trac.ffmpeg.org/wiki/CompilationGuide/WinRT, but paths are different from VS2015
[11:33:31 CET] <cslcm> Hi everyone - I have a big memory leak in this program: https://pastebin.com/raw/3X5h9YiK  centered around av_bitstream_filter_filter - if i remove this call there is no leak. Could someone take a look and tell me if i'm handling resources incorrectly?
[12:07:34 CET] <skident> \cslcm have you checked a return value from av_bitstream_filter_filter (int a = )?
[12:10:36 CET] <skident> cslcm: have you checked a return value from av_bitstream_filter_filter (int a = )?
[12:16:18 CET] <cslcm> the return value is always 1
[13:20:51 CET] <skident> how does this memleak looks like? It eats memory on each call of av_bitstream_filter_filter and doesn't free memory at all&
[13:20:52 CET] <skident> ?
[13:24:20 CET] <cslcm> right, it quickly fills up to gigabytes of allocations
[13:24:48 CET] <cslcm> I posted a question on stackoverflow including valgrind output https://stackoverflow.com/questions/53498403/av-bitstream-filter-filter-memory-leak
[13:25:21 CET] <cslcm> i suspect the leak may be internal to ffmpeg
[13:25:37 CET] <BtbN> Unlikely, that functions is used a lot.
[13:25:49 CET] <cslcm> with h264_mp4toannexb?
[13:25:52 CET] <BtbN> yes
[13:25:58 CET] <BtbN> it's auto-inserted whenever it's needed
[13:26:51 CET] <cslcm> i could try with ffmpeg itself, is there a command line option to tell it to keep looping the input indefinitely
[13:26:59 CET] <BtbN> -loop
[13:27:05 CET] <cslcm> hah
[13:27:07 CET] <cslcm> fancy that
[13:28:23 CET] <BtbN> But I see your leek
[13:28:26 CET] <BtbN> https://github.com/FFmpeg/FFmpeg/blob/0c14b73e435cf3373df7bca149e665d4e6b80a8d/libavcodec/avpacket.c#L281
[13:28:38 CET] <BtbN> av_free_packet only frees buffers, not raw data on the packet
[13:28:48 CET] <BtbN> *leak
[13:29:45 CET] <BtbN> so your pkt2 is never freed
[13:31:47 CET] <cslcm> but it's reused
[13:31:59 CET] <BtbN> doesn't matter
[13:32:00 CET] <cslcm> so it will leak once
[13:32:17 CET] <BtbN> each call to av_bitstream_filter_filter calls malloc and assigns the result to pkt2.data
[13:32:29 CET] <BtbN> And you just overwrite it with NULL again, never freeing it
[13:32:40 CET] <cslcm> ah right, how do i free that data?
[13:32:47 CET] <cslcm> literally just free?
[13:32:51 CET] <BtbN> av_free
[13:32:54 CET] <cslcm> ok
[13:32:57 CET] <cslcm> will try that, thanks
[13:33:08 CET] <BtbN> av_freep(&pkt.data) ideally
[13:33:45 CET] <BtbN> You probably shouldn't use a packet there
[13:34:05 CET] <BtbN> Or take a look at how the legacy compat code handles it: https://github.com/FFmpeg/FFmpeg/blob/f72b9904fefa79d799d0f6ecc8bd97ce52658725/libavformat/utils.c#L5604
[13:36:33 CET] <BtbN> av_free_packet is also deprecated and should not be used. Use unref instead
[13:37:50 CET] <cslcm> should i be freeing the data and the packet on each iteration?
[13:37:53 CET] <cslcm> or just the data?
[13:40:27 CET] <BtbN> The whole API you are using is deprecated btw.
[13:40:45 CET] <BtbN> You should be using the av_bsf_* API instead
[13:40:50 CET] <cslcm> I'm only following the examples on the ffmpeg website heh
[13:40:53 CET] <cslcm> this is new to me
[13:41:26 CET] <BtbN> https://www.ffmpeg.org/doxygen/trunk/group__lavc__misc.html#ga511d9ec0593e70035813492a7bb1d390
[13:41:48 CET] <cslcm> is there an example anywhere showing how to do it the new way?
[13:42:37 CET] <BtbN> plenty all over the ffmpeg codebase.
[13:42:44 CET] <BtbN> Search for av_bsf_ for example in http://git.videolan.org/?p=ffmpeg.git;a=blob;f=libavcodec/cuviddec.c
[13:44:02 CET] <cslcm> looks like it's av_freep i needed and not av_free. and if i also try to av_free_packet it complains of a double-free.
[13:44:15 CET] <cslcm> but the leak is fixed, thanks for your help
[13:44:21 CET] <cslcm> i'll look into the new api
[13:44:22 CET] <BtbN> av_free and av_freep do the same, but freep sets the pointer to NULL
[13:44:41 CET] <BtbN> av_free(v); v = NULL; is equivalent to av_freep(&v);
[13:45:45 CET] <cslcm> hm, that's very weird, because I am setting data to null after ever free... but free results in "munmap_chunk(): invalid pointer" whereas freep does not
[13:46:18 CET] <BtbN> You're doing something wrong then
[13:50:42 CET] <BtbN> The new API is way less prone to this btw.
[13:50:54 CET] <cslcm> if av_free_packet doesn't free the packet data then why does it result in a double free when i try to free both
[13:51:17 CET] <BtbN> You are freeing something you are not supposed to free I guess
[13:51:29 CET] <BtbN> but really, use the new API, it makes a whole lot more sense
[13:51:42 CET] <BtbN> And avoid that issue entirely
[13:51:56 CET] <cslcm> i'm trying to find some actual examples
[13:52:49 CET] <cslcm> anyway, thanks for your help :) I appreciate it
[13:55:46 CET] <BtbN> The new API is fairly self-explanatory
[13:55:58 CET] <BtbN> Why do you even want to use it directly? Usually the encoders that need it do it themselves
[13:58:02 CET] <cslcm> openmaxil on the raspberry pi requires h264 data in this format
[13:58:55 CET] <cslcm> interestingly none of the examples i could find on the web which use this filter free the frame data with av_free
[13:59:00 CET] <cslcm> so they all leak i guess
[14:16:00 CET] <cslcm> BtbN: So it appears that av_free is only necessary on the output from av_bitstream_filter_filter.. i guess av_read_frame does it for us
[14:16:17 CET] <cslcm> that's why i was getting the double free issue
[14:17:09 CET] <BtbN> The old API is really bad for that. It was replaced for a reason
[14:17:26 CET] <cslcm> i get it, i know. I will look into it. Just have a deadline for this phase.
[14:18:46 CET] <cslcm> ==44787== LEAK SUMMARY:  ==44787==    definitely lost: 0 bytes in 0 blocks  ==44787==    indirectly lost: 0 bytes in 0 blocks  ==44787==      possibly lost: 0 bytes in 0 blocks
[14:18:48 CET] <cslcm> success :D
[14:18:49 CET] <cslcm> cheers
[14:19:04 CET] <cslcm> ls
[14:19:07 CET] <cslcm> whoops
[17:31:27 CET] <mooniac> I can't believe I can't find this with a simple web search. I want to use ffmpeg to record mike audio into a file. No video needed. Should be pretty simple I thought.
[17:41:00 CET] <CoreX> mooniac maybe spell mic correctly
[17:41:01 CET] <CoreX> http://free-tutorials.org/how-to-record-sound-from-microphone-with-ffmpeg/
[17:41:30 CET] <CoreX> or
[17:41:31 CET] <CoreX> http://www.pc-freak.net/blog/record-microphone-input-sound-good-ffmpeg/
[17:44:24 CET] <mooniac> thx
[17:54:52 CET] <rainey> when using libavresample to convert to a lesser amount of audio channels (eg stereo to mono), is it possible to specify which channel is taken?
[18:06:48 CET] <mooniac> none of them worked for me. Oh well, I'll just use OBS then, that has a pulseaudio option (audio only, not screen capture). Works great.
[18:12:22 CET] <rainey> I guess converting to mono I can just convert to stereo planar and get a pointer to whichever channel I need
[21:28:55 CET] <TheAMM> How do I get RGBA from the lafvi color input filter?
[21:29:08 CET] <TheAMM> ffmpeg -f lavfi -i "color=color=0xFFFFFF00:size=50x50" gives me yuv420p
[21:29:35 CET] <TheAMM> vf format=rgba is technically rgba, but it's just a white square, because the input doesn't have the alpha
[21:33:37 CET] <furq> TheAMM: color=...,format=yuva420p
[21:34:26 CET] <TheAMM> Thanks
[00:00:00 CET] --- Wed Nov 28 2018


More information about the Ffmpeg-devel-irc mailing list