Re: [FFmpeg-user] Read from pulseaudio - latency - how to fix!
On 01-09-2022 17:06, Thomas Seilund via ffmpeg-user wrote: Dear All I do live streaming and I need to pick up the audio from a microphone. I test latency like this: ffplay -f pulse -i "alsa_input.usb-Remo_Tech_Co.__Ltd._OBSBOT_Tiny-02.analog-mono" ffplay -f alsa -i default After running one of the commands I can hear my own voice in my headphones. I am happy. But the first command gives a delay of 3 sec. The other command gives close to no delay. How can I fix the first command to get close to no delay? Both command records from the same microphone and output to the same headphones. What I see is that the black screen from ffplay takes about 3 sec to display with the first command but shows up close to instantly with the second command. Here is output from the two commands: ffplay -f pulse -acodec pcm_s16le -i "alsa_input.usb-Remo_Tech_Co.__Ltd._OBSBOT_Tiny-02.analog-mono" ffplay version N-104384-g374f2ac370 Copyright (c) 2003-2021 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --enable-libfreetype --enable-libx264 --enable-gpl --enable-libvorbis --enable-libvpx --enable-libmp3lame --enable-libzmq --enable-libpulse libavutil 57. 7.100 / 57. 7.100 libavcodec 59. 12.100 / 59. 12.100 libavformat 59. 6.100 / 59. 6.100 libavdevice 59. 0.101 / 59. 0.101 libavfilter 8. 14.100 / 8. 14.100 libswscale 6. 1.100 / 6. 1.100 libswresample 4. 0.100 / 4. 0.100 libpostproc 56. 0.100 / 56. 0.100 Input #0, pulse, from 'alsa_input.usb-Remo_Tech_Co.__Ltd._OBSBOT_Tiny-02.analog-mono': Duration: N/A, start: 1662044141.069410, bitrate: 1536 kb/s Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s 1662044142.91 M-A: -0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0 ffplay -f alsa -i default ffplay version N-104384-g374f2ac370 Copyright (c) 2003-2021 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --enable-libfreetype --enable-libx264 --enable-gpl --enable-libvorbis --enable-libvpx --enable-libmp3lame --enable-libzmq --enable-libpulse libavutil 57. 7.100 / 57. 7.100 libavcodec 59. 12.100 / 59. 12.100 libavformat 59. 6.100 / 59. 6.100 libavdevice 59. 0.101 / 59. 0.101 libavfilter 8. 14.100 / 8. 14.100 libswscale 6. 1.100 / 6. 1.100 libswresample 4. 0.100 / 4. 0.100 libpostproc 56. 0.100 / 56. 0.100 Input #0, alsa, from 'default': 0KB vq= 0KB sq= 0B f=0/0 Duration: N/A, start: 1662044161.792616, bitrate: 1536 kb/s Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s 1662044163.53 M-A: 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0 Regards Thomas S Simple, the first command uses pulseaudio which is userspace to read from alsa which is in kernelspace. The second command bypasses userspace to read directly from alsa therefor has less latency. Pulseaudio is not known for its low latency, if you need to use a sound server in userspace with low latency use jack. ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Guidance on debugging a potential memory leak
On 9/1/22 13:26, Carl Eugen Hoyos wrote: Am Do., 1. Sept. 2022 um 21:16 Uhr schrieb Jorge Villatoro via ffmpeg-user : If you'd like to call it something else that's fine with me, but it's clear that the memory usage of the process escalates over time Which is not unusual for applications writing multimedia files. massif (another memcheck tool) allows you to see which functions allocate the memory. I can recommend heaptrack https://milianw.de/blog/heaptrack-a-heap-memory-profiler-for-linux.html ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Guidance on debugging a potential memory leak
Am Do., 1. Sept. 2022 um 21:16 Uhr schrieb Jorge Villatoro via ffmpeg-user : > > If you'd like to call it something else that's fine with me, but it's clear > that the memory usage of the process escalates over time Which is not unusual for applications writing multimedia files. massif (another memcheck tool) allows you to see which functions allocate the memory. Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Guidance on debugging a potential memory leak
On Thu, Sep 1, 2022 at 11:24 AM Carl Eugen Hoyos wrote: > Am Do., 1. Sept. 2022 um 19:07 Uhr schrieb Jorge Villatoro via > ffmpeg-user : > > > I've tried running valgrind on this process for a while but I'm not > really > > sure how to decipher the results other than that there doesn't appear to > be > > an obvious leak. > > If valgrind does not show a memory there is no memory leak. > If you'd like to call it something else that's fine with me, but it's clear that the memory usage of the process escalates over time with this configuration and does not in my other configurations. Whether you'd refer it to a memory leak I guess could be a semantic argument. It seems possible that something is holding a bunch of references unintentionally for example, which I'd consider a memory leak and which valgrind may not detect if those references are still cleaned up properly at program exit. In any case the usage is high enough in some cases that the process has to be restarted to avoid running the host out of memory. Any guidance someone here might have on how to track this "memory usage escalation" down would still be very appreciated :) > > A process may need more memory over time but that is not a leak. > > Carl Eugen > ___ > ffmpeg-user mailing list > ffmpeg-user@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > > To unsubscribe, visit link above, or email > ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Guidance on debugging a potential memory leak
On 9/1/2022 11:24 AM, Carl Eugen Hoyos wrote: If valgrind does not show a memory there is no memory leak. Probably; the tool is generally considered reliable but "never say never" (this is why we test the testing tools). A process may need more memory over time but that is not a leak. True. OTOH it may fail to dealloc memory as appropriate; to quote from https://stackoverflow.com/questions/7726345/valgrind-doesnt-detect-any-memory-leaks-how-safe-is-that === You need to distinguish between memory leaks (memory that was allocated, but you lost all references to) and memory hogs (memory that was allocated, that you keep references to, but forgot to deallocate). The later one can not be detected by valgrind, since valgrind doesn't know you did not want to use it anymore. === Some people consider both to be "leaks". Since it sounds like the OP is monitoring while ffmpeg is running, it could well be a failure-to-dealloc issue. Later, z! ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Guidance on debugging a potential memory leak
Am Do., 1. Sept. 2022 um 19:07 Uhr schrieb Jorge Villatoro via ffmpeg-user : > I've tried running valgrind on this process for a while but I'm not really > sure how to decipher the results other than that there doesn't appear to be > an obvious leak. If valgrind does not show a memory there is no memory leak. A process may need more memory over time but that is not a leak. Carl Eugen ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-user] Guidance on debugging a potential memory leak
Hi, I believe that I've stumbled across a slow memory leak in the QSV encoder, or possibly the underlying library I'm not really sure. I've been able to see a slow leak (~50MB/hr in the worst case) in ffmpeg processes performing an QSV encode where an identical configuration running a CUDA encode has stable memory usage. The command I am using looks something like this: ffmpeg -loglevel error -nostdin -hide_banner -progress pipe:3 -y -rtsp_transport tcp -reorder_queue_size 1000 -max_delay 200 -allowed_media_types video -hwaccel qsv -c:v h264_qsv -i -vf setpts=(PTS-STARTPTS)+RTCSTART/(TB*100),vpp_qsv=framerate=5:w=720:h=in_h/in_w*w -an -enc_time_base 1:1000 -c:v hevc_qsv -g 50 -b:v 500k -maxrate 2000k -f matroska - I've tried running valgrind on this process for a while but I'm not really sure how to decipher the results other than that there doesn't appear to be an obvious leak. There are quite a few messages about uninitialized values in (/usr/lib/x86_64-linux-gnu/dri/iHD_drv_video.so) but I think these might be false positives. Would anyone here have any guidance as far as where to look/who to ask on this? Has anyone else here attempted to use hevc_qsv for a streaming use case with long-lived processes? --Jorge ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-user] Read from pulseaudio - latency - how to fix!
Dear All I do live streaming and I need to pick up the audio from a microphone. I test latency like this: ffplay -f pulse -i "alsa_input.usb-Remo_Tech_Co.__Ltd._OBSBOT_Tiny-02.analog-mono" ffplay -f alsa -i default After running one of the commands I can hear my own voice in my headphones. I am happy. But the first command gives a delay of 3 sec. The other command gives close to no delay. How can I fix the first command to get close to no delay? Both command records from the same microphone and output to the same headphones. What I see is that the black screen from ffplay takes about 3 sec to display with the first command but shows up close to instantly with the second command. Here is output from the two commands: ffplay -f pulse -acodec pcm_s16le -i "alsa_input.usb-Remo_Tech_Co.__Ltd._OBSBOT_Tiny-02.analog-mono" ffplay version N-104384-g374f2ac370 Copyright (c) 2003-2021 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --enable-libfreetype --enable-libx264 --enable-gpl --enable-libvorbis --enable-libvpx --enable-libmp3lame --enable-libzmq --enable-libpulse libavutil 57. 7.100 / 57. 7.100 libavcodec 59. 12.100 / 59. 12.100 libavformat 59. 6.100 / 59. 6.100 libavdevice 59. 0.101 / 59. 0.101 libavfilter 8. 14.100 / 8. 14.100 libswscale 6. 1.100 / 6. 1.100 libswresample 4. 0.100 / 4. 0.100 libpostproc 56. 0.100 / 56. 0.100 Input #0, pulse, from 'alsa_input.usb-Remo_Tech_Co.__Ltd._OBSBOT_Tiny-02.analog-mono': Duration: N/A, start: 1662044141.069410, bitrate: 1536 kb/s Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s 1662044142.91 M-A: -0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0 ffplay -f alsa -i default ffplay version N-104384-g374f2ac370 Copyright (c) 2003-2021 the FFmpeg developers built with gcc 8 (Debian 8.3.0-6) configuration: --enable-libfreetype --enable-libx264 --enable-gpl --enable-libvorbis --enable-libvpx --enable-libmp3lame --enable-libzmq --enable-libpulse libavutil 57. 7.100 / 57. 7.100 libavcodec 59. 12.100 / 59. 12.100 libavformat 59. 6.100 / 59. 6.100 libavdevice 59. 0.101 / 59. 0.101 libavfilter 8. 14.100 / 8. 14.100 libswscale 6. 1.100 / 6. 1.100 libswresample 4. 0.100 / 4. 0.100 libpostproc 56. 0.100 / 56. 0.100 Input #0, alsa, from 'default': 0KB vq= 0KB sq= 0B f=0/0 Duration: N/A, start: 1662044161.792616, bitrate: 1536 kb/s Stream #0:0: Audio: pcm_s16le, 48000 Hz, 2 channels, s16, 1536 kb/s 1662044163.53 M-A: 0.000 fd= 0 aq= 0KB vq= 0KB sq= 0B f=0/0 Regards Thomas S ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
[FFmpeg-user] Read from pulseaudio - latency - how to fix!
Dear All I do live streaming and I need to pick up the audio from a microphone. I test latency like this: ffplay -f pulse -i "alsa_input.usb-Remo_Tech_Co.__Ltd._OBSBOT_Tiny-02.analog-mono" ffplay -f alsa -i default After running one of the commands I can hear my own voice in my headphones. I am happy. But the first command gives a delay of 3 sec. The other command gives close to no delay. How can I fix the first command to get close to no delay? Both command records from the same microphone and output to the same headphones. What I see is that the black screen from ffplay takes about 3 sec to display with the first command but shows up close to instantly with the second command. Regards Thomas S ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Need to Convert MP4 (or MKV) with AAC *and* AC-3 Audio to Multi-Rendition HLS (each with *both* audio streams)
Thank you Moritz! I will apply your advice and report back! On Thu, Sep 1, 2022, 02:26 Moritz Barsnick wrote: > Hi Clay, > > On Tue, Aug 30, 2022 at 18:51:13 -0400, Clay wrote: > > If you have a better way to achieve this, I am ***all ears***. > > Here is the code I have so far: > > I think you need to fix your command line in various places: > > > ffmpeg -i ../InputFile-1920x804-24f.mp4 \ > > -filter_complex "[0:v]split=4[v1][v2][v3][v4]; [v1]copy[v1out]; > > [v2]scale=w=1280:h=536[v2out]; [v3]scale=w=720:h=300[v3out]; > > [v4]scale=w=480:h=200[v4out]"\ > > -map [v1out] -c:v:0 libx264 -x264-params -b:v:0 -maxrate:v:0 4M > > "-x264-params" needs an argument - that's missing here. > "-b:v:0" needs an argument - that's missing here. > > And for bash's sake, I believe you need to quote "[v1out]" and the > similar ones below (but I may be overambitious here). > > > -minrate:v:0 4M -bufsize:v:0 4M -crf 17 -preset slower -g 48 > > -sc_threshold 0 -keyint_min 48 \ > > -map [v2out] -c:v:1 libx264 -x264-params -b:v:1 -maxrate:v:1 3M > > -minrate:v:1 3M -bufsize:v:1 3M -crf 17 -preset slower -g 48 > > -sc_threshold 0 -keyint_min 48 \ > > -map [v3out] -c:v:2 libx264 -x264-params -b:v:2 -maxrate:v:2 2M > > -minrate:v:2 2M -bufsize:v:2 2M -crf 17 -preset slower -g 48 > > -sc_threshold 0 -keyint_min 48 \ > > -map [v4out] -c:v:3 libx264 -x264-params -b:v:3 -maxrate:v:3 1M > > -minrate:v:3 1M -bufsize:v:3 1M -crf 17 -preset slower -g 48 > > -sc_threshold 0 -keyint_min 48 \ > > -map 0:a -c:a:0 \ > > -map 0:a -c:a:1 \ > > -map 0:a -c:a:2 \ > > -map 0:a -c:a:3 \ > > "-c:a:x" needs an argument. > > > -f hls \ > > -hls_time 2 \ > > -hls_playlist_type vod \ > > -hls_flags independent_segments \ > > -hls_segment_type mpegts \ > > -hls_segment_filename OutputFile_%v/data%02d.ts \ > > -master_pl_name master.m3u8 \ > > -var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2 v:3,a:3"OutputFile_%v.m3u8 > > > This code breaks when I attempt to run it, giving the following error: > > [NULL @ 0x55f0357bbd40] Unable to find a suitable output format for '0:a' > > 0:a: Invalid argument > > Probably because ffmpeg's whole option parsing is messed up due to your > missing arguments. > > > I have tried many varieties of the audio stream mapping... 0:a, a:0, > > a:0:1.. etc. > > And this is not the actual issue. > > Cheers, > Moritz > ___ > ffmpeg-user mailing list > ffmpeg-user@ffmpeg.org > https://ffmpeg.org/mailman/listinfo/ffmpeg-user > > To unsubscribe, visit link above, or email > ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe". > ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [FFmpeg-user] Need to Convert MP4 (or MKV) with AAC *and* AC-3 Audio to Multi-Rendition HLS (each with *both* audio streams)
Hi Clay, On Tue, Aug 30, 2022 at 18:51:13 -0400, Clay wrote: > If you have a better way to achieve this, I am ***all ears***. > Here is the code I have so far: I think you need to fix your command line in various places: > ffmpeg -i ../InputFile-1920x804-24f.mp4 \ > -filter_complex "[0:v]split=4[v1][v2][v3][v4]; [v1]copy[v1out]; > [v2]scale=w=1280:h=536[v2out]; [v3]scale=w=720:h=300[v3out]; > [v4]scale=w=480:h=200[v4out]"\ > -map [v1out] -c:v:0 libx264 -x264-params -b:v:0 -maxrate:v:0 4M "-x264-params" needs an argument - that's missing here. "-b:v:0" needs an argument - that's missing here. And for bash's sake, I believe you need to quote "[v1out]" and the similar ones below (but I may be overambitious here). > -minrate:v:0 4M -bufsize:v:0 4M -crf 17 -preset slower -g 48 > -sc_threshold 0 -keyint_min 48 \ > -map [v2out] -c:v:1 libx264 -x264-params -b:v:1 -maxrate:v:1 3M > -minrate:v:1 3M -bufsize:v:1 3M -crf 17 -preset slower -g 48 > -sc_threshold 0 -keyint_min 48 \ > -map [v3out] -c:v:2 libx264 -x264-params -b:v:2 -maxrate:v:2 2M > -minrate:v:2 2M -bufsize:v:2 2M -crf 17 -preset slower -g 48 > -sc_threshold 0 -keyint_min 48 \ > -map [v4out] -c:v:3 libx264 -x264-params -b:v:3 -maxrate:v:3 1M > -minrate:v:3 1M -bufsize:v:3 1M -crf 17 -preset slower -g 48 > -sc_threshold 0 -keyint_min 48 \ > -map 0:a -c:a:0 \ > -map 0:a -c:a:1 \ > -map 0:a -c:a:2 \ > -map 0:a -c:a:3 \ "-c:a:x" needs an argument. > -f hls \ > -hls_time 2 \ > -hls_playlist_type vod \ > -hls_flags independent_segments \ > -hls_segment_type mpegts \ > -hls_segment_filename OutputFile_%v/data%02d.ts \ > -master_pl_name master.m3u8 \ > -var_stream_map "v:0,a:0 v:1,a:1 v:2,a:2 v:3,a:3"OutputFile_%v.m3u8 > This code breaks when I attempt to run it, giving the following error: > [NULL @ 0x55f0357bbd40] Unable to find a suitable output format for '0:a' > 0:a: Invalid argument Probably because ffmpeg's whole option parsing is messed up due to your missing arguments. > I have tried many varieties of the audio stream mapping... 0:a, a:0, > a:0:1.. etc. And this is not the actual issue. Cheers, Moritz ___ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user To unsubscribe, visit link above, or email ffmpeg-user-requ...@ffmpeg.org with subject "unsubscribe".