Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
ffmpeg : is there a fast way for extracting several thumbnails from a video without parsing the video from the beginning every time ?
18 mars, par archieI tried several ways for extracting sample frames from a video file with ffmpeg. I found out that the fastest way is by placing the following command in a loop:
ffmpeg -ss $frame_time -i "$input_video" -frames:v 1 -vf scale=256:-1 "$Work_dir/thumb$thumb_index.jpg"
(I have omitted the parts of the command that are not relevant to the question, such as drawtext, hide_banner, loglevel). The variables frame_time and thumb_index are initialized before the loop and incremented by a fixed amount at every step: +1 for thumbs_index and $duration/25 for frame_time. I read in the ffmpeg documentation (https://trac.ffmpeg.org/wiki/Seeking) that having the -ss part before the -i part is very fast because the input is parsed by keyframe. For the same reason, the loop containing the command above is also much faster than commands based on "-vf fps=$thumbs_number/$duration".
In fact, the code works pretty well. However, I can't escape a feeling of programming discomfort, because ffmpeg is called several times for each video file, and every time it has to parse the file from the beginning. I mean, if I had a function doing the same as the command above — it would parse a video from the beginning to search for a frame at a certain time — calling it n times to extract a regular sequence of n frames would be bad programming. I should change the function to parse the video file once and get all the frames I need in a single pass.
My question is: is there a fast way for having ffmpeg parse a video file a single time, searching by keyframes and extracting a given number of frames at a given distance from one another? I am ready to take No for an answer, but one who is deeper into ffmpeg than I am might know a way. Thanks
-
How to implement FFMPEG retry logic [closed]
18 mars, par M9AI am recording a live stream using the following code:
ffmpeg -i
-c copy output.mp4 This works fine for occasions where the stream is segmented in the sense that it will retry if the stream drops. However if the url no longer exists or returns a code such as 403, it will still retry, resulting in an infinite loop of retrying when the stream doesnt exist.
How can I retry for segments but maybe retry only a few times for page errors?
-
Loading a larger file with ffmpeg crashes on safari mobile
17 mars, par developer1My use case is to extract audio from video file to minimize the size of sent file over network. Everything works fine on a computer (chrome, safari) but it's either stuck or crashes on ios safari. AFAIK it crashes not while executing the ffmpeg command, but while trying to load the input file, which is quite big (500MB+).
I load the ffmpeg like this:
const baseURL = "https://unpkg.com/@ffmpeg/core-mt@0.12.6/dist/esm"; await ffmpeg.load({ coreURL: await toBlobURL(`${baseURL}/ffmpeg-core.js`, "text/javascript"), wasmURL: await toBlobURL(`${baseURL}/ffmpeg-core.wasm`, "application/wasm"), workerURL: await toBlobURL( `${baseURL}/ffmpeg-core.worker.js`, "text/javascript" ), });
And I try to load the file like this:
await ffmpeg.writeFile(inputFileName, await fetchFile(file));
But it does not go past this step. How can I work around this limitation? Is there any other way to load larger files?
Thank you.
-
Convert .flac to .mp3 with ffmpeg, keeping all metadata
17 mars, par Vito GentileHow can I convert .flac to .mp3 with ffmpeg, keeping all metadata (that is converting Vorbis comment in .flac files to ID3v2 metadata of .mp3)?
-
FFMPEG : Invalid data found when processing input
16 mars, par SchülerI am unable to upload mp3 or mp4 is there any specific path format? Here is my code. I have tried this also
ffmpeg -i Video/" + Name + " -ss 01:30 -r 1 -an -vframes 1 -f mjpeg Video/" + Name + ".jpg
exec("ffmpeg -y -i Video/" + Name + " -map_metadata -1 -ab 192k Video/" + Name + ".jpg", function(err) { if (err) {console.log(err)} console.log('Done', {'Image' : 'Video/' + Name + '.jpg'}); });
Here is the error
{ Error: Command failed: ffmpeg -y -i Video/ac9358e25dd41a69e95a72d3e71e4881 -map_metadata -1 -ab 192k Video/ac9358e25dd41a69e95a72d3e71e4881.jpg ffmpeg version 4.1.1 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 8.2.1 (GCC) 20190212 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth libavutil 56. 22.100 / 56. 22.100 libavcodec 58. 35.100 / 58. 35.100 libavformat 58. 20.100 / 58. 20.100 libavdevice 58. 5.100 / 58. 5.100 libavfilter 7. 40.101 / 7. 40.101 libswscale 5. 3.100 / 5. 3.100 libswresample 3. 3.100 / 3. 3.100 libpostproc 55. 3.100 / 55. 3.100 Video/ac9358e25dd41a69e95a72d3e71e4881: Invalid data found when processing input at ChildProcess.exithandler (child_process.js:275:12) at emitTwo (events.js:126:13) at ChildProcess.emit (events.js:214:7) at maybeClose (internal/child_process.js:925:16) at Socket.stream.socket.on (internal/child_process.js:346:11) at emitOne (events.js:116:13) at Socket.emit (events.js:211:7) at Pipe._handle.close [as _onclose] (net.js:557:12) killed: false, code: 1, signal: null, cmd: 'ffmpeg -y -i Video/ac9358e25dd41a69e95a72d3e71e4881 -map_metadata -1 -ab 192k Video/ac9358e25dd41a69e95a72d3e71e4881.jpg' }