<video id="h99qi"><ins id="h99qi"><span id="h99qi"></span></ins></video>

        <var id="h99qi"><td id="h99qi"></td></var>
        1. <acronym id="h99qi"></acronym>
          <wbr id="h99qi"><code id="h99qi"><span id="h99qi"></span></code></wbr>

          1. <var id="h99qi"><th id="h99qi"></th></var>
            0712-2888027 189-8648-0214
            微信公眾號

            孝感風信網絡科技有限公司微信公眾號

            當前位置:主頁 > 技術支持 > PHP > 視頻流使用FFmpeg將mp4視頻轉換為m3u8/ts文件

            視頻流使用FFmpeg將mp4視頻轉換為m3u8/ts文件

            時間:2024-08-07來源:風信官網 點擊: 8417次
            風信建站新的開發項目中引用視頻流技術,為了有效解決大視頻在數據請求過程中加載過慢的問題,經過多次測試,決定使用m3u8格式做為視頻流的格式,那么mp4和m3u8格式的視頻各有什么缺點和優點呢?
             
            mp4視頻格式有以下優點:
             
            1:跨平臺支持,即支持pc端和移動端(ios和安卓)。
            2:該格式性能優越。
             
            mp4視頻的缺點:
             
            1:視頻時間長度過長時,在移動端會消耗大量的流量,但隨著互聯網流量資費的發展(將來流量是包月/年的,每月交一定費用,流量無限使用。)該缺點將不再存在。
            2:視頻文件相對大一些。對于服務器的空間占用方面會有一定壓力。
             
            視頻本身的要求
            1:視頻轉碼格式需要是h.264
            2:音頻轉碼格式需要是AAC
            3:如果考慮到需要支持在PC端低版本IE(IE9及以下)的環境中(在該環境中只能使用flashplayer播放)支持視頻請求未下載到用戶本地緩存區的內容播放。則需要視頻本身存在關鍵幀和關鍵時間點(服務器方面也有要求)。
             
            m3u8的優點:
             
            1:因為視頻被切成多個.ts文件,所以不需要考慮元數據的問題,并且可以分段加載。
            2:在PC端使用flashplayer播放時可以實現視頻的絕對加密。也就是視頻即使是被下載到用戶本地也無法使用。
             
            m3u8的缺點
             
            正常情況下不支持PC端的播放。ckplayer做了兼容是支持在pc端播放的,前提是pc端瀏覽器需要支持flashplayer
             
            使用m3u8我們需要將mp4視頻進行轉碼,命令如下:
             
            ffmpeg -i 2.mp4 -codec copy -vbsf h264_mp4toannexb -map 0 -f segment -segment_list m3u8/2.m3u8 -segment_time 10 m3u8/out%03d.ts
             
            G:\phpstudy_pro\wwwroot\ebiaoip-v\public>ffmpeg -i 2.mp4 -codec copy -vbsf h264_
            mp4toannexb -map 0 -f segment -segment_list m3u8/2.m3u8 -segment_time 10 m3u8/ou
            t%03d.ts
            ffmpeg version n4.3.1-23-gc19641b2e2 Copyright (c) 2000-2020 the FFmpeg develope
            rs
              built with gcc 9.3-win32 (GCC) 20200320
              configuration: --prefix=/ffbuild/prefix --pkg-config-flags=--static --pkg-conf
            ig=pkg-config --cross-prefix=x86_64-w64-mingw32- --arch=x86_64 --target-os=mingw
            32 --enable-gpl --enable-version3 --disable-debug --enable-iconv --enable-zlib -
            -enable-libxml2 --enable-libfreetype --enable-libfribidi --enable-gmp --enable-l
            zma --enable-fontconfig --enable-opencl --enable-libvmaf --disable-vulkan --enab
            le-libvorbis --enable-amf --enable-libaom --enable-avisynth --enable-libdav1d --
            enable-libdavs2 --enable-ffnvcodec --enable-cuda-llvm --disable-libglslang --ena
            ble-libass --enable-libbluray --enable-libmp3lame --enable-libopus --enable-libt
            heora --enable-libvpx --enable-libwebp --enable-libmfx --enable-libopencore-amrn
            b --enable-libopencore-amrwb --enable-libopenjpeg --enable-librav1e --enable-lib
            rubberband --enable-schannel --enable-sdl2 --enable-libsoxr --enable-libsrt --en
            able-libtwolame --enable-libvidstab --enable-libx264 --enable-libx265 --enable-l
            ibxavs2 --enable-libxvid --enable-libzimg --extra-cflags=-DLIBTWOLAME_STATIC --e
            xtra-cxxflags= --extra-ldflags=-pthread --extra-libs=-lgomp
              libavutil      56. 51.100 / 56. 51.100
              libavcodec     58. 91.100 / 58. 91.100
              libavformat    58. 45.100 / 58. 45.100
              libavdevice    58. 10.100 / 58. 10.100
              libavfilter     7. 85.100 /  7. 85.100
              libswscale      5.  7.100 /  5.  7.100
              libswresample   3.  7.100 /  3.  7.100
              libpostproc    55.  7.100 / 55.  7.100
            Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '2.mp4':
              Metadata:
                major_brand     : isom
                minor_version   : 512
                compatible_brands: isomiso2avc1mp41
                encoder         : Lavf57.58.101
              Duration: 00:04:10.13, start: 0.000000, bitrate: 161 kb/s
                Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x368 [
            SAR 1:1 DAR 40:23], 107 kb/s, 20 fps, 20 tbr, 10240 tbn, 80 tbc (default)
                Metadata:
                  handler_name    : VideoHandler
                Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt
            p, 48 kb/s (default)
                Metadata:
                  handler_name    : SoundHandler
            [segment @ 00000000004b8d00] Opening 'm3u8/out000.ts' for writing
            Output #0, segment, to 'm3u8/out%03d.ts':
              Metadata:
                major_brand     : isom
                minor_version   : 512
                compatible_brands: isomiso2avc1mp41
                encoder         : Lavf58.45.100
                Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 640x368 [
            SAR 1:1 DAR 40:23], q=2-31, 107 kb/s, 20 fps, 20 tbr, 90k tbn, 40 tbc (default)
                Metadata:
                  handler_name    : VideoHandler
                Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt
            p, 48 kb/s (default)
                Metadata:
                  handler_name    : SoundHandler
            Stream mapping:
              Stream #0:0 -> #0:0 (copy)
              Stream #0:1 -> #0:1 (copy)
            Press [q] to stop, [?] for help
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out001.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out002.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out003.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out004.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out005.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out006.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out007.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out008.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out009.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out010.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out011.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out012.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out013.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out014.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out015.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out016.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out017.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out018.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/out019.ts' for writing
            [segment @ 00000000004b8d00] Opening 'm3u8/2.m3u8.tmp' for writing
            frame= 4996 fps=0.0 q=-1.0 Lsize=N/A time=00:04:10.09 bitrate=N/A speed=1.44e+03
            x
            video:3274kB audio:1468kB subtitle:0kB other streams:0kB global headers:0kB muxi
            ng overhead: unknown
             
            轉碼成功之后就可以在播放器中使用,加載速度快多啦!

            視頻流使用FFmpeg將mp4視頻轉換為m3u8/ts文件
            視頻流使用FFmpeg將mp4視頻轉換為m3u8/ts文件
             
            如需網站開發、微信開發,接口開發,建站功能定制開發,歡迎致電風信網絡,電話:189-8648-0214(微信同號)
            欄目列表
            推薦內容
            熱點內容
            展開
            亚洲精品在线视频_18禁无码毛片精品久久久久久_精品熟妇无码av免费久久_午夜福利片