FFmpeg: Difference between revisions
No edit summary |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 250: | Line 250: | ||
Add a background to transparent images.<br> | Add a background to transparent images.<br> | ||
<pre> | <pre> | ||
ffmpeg -i in.mov -filter_complex | ffmpeg -i in.mov -filter_complex "[0]format=pix_fmts=yuva420p,split=2[bg][fg];[bg]drawbox=c=white@1:replace=1:t=fill[bg];[bg][fg]overlay=format=auto" -c:a copy new.mov | ||
</pre> | </pre> | ||
Line 356: | Line 354: | ||
==JavaScript API== | ==JavaScript API== | ||
To use FFmpeg in a browser, see [https://ffmpegwasm. | To use FFmpeg in a browser, see [https://ffmpegwasm.netlify.app/ ffmpegwasm]. | ||
This is used in https://davidl.me/apps/media/index.html. | |||
==My Preferences== | ==My Preferences== | ||
My preferences for encoding video | My preferences for encoding video | ||
===AV1=== | |||
Prefer AV1 for encoding video on on modern devices. | |||
===H265/HEVC=== | ===H265/HEVC=== | ||
H264/HEVC is | H264/HEVC is now a good tradeoff between size, quality, and compatibility. | ||
This has been supported on devices since Android 5.0 (2014). | |||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
ffmpeg -i $1 -c:v libx265 -crf 23 -preset slow -pix_fmt yuv444p10le -c:a libopus -b:a 128K $2 | ffmpeg -i $1 -c:v libx265 -crf 23 -preset slow -pix_fmt yuv444p10le -c:a libopus -b:a 128K $2 | ||
</syntaxhighlight> | </syntaxhighlight> | ||
;Notes | ;Notes | ||
* The pixel format <code>yuv444p10le</code> is 10 bit color without chroma subsampling. If your source is lower, you can use <code>yuv420p</code> instead for 8-bit color and 4:2:0 chroma subsampling. | * The pixel format <code>yuv444p10le</code> is 10 bit color without chroma subsampling. If your source is lower, you can use <code>yuv420p</code> instead for 8-bit color and 4:2:0 chroma subsampling. | ||
=== | ===H264=== | ||
If you need compatability with very old and low end devices. | |||
<syntaxhighlight lang="bash"> | |||
ffmpeg -i $1 -c:v libx264 -crf 28 -preset medium -pix_fmt yuv420p -c:a libfdk_aac -b:a 128K $2 | |||
</syntaxhighlight> | |||
===Opus=== | |||
For streaming: | |||
<syntaxhighlight lang="bash"> | |||
ffmpeg -i input.wav -c:a libopus -b:a 96k output.opus | |||
</syntaxhighlight> | |||
See https://wiki.xiph.org/Opus_Recommended_Settings |