Html 5 video/audio 格式转换 ogg

Html5 开始支持video和audio标签,但是各个浏览器支持的格式不一样,见下图

Browser

Ogg Vorbis

MP3

WAV

FireFox 3.6+

Safari 5+

Chrome 6

Opera 10.5+

Internet Explorer 9 (beta)

因此,要想全面兼容,至少需要提供两种格式,由于wav文件体积太庞大,因此我们提供MP3和ogg

MP3转换很容易,下面简单说下ogg

Ogg全称应该是OGGVobis(oggVorbis)是一种新的音频压缩格式,类似于MP3等的音乐格式。Ogg是完全免费、开放和没有专利限制的。OggVorbis文件的扩展名是.OGG。Ogg文件格式可以不断地进行大小和音质的改良,而不影响旧有的编码器或播放器。

ogg编码转换有个开源项目可以通过ffmpeg2theor(http://v2v.cc/~j/ffmpeg2theora/index.html)来实现:

ffmpeg2theora 编码器,可以将任何格式的影音媒体档案,转换成 ogg 档案。作者以传统的 C 语言编写这套软件,主要是利用大量的数据结构和指标来编写程式,由于这个编码器是采用命令列的操作模式,对于不熟悉命令列接口的人来说较为不便。

下面是 ffmpeg2theora  的使用说明:

ffmpeg2theora 0.27 - Xiph.Org libtheora 1.1 20090822 (Thusnelda)

  Usage: ffmpeg2theora [options] input

General output options:   -o, --output           alternative output filename       --no-skeleton      disables ogg skeleton metadata output       --skeleton-3       outputs Skeleton Version 3, without keyframe indexes   -s, --starttime        start encoding at this time (in sec.)   -e, --endtime          end encoding at this time (in sec.)   -p, --preset           encode file with preset.                           Right now there is preview, pro and videobin. Run                           'ffmpeg2theora -p info' for more informations

Video output options:   -v, --videoquality     [0 to 10] encoding quality for video (default: 6)                                    use higher values for better quality   -V, --videobitrate     encoding bitrate for video (kb/s)       --soft-target      Use a large reservoir and treat the rate                          as a soft target; rate control is less                          strict but resulting quality is usually                          higher/smoother overall. Soft target also                          allows an optional -v setting to specify                          a minimum allowed quality.

      --two-pass         Compress input using two-pass rate control                          This option requires that the input to the                          to the encoder is seekable and performs                          both passes automatically.

      --first-pass <filename> Perform first-pass of a two-pass rate                          controlled encoding, saving pass data to                          <filename> for a later second pass

      --second-pass <filename> Perform second-pass of a two-pass rate                          controlled encoding, reading first-pass                          data from <filename>.  The first pass                          data must come from a first encoding pass                          using identical input video to work                          properly.

      --optimize         optimize video output filesize (slower)                          (same as speedlevel 0)       --speedlevel       encoding is faster with higher values                          the cost is quality and bandwidth                          - 0: Slowest (best)                          - 1: Enable early skip (default)                          - 2: Disable motion compensation   -x, --width            scale to given width (in pixels)   -y, --height           scale to given height (in pixels)       --max_size         scale output frame to be within box of                          given size, height optional (%d[x%d], i.e. 640x480)       --aspect           define frame aspect ratio: i.e. 4:3 or 16:9       --pixel-aspect     define pixel aspect ratio: i.e. 1:1 or 4:3,                          overwrites frame aspect ratio   -F, --framerate        output framerate e.g 25:2 or 16       --croptop, --cropbottom, --cropleft, --cropright                          crop input by given pixels before resizing   -K, --keyint           [1 to 2147483647] keyframe interval (default: 64)   -d --buf-delay <n>     Buffer delay (in frames). Longer delays                          allow smoother rate adaptation and provide                          better overall quality, but require more                          client side buffering and add latency. The                          default value is the keyframe interval for                          one-pass encoding (or somewhat larger if                          --soft-target is used) and infinite for                          two-pass encoding. (only works in bitrate mode)       --no-upscaling     only scale video or resample audio if input is                          bigger than provided parameters

Video transfer options:   --pp                   Video Postprocessing, denoise, deblock, deinterlacer                           use --pp help for a list of available filters.   -C, --contrast         [0.1 to 10.0] contrast correction (default: 1.0)                           Note: lower values make the video darker.   -B, --brightness       [-1.0 to 1.0] brightness correction (default: 0.0)                           Note: lower values make the video darker.   -G, --gamma            [0.1 to 10.0] gamma correction (default: 1.0)                           Note: lower values make the video darker.   -Z, --saturation       [0.1 to 10.0] saturation correction (default: 1.0)                           Note: lower values make the video grey.

Audio output options:   -a, --audioquality     [-2 to 10] encoding quality for audio (default: 1)                                     use higher values for better quality   -A, --audiobitrate     [32 to 500] encoding bitrate for audio (kb/s)   -c, --channels         set number of output channels   -H, --samplerate       set output samplerate (in Hz)       --noaudio          disable audio from input       --novideo          disable video from input

Input options:       --deinterlace      force deinterlace, otherwise only material                           marked as interlaced will be deinterlaced   -f, --format           specify input format       --inputfps fps     override input fps       --audiostream id   by default the first audio stream is selected,                           use this to select another audio stream       --videostream id   by default the first video stream is selected,                           use this to select another video stream       --nosync           do not use A/V sync from input container.                          try this if you have issues with A/V sync Subtitles options:       --subtitles file                 use subtitles from the given file (SubRip (.srt) format)       --subtitles-encoding encoding    set encoding of the subtitles file              supported are utf-8, utf8, iso-8859-1, latin1       --subtitles-language language    set subtitles language (de, en_GB, etc)       --subtitles-category category    set subtitles category (default "subtitles")       --subtitles-ignore-non-utf8      ignores any non UTF-8 sequence in UTF-8 text       --nosubtitles                    disables subtitles from input                                        (equivalent to --subtitles=none)       --subtitle-types=[all,text,spu,none]   select what subtitle types to include from the                                              input video (default text)

Metadata options:       --artist           Name of artist (director)       --title            Title       --date             Date       --location         Location       --organization     Name of organization (studio)       --copyright        Copyright       --license          License       --contact          Contact link       --nometadata       disables metadata from input       --no-oshash        do not include oshash of source file(SOURCE_OSHASH)

Keyframe indexing options:       --index-interval <n>         set minimum distance between indexed keyframes                                    to <n> ms (default: 2000)       --theora-index-reserve <n>   reserve <n> bytes for theora keyframe index       --vorbis-index-reserve <n>   reserve <n> bytes for vorbis keyframe index       --kate-index-reserve <n>     reserve <n> bytes for kate keyframe index

Other options:   -P, --pid fname        write the process' id to a file   -h, --help             this message       --info             output json info about input file, use -o to save json to file       --frontend         print status information in json, one json dict per line

Examples:   ffmpeg2theora videoclip.avi (will write output to videoclip.ogv)

  ffmpeg2theora videoclip.avi --subtitles subtitles.srt (same, with subtitles)

  cat something.dv | ffmpeg2theora -f dv -o output.ogv -

  Encode a series of images:     ffmpeg2theora frame%06d.png -o output.ogv

  Live streaming from V4L Device:     ffmpeg2theora /dev/video0 -f video4linux --inputfps 15 -x 160 -y 128 -o - \      | oggfwd icast2server 8000 password /theora.ogv      (you might have to use video4linux2 depending on your hardware)

  Live encoding from a DV camcorder (needs a fast machine):     dvgrab - | ffmpeg2theora -f dv -x 352 -y 288 -o output.ogv -

  Live encoding and streaming to icecast server:     dvgrab --format raw - \      | ffmpeg2theora -f dv -x 160 -y 128 -o /dev/stdout - \      | oggfwd icast2server 8000 password /theora.ogv

示例:

G:\Users\Administrator>ffmpeg2theora-0.27.exe -o G:\Users\Administrator\Desktop\simplehtmldom_1_ 11\simplehtmldom\test.ogg G:\Users\Administrator\Desktop\simplehtmldom_1_11\simp lehtmldom\026d9859-dea9-4e4f-9c60-6545e51bf547.wav

Html示例

   Your browser does not support the video element.  

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏SAP最佳业务实践

SAP最佳业务实践:MM–组件收费的委外加工(251)-6开销售发票

4.7 创建出具发票凭证 创建出具发票凭证给委外加工商。 完成了对委外加工商的发货。 SAP ECC菜单Processes -Create Invoices f...

3578
来自专栏YouMeek

1.3 Elasticsearch Document(文档)的管理

课程环境 CentOS 7.3 x64 JDK 版本:1.8(最低要求),主推:JDK 1.8.0_121 Elasticsearch 版本:5.2.0 相关软...

3836
来自专栏一个会写诗的程序员的博客

《Kotlin极简教程》第1章 Kotlin简介

我们这里讲的Kotlin,就是一门以这个Котлин岛命名的现代程序设计语言。它是一门静态类型编程语言,支持JVM平台,Android平台,浏览器JS运行环境,...

692
来自专栏即时通讯技术

手把手教你读取Android版微信和手Q的聊天记录(仅作技术研究学习)

特别说明:本文内容仅用于即时通讯技术研究和学习之用,请勿用于非法用途。如本文内容有不妥之处,请联系JackJiang进行处理!

3052
来自专栏星流全栈

Github开源免费编程书籍

1.1K4
来自专栏木子昭的博客

<技术贴>当图虫遇到爬虫...根据”分类名称”,获取json数据根据json数据,获取图集url与title爬虫架构:运行界面:最终效果

首先,图虫网是一个很棒的图片网站,这里的爬虫只是为了研究技术,请读者朋友们,不要大量采集网站信息,爬取的图片,请取得版权后再使用... ? 图虫网 根据”分类...

3229
来自专栏Java与Android技术栈

一个快速分析android app使用了哪些sdk的工具工具使用实现原理写在最后

前段时间我们要准备开始做移动端广告sdk,我需要了解市面上一些常用的广告sdk使用情况。如果一个个app去分析,那工作量会非常庞大,所以就产生了这个工具Anal...

902
来自专栏转载gongluck的CSDN博客

波形音频(WAVE)底层接口的学习与使用

在WINDOWS下,音频函数有多种类型,如MCI、多媒体OLE控制、高级音频等,使用方法都比较简单。 但如果想编写一个功能较强大的音频处理程序,那...

1K5
来自专栏iOSDevLog

用Kotlin破解Android版微信小游戏-跳一跳成果跳一跳思路源码使用方法参考来源Android 插件 免PC

3566
来自专栏前端新视界

《了不起的 nodejs》中 TwitterWeb 案例 bug 解决

了不起的nodejs算是一本不错的入门书,不过书中个别案例存在bug,按照书中源码无法做出和书中相同效果,原本兴奋的心情掺杂着些许失落。 现在我们看一下第七章H...

1885

扫码关注云+社区