Newest 'ffmpeg' Questions - Stack Overflow
Les articles publiés sur le site
-
can ffmpeg use actual frame number in stream instead of sequentially added image numbers
26 mars, par Wangffmpeg -i test.mp4 -vf select="eq(pict_type\,I)" %d.png
above code create file name incremental by 1, like:
1.png 2.png 3.png ...
but I want the actual frame number in the source stream:
1.png 26.png 51.png ...
there is very old thread asking the same thing. But I wonder is there a solution right now?
-
Compile FFmpeg with libfdk_aac
26 mars, par ToydorI been reading on how to convert mp3 to m4a, and found that I must compile FFmpeg if I'll use the AAC encoder, libfdk_aac.
But reading FFmpeg guide on how to compile FFmpeg with libfdk_aac makes no sense for a beginner like me.
To use libfdk_aac the encoding guide says:
Requires ffmpeg to be configured with --enable-libfdk_aac --enable-nonfree.
Where do I put those flags?
Do I put it here somewhere?:
cd ~/ffmpeg_sources git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git cd fdk-aac autoreconf -fiv ./configure --prefix="$HOME/ffmpeg_build" --disable-shared make make install make distclean
Or maybe here somewhere?
cd ~/ffmpeg_sources git clone --depth 1 git://source.ffmpeg.org/ffmpeg cd ffmpeg PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" export PKG_CONFIG_PATH ./configure --prefix="$HOME/ffmpeg_build" \ --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" \ --bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac \ --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx \ --enable-libx264 --enable-nonfree --enable-x11grab make make install make distclean hash -r
If I'm reading the compile guide right I guess that these two chunks of code is what I need to compile FFmpeg.
I'm using Ubuntu server 12.4
UPDATE
After upgrading my system to Ubuntu 16.04 I had to install ffmpeg again. I still needed libfdk-aac. Fortunately there's a good step-by-step guide at http://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu on how to compile ffmpeg.
I thought I would share how to compile if just interested in compiling ffmpeg with libfdk-aac and libmp3lame.
If you haven't already a bin in home directory:
mkdir ~/bin
Install dependencies. Didn't need the non-server packages:
sudo apt-get update sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libtheora-dev libtool libvorbis-dev pkg-config texinfo zlib1g-dev
Then install the encoders. Had to install yasm as well, otherwise I got errors when compiling.
sudo apt-get install libfdk-aac-dev sudo apt-get install libmp3lame-dev sudo apt-get install yasm
Then compile ffmpeg with needed flags
cd ~/ffmpeg_sources wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 tar xjvf ffmpeg-snapshot.tar.bz2 cd ffmpeg PATH="$HOME/bin:$PATH" PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig" ./configure \ --prefix="$HOME/ffmpeg_build" \ --pkg-config-flags="--static" \ --extra-cflags="-I$HOME/ffmpeg_build/include" \ --extra-ldflags="-L$HOME/ffmpeg_build/lib" \ --bindir="$HOME/bin" \ --enable-libass \ --enable-libfdk-aac \ --enable-libfreetype \ --enable-libtheora \ --enable-libvorbis \ --enable-libmp3lame \ --enable-nonfree \ --enable-gpl PATH="$HOME/bin:$PATH" make make install make distclean hash -r
-
ffmpeg pipe out to stdout on windows
26 mars, par JaSHinHello I need to pipe output from ffmpeg to another program. It's works on my macOs with command:
ffmpeg -i C0333.MP4 -start_number 0 -f rawvideo -pix_fmt rgb48le pipe: | rgb2dng -i - -n 0 -o 'export/test-####.dng'
I have ported rgb2dng from Unix systems to Windows. But same command doesn't work. rgb2dng used stdin to read pipe:
if (strcmp(ifn,"-")==0) { ifo = stdin; } else { ifo = fopen(ifn, "rb"); }
-
ffmpeg burned-in subtitles render in the wrong font
26 mars, par dv151Trying to burn in subtitles to a video in FFMPEG in GothamProBold font. No matter what I do it keeps reverting to Helvetica. From the console, I see that FFMPEG seems to load the font without error. Then switches over to font provider "coretext"
[Parsed_subtitles_0 @ 0x7fed054048c0] Loading font file '/Projects/Fonts/GothaProBol.otf' [Parsed_subtitles_0 @ 0x7fed054048c0] Using font provider coretext [Parsed_subtitles_0 @ 0x7fed054048c0] fontselect: (GothaProBol.otf, 400, 0) -> /System/Library/Fonts/Helvetica.ttc, -1, Helvetica
It seems like it has my font loaded, then loads what is likely a system default of Helvetica instead. My guess is that my chosen font isn't actually loading after all.
FFMPEG command (called from python) is as follows:
ffmpeg_cmd = ["ffmpeg", "-i", self.source_video_uri, "-y", "-c:v", "prores", "-profile:v", "1", "-c:a", "pcm_s16be", "-vf", f"subtitles={srt_uri}:fontsdir=/Projects/Fonts:force_style='Fontname=GothaProBol.otf'", f"{self.source_video_uri}_render.mov"] subprocess.call(ffmpeg_cmd)
Any ideas?
UPDATE: Found this setting in libass header file "ass.h" - which ffmpeg calls when using the subtitle filter. Don't know how to actually set this variable when ffmpeg calls libass, but here it is. Line 182:
* \brief Default Font provider to load fonts in libass' database * * NONE don't use any default font provider for font lookup * AUTODETECT use the first available font provider * CORETEXT force a CoreText based font provider (OS X only) * FONTCONFIG force a Fontconfig based font provider * * libass uses the best shaper available by default. */ typedef enum { ASS_FONTPROVIDER_NONE = 0, ASS_FONTPROVIDER_AUTODETECT = 1, ASS_FONTPROVIDER_CORETEXT, ASS_FONTPROVIDER_FONTCONFIG, ASS_FONTPROVIDER_DIRECTWRITE, } ASS_DefaultFontProvider;
RE: ANSWER BELOW: For the most part, it seems that if your font is installed in /System/Fonts or /Library/Fonts then CoreText can find it. Though in some cases, the naming conventions can be quite particular and non-intuitive. It also can't seem to find all fonts, necessarily.
For example: Gotham Pro Bold, in the /Library/Fonts folder on my system, file named "GothaProBol.otf" is correctly passed to fontname as: GothamPro-Bold or just Gotham Pro. Gotham Pro Bold, GothamPro, Gotham Pro-Bold, GothaProBol, and GothaProBol.otf do NOT work.
For most fonts it seems the preferred convention is {FontName}-{Style/Weight} as displayed in Mac OS's FontBook, not the filename.
That said, I have a novelty 'Game of Thrones.ttf' font in the same folder as Gotham Pro, and I can't get CoreText to connect to it under any of the above naming conventions.
-
FFMPEG - await ffmpeg.load() - overlay.ts Uncaught ReferenceError : document is not defined
26 mars, par devVue123I use FFMPEG plugin with Vue3 and Vite. My code:
<script setup>
import { FFmpeg } from '@ffmpeg/ffmpeg'
import { fetchFile, toBlobURL } from '@ffmpeg/util'
import {onMounted} from "vue";

// const baseURL = 'https://unpkg.com/@ffmpeg/core@0.12.6/dist/esm' // doc - vite
const baseURL = 'https://unpkg.com/@ffmpeg/core-mt@0.12.6/dist/esm' // example

const ffmpeg = new FFmpeg();

onMounted(() => {
 initializeFfmpeg()
})

const initializeFfmpeg = async () => {
await ffmpeg.load()
}
</script>
but FFMPEG is not initialized correctly. the error occurs when I run the command:
await ffmpeg.load()
I get an error that may be related to vite:
I tried several import options, but I still get this error. please help me, thank you
package.json
"dependencies": { "@ffmpeg/core": "^0.12.6", "@ffmpeg/ffmpeg": "0.12.6", "@ffmpeg/util": "^0.12.1", "vue": "^3.4.21" }, "devDependencies": { "@vitejs/plugin-vue": "^5.0.4", "vite": "^5.2.0" }
vite.config.js
import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import { fileURLToPath, URL } from 'node:url' // https://vitejs.dev/config/ export default defineConfig({ plugins: [vue()], resolve: { alias: { '@': fileURLToPath(new URL('./src', import.meta.url)) } }, optimizeDeps: { exclude: ["@ffmpeg/ffmpeg", "@ffmpeg/util"], }, server: { headers: { "Cross-Origin-Opener-Policy": "same-origin", "Cross-Origin-Embedder-Policy": "require-corp", }, }, })
node version:
v18.18.2
I try this too:
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') })