Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
How to initialize video decoder with a already decoded frame ?
27 mars, par Ragdoll CarLet's say I have an FFmpeg video decoder x264 initially initialized with some parameters. I am using C++ in my scenario. In normal conditions we push an encoded I-frame into such decoder and then referencing encoded P-frames.
I have a special case where my I-frame is already decoded. So in my case I want to:
- push already decoded I-frame into my decoder
- push referencing encoded P-frames into my decoder
How can I initialize the decoder state with already decoded I-frame? Currently to bypass these limitations I have to:
- create a new temporary encoder
- encode already decoded I-frame
- decode encoded I-frame
- and then I am able to push referencing encoded P-frames
-
Audio delay after resuming FFmpeg on Windows
27 mars, par Iman SajadpurI'm building a screen recording software for Windows using Python. I use FFmpeg for recording and psutil to pause and resume the process.
Here is a sample of my code:
import psutil import subprocess process = subprocess.Popen([ 'ffmpeg', '-y', '-rtbufsize', '100M', '-f', 'gdigrab', '-thread_queue_size', '1024', '-probesize', '50M', '-r', '24', '-draw_mouse', '1', '-video_size', '1920x1080', '-i', 'desktop', '-f', 'dshow', '-channel_layout', 'stereo', '-thread_queue_size', '1024', '-i', 'audio=Microphone (2- High Definition Audio Device)', # my audio device '-c:v', 'h264_nvenc', # encoding via Nvidia '-r', '24', '-preset', 'p1', '-pix_fmt', 'yuv444p', '-fps_mode', 'cfr', '-c:a', 'aac', '-ac', '2', '-b:a', '128k', 'output.mp4']) ffmpeg_proc = psutil.Process(process.pid) # pause ffmpeg_proc.suspend() # resume ffmpeg_proc.resume()
The issue is that after resuming, the audio becomes choppy and delayed, while the video continues smoothly.
I have tried using following flags, but they didn't solve the issue:
-analyzeduration -fflags +genpts -async -use_wallclock_as_timestamps -af aresample=async=1
How can I properly pause and resume FFmpeg without causing audio delay? Is there any other method to handle this properly?
Thanks for any suggestions.
-
using FFMPEG with silencedetect to remove audio silence
27 mars, par ZahliiI am trying to use the following command with the latest ffmpeg build to remove silence from my .mp3 files:
ffmpeg -i SILENCE.mp3 -af silencedetect=n=-50dB:d=1 -y -ab 192k SILENCE_OUT.mp3
However, the following output is produced:
ffmpeg version N-66154-g1654ca7 Copyright (c) 2000-2014 the FFmpeg developers built on Sep 5 2014 22:10:38 with gcc 4.8.3 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca -- enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable- libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib libavutil 54. 7.100 / 54. 7.100 libavcodec 56. 1.100 / 56. 1.100 libavformat 56. 4.100 / 56. 4.100 libavdevice 56. 0.100 / 56. 0.100 libavfilter 5. 1.100 / 5. 1.100 libswscale 3. 0.100 / 3. 0.100 libswresample 1. 1.100 / 1. 1.100 libpostproc 53. 0.100 / 53. 0.100 Input #0, mp3, from 'SILENCE.mp3': Metadata: title : Snowblind (Featuring Tasha Baxter) artist : Au5 album : Snowblind (Featuring Tasha Baxter) genre : Electronica performer : Au5 track : 1/1 date : 2014 album_artist : Au5,Tasha Baxter major_brand : mp42 minor_version : 0 compatible_brands: isommp42 encoder : Lavf55.42.100 Duration: 00:05:50.80, start: 0.025057, bitrate: 192 kb/s Stream #0:0: Audio: mp3, 44100 Hz, stereo, s16p, 192 kb/s Output #0, mp3, to 'SILENCE_OUT.mp3': Metadata: TIT2 : Snowblind (Featuring Tasha Baxter) TPE1 : Au5 TALB : Snowblind (Featuring Tasha Baxter) TCON : Electronica TPE3 : Au5 TRCK : 1/1 TDRL : 2014 TPE2 : Au5,Tasha Baxter major_brand : mp42 minor_version : 0 compatible_brands: isommp42 TSSE : Lavf56.4.100 Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, s16p, 192 kb/s Metadata: encoder : Lavc56.1.100 libmp3lame Stream mapping: Stream #0:0 -> #0:0 (mp3 (native) -> mp3 (libmp3lame)) Press [q] to stop, [?] for help [silencedetect @ 0000000004398f40] silence_start: -0.00628118 [silencedetect @ 0000000004398f40] silence_end: 3.21413 | silence_duration: 3.22 041 [silencedetect @ 0000000004398f40] silence_start: 343.844 [libmp3lame @ 00000000043b2940] Trying to remove 1152 samples, but the queue is empty size= 8223kB time=00:05:50.79 bitrate= 192.0kbits/s video:0kB audio:8222kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.011485%
The generated audio file however still has the original length without any silence removed. See the following images:
Any help is appreciated!
EDIT: Alright, silence detect is only DETECTING the silence. Not removing it. I will try to post a solution for this.
-
How can I remove silence from an MP3 programmatically ?
27 mars, par Benjamin OakesI have MP3 files that sometimes have silence at the end. I would like to remove this silence automatically. From what I can tell, it is "perfect" silence (0 amplitude), not background noise. The length of the content and the silence varies.
I found some other questions about cropping to the first 30 seconds or cropping to X and X+N seconds using
ffmpeg
. I would think I could use a similar approach, as long as I have a way to find when the silence starts. How would I do that programatically?For example, one possible solution would be to have a command that finds the beginning of the "silence". I'd expect a sequence like this
end=$(ffmpeg some-command-to-find-start-of-silence) ffmpeg -t "$end" -acodec copy -i inputfile.mp3 outputfile.mp3
The solution does not have to use
ffmpeg
, but it does need to be available on Ubuntu. -
Rewrite video with ffmpeg with given non-equidistant times for each frame
27 mars, par Aleph0In one of my projects it is necessary to synchronize a video with a different datasource. I already have the video as a mts file.
I also exactly know which frame will be displayed at which time. This times are not necessarily equidistant.
For simplicity assume that my video consists just out of 5 frames:
Frame No Time 1 1s 2 3s 3 5s 4 8s 5 12s What kind of ffmpeg command using a list of times give by a simple text file can be used to create a video stream with non-equidistant frames with the given times.