淘宝客做二级域名网站,免费游戏打开就能玩,门户网站 架构,建设公司网站意义文章目录 ffmpeg安装、配置java运行报错 Cannot run program ffmpeg ffmpeg命令mp4转为swf示例 ### ffmpeg -i input.mkv -b:v 600 -c:v libx264 -vf scale1920:1080 -crf 10 -ar 48000 -r 24 output.swfmkv转为swf示例 其他文档命令参数简介 需要将mp4转换为swfffmpeg ffmpeg命令mp4转为swf示例 ### ffmpeg -i input.mkv -b:v 600 -c:v libx264 -vf scale1920:1080 -crf 10 -ar 48000 -r 24 output.swfmkv转为swf示例 其他文档命令参数简介 需要将mp4转换为swf网上有很多软件不是收费就是功能不全要不就是分辨率比例不满足要求。突然想到实在不行就自己开发个谁让自己是程序员呢。 ffmpeg安装、配置
不是只写程序就行需要先安装ffpmeg。
下载地址 https://www.gyan.dev/ffmpeg/builds/#release-builds # 下载zip包就行
然后配置环境变量在path中添加即可。 ffmpeg.exe所在的目录就是要添加到path中的路径。如 D:\Program Files\ffmpeg\ffmpeg-7.0.1-essentials_build\bin
打开cmd输入ffmpeg -h 命令试下是否可以了。
注git bash命令行最好也添加下。
java运行报错 Cannot run program “ffmpeg”
Cannot run program “ffmpeg -i d:\swf\input.mp4 -vcodec libx264 -f flv d:\swf\output.swf”: CreateProcess error2, 系统找不到指定的文件
解决方案 1、ffmpeg已安装且环境变量已配置。 2、git bash的安装路径下也添加bin下的3个exe。
但还是报错这就怪了。
ffmpeg命令
初衷原本是想用java开发的后来发现直接用命令就可以那应该比java更方便。
这里特别强调下ffmpeg是个非常强大的命令里面知识特别多如果连扩展也算上如ffmpeg-allffplay。那么知识就更多了要花太多的时间。 想要用好这个命令对视频音频各种编码还需要有一定认知一般人都不太懂这个。 所以我们会用几个常用命令能实现简单转换就够了。
命令模板
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...ffmpeg -version # 查看版本 ffmpeg -h # 帮助
以下表格内三种写法是等价的
音频视频字幕-codec:a-codec:v-codec:s-c:a-c:v-c:s-acodec-vcodec-scodec
①、主要命令选项 -f fmt (input/output) 指定输入或者输出文件格式封装格式视频容器。常规可省略而使用依据扩展名文件的前几百 K 的内容智能分析的自动指定但一些选项需要强制明确设定。 -i filenameinput 指定输入文件。 -yglobal默认自动覆盖输出文件而不再询问确认。 -n global不覆盖输出文件如果输出文件已经存在则立即退出。 -t duration input/output限制输入/输出的时间。如果是在 -i 前面就是限定从输入中读取多少时间的数据如果是用于限定输出文件则表示写入多少时间数据后就停止。duration 可以是以秒为单位的数值或者 hh:mm:ss.xxx 格式的时间值。注意 -to 和 -t 是互斥的-t 有更高优先级。 -to position (output) 只写入 position 时间后就停止position 可以是以秒为单位的数值或者 hh:mm:ss.xxx 格式的时间值。注意 -to 和 -t 是互斥的-t 有更高优先级。 -ss position (input/output)当在 -i 前表示定位输入文件到 position 指定的位置。注意可能一些格式是不支持精确定位的所以 ffmpeg 可能是定位到最接近 position在之前的可定位点。position 可以是以秒为单位的数值或者 hh:mm:ss.xxx 格式的时间值。 -codec[:stream_specifier] codec (input/output,per-stream) 为特定的文件选择编/解码模式对于输出文件就是编码器 对于输入或者某个流就是解码器。选项参数中 codec 是编解码器的名字或者是 copy仅对输出文件则意味着流数据直接复制而不再编码。 使用下面命令可以检测 ffmepg 所支持的所有编码器的格式
ffmpeg -encoders # 查看所支持的所有编码器的格式内容太多不列出了还是那句话ffmpeg是个比较专业的东西
mp4转为swf示例
ffmpeg -i input.mp4 -vcodec copy -f flv output.swf
参数说明
-i input.mp4 指定输入文件。
-vcodec copy 表示复制视频编解码器数据。
-f flv 指定输出格式为FLV因为SWF通常通过FLV容器格式传输视频。### ffmpeg -i input.mkv -b:v 600 -c:v libx264 -vf scale1920:1080 -crf 10 -ar 48000 -r 24 output.swf
报错 SWF muxer only supports VP6, FLV, Flash Screen Video, P NG and MJPEG
mkv转为swf示例
ffmpeg -i input.mkv -c:v flashvideo -c:a flashaudio -f flash output.swf
在这个命令中
-i input.mkv 指定输入文件。
-c:v flashvideo 指定视频编码器为flashvideo这是SWF格式支持的视频编码器之一。
-c:a flashaudio 指定音频编码器为flashaudio这是SWF格式支持的音频编码器之一。
-f flash 指定输出格式为SWF。
output.swf 是输出文件的名称。请注意确保你的FFmpeg版本支持你想要使用的编码器。如果你的版本不支持这些编码器你可能需要使用其他编码器或者升级你的FFmpeg。其他
文档
官网文档 https://ffmpeg.org/ffmpeg.html
这个是文档详细描述页 https://ffmpeg.org/documentation.html
比较不错的文章 FFmpeg常用命令行讲解及实战一
命令参数简介
ffmpeg -h返回的内容
ffmpeg -h
返回
ffmpeg version 7.0.1-essentials_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developersbuilt with gcc 13.2.0 (Rev5, Built by MSYS2 project)configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-zlib --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-sdl2 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxvid --enable-libaom --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libgme --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libtheora --enable-libvo-amrwbenc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-librubberbandlibavutil 59. 8.100 / 59. 8.100libavcodec 61. 3.100 / 61. 3.100libavformat 61. 1.100 / 61. 1.100libavdevice 61. 1.100 / 61. 1.100libavfilter 10. 1.100 / 10. 1.100libswscale 8. 1.100 / 8. 1.100libswresample 5. 1.100 / 5. 1.100libpostproc 58. 1.100 / 58. 1.100
Universal media converter
usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...Getting help:-h -- print basic options-h long -- print more options-h full -- print all options (including all format and codec specific options, very long)-h typename -- print all options for the named decoder/encoder/demuxer/muxer/filter/bsf/protocolSee man ffmpeg for detailed description of the options.Per-stream options can be followed by :stream_spec to apply that option to specific streams only. stream_spec can be a stream index, or v/a/s for video/audio/subtitle (see manual for full syntax).Print help / information / capabilities:
-L show license
-h topic show help
-version show version
-muxers show available muxers
-demuxers show available demuxers
-devices show available devices
-decoders show available decoders
-encoders show available encoders
-filters show available filters
-pix_fmts show available pixel formats
-layouts show standard channel layouts
-sample_fmts show available audio sample formatsGlobal options (affect whole program instead of just one file):
-v loglevel set logging level
-y overwrite output files
-n never overwrite output files
-stats print progress report during encodingPer-file options (input and output):
-f fmt force container format (auto-detected otherwise)
-t duration stop transcoding after specified duration
-to time_stop stop transcoding after specified time is reached
-ss time_off start transcoding at specified timePer-file options (output-only):
-metadata[:spec] keyvalue add metadataPer-stream options:
-c[:stream_spec] codec select encoder/decoder (copy to copy stream without reencoding)
-filter[:stream_spec] filter_graph apply specified filters to audio/videoVideo options:
-r[:stream_spec] rate override input framerate/convert to given output framerate (Hz value, fraction or abbreviation)
-aspect[:stream_spec] aspect set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-vn disable video
-vcodec codec alias for -c:v (select encoder/decoder for video streams)
-vf filter_graph alias for -filter:v (apply filters to video streams)
-b bitrate video bitrate (please use -b:v)Audio options:
-aq quality set audio quality (codec-specific)
-ar[:stream_spec] rate set audio sampling rate (in Hz)
-ac[:stream_spec] channels set number of audio channels
-an disable audio
-acodec codec alias for -c:a (select encoder/decoder for audio streams)
-ab bitrate alias for -b:a (select bitrate for audio streams)
-af filter_graph alias for -filter:a (apply filters to audio streams)Subtitle options:
-sn disable subtitle
-scodec codec alias for -c:s (select encoder/decoder for subtitle streams)