读书之深入理解ffmpeg_简单笔记1(初步)

对音视频一直有初步的了解,深入理解ffmpeg这本书出来后就迫不及待大代价购买,先通读一遍,简单对其做笔记,下一步做细节整理练习(仅个人笔记)。

第一章:都是一些理论基础,因为个人也浅了解过,略过。

音频,图像,声道,视频,带宽计算等基础。

第二章:FFmpeg的历史,宏观介绍

AVFormat(封装,解封装),

AVCodec(编码,解码模块),

AVFilter(滤镜模块),

AVDevices(设备模块),

AVUtils(通用工具模块)

swscale(图像转换模块)

swresample(音频转换模块)

ffmpeg编译后生成三个工具,ffmpeg(编解码工具),ffplay(播放器),ffprobe(多媒体分析器)

安装:可以去官网直接下载可执行程序,也可以去源码安装(整理过,这里略过)

源码安装的方式,可以通过configure查看支持的模块,配置支持的模块,查看编解码,封装/解封装,通信协议 支持等

第三章:ffmpeg工具使用整理

ffmpeg -version

E:\ffmpeg\ffmpeg-2023-11-09-git-acf63d5350-full_build\bin>ffmpeg -version
ffmpeg version 2023-11-09-git-acf63d5350-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
libavutil      58. 32.100 / 58. 32.100
libavcodec     60. 33.100 / 60. 33.100
libavformat    60. 17.100 / 60. 17.100
libavdevice    60.  4.100 / 60.  4.100
libavfilter     9. 13.100 /  9. 13.100
libswscale      7.  6.100 /  7.  6.100
libswresample   4. 13.100 /  4. 13.100
libpostproc    57.  4.100 / 57.  4.100

ffmpeg --help

ffmpeg --help full

ffmpeg -formats

ffmpeg -codecs

ffmpeg -encoders

ffmpeg -decoders

ffmpeg -filters

ffmpeg -h filter=colorkey

E:\ffmpeg\ffmpeg-2023-11-09-git-acf63d5350-full_build\bin>ffmpeg -h filter=colorkey
ffmpeg version 2023-11-09-git-acf63d5350-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58. 32.100 / 58. 32.100
  libavcodec     60. 33.100 / 60. 33.100
  libavformat    60. 17.100 / 60. 17.100
  libavdevice    60.  4.100 / 60.  4.100
  libavfilter     9. 13.100 /  9. 13.100
  libswscale      7.  6.100 /  7.  6.100
  libswresample   4. 13.100 /  4. 13.100
  libpostproc    57.  4.100 / 57.  4.100
Filter colorkey
  Turns a certain color into transparency. Operates on RGB colors.
    slice threading supported
    Inputs:
       #0: default (video)
    Outputs:
       #0: default (video)
colorkey AVOptions:
   color             <color>      ..FV.....T. set the colorkey key color (default "black")
   similarity        <float>      ..FV.....T. set the colorkey similarity value (from 1e-05 to 1) (default 0.01)
   blend             <float>      ..FV.....T. set the colorkey key blend value (from 0 to 1) (default 0)

This filter has support for timeline through the 'enable' option

ffmpeg -h muxer=flv

E:\ffmpeg\ffmpeg-2023-11-09-git-acf63d5350-full_build\bin>ffmpeg -h muxer=flv
ffmpeg version 2023-11-09-git-acf63d5350-full_build-www.gyan.dev Copyright (c) 2000-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58. 32.100 / 58. 32.100
  libavcodec     60. 33.100 / 60. 33.100
  libavformat    60. 17.100 / 60. 17.100
  libavdevice    60.  4.100 / 60.  4.100
  libavfilter     9. 13.100 /  9. 13.100
  libswscale      7.  6.100 /  7.  6.100
  libswresample   4. 13.100 /  4. 13.100
  libpostproc    57.  4.100 / 57.  4.100
Muxer flv [FLV (Flash Video)]:
    Common extensions: flv.
    Mime type: video/x-flv.
    Default video codec: flv1.
    Default audio codec: mp3.
flv muxer AVOptions:
  -flvflags          <flags>      E.......... FLV muxer flags (default 0)
     aac_seq_header_detect              E.......... Put AAC sequence header based on stream data
     no_sequence_end              E.......... disable sequence end for FLV
     no_metadata                  E.......... disable metadata for FLV
     no_duration_filesize              E.......... disable duration and filesize zero value metadata for FLV
     add_keyframe_index              E.......... Add keyframe index metadata

需要关注封装转换的参数

需要关注编码,解码参数

转码流程

ffmpeg -i xxx.rmvb -vcodec mpeg4 -b:v 200k -r 15 -an output.mp4

ffprobe 常用指令

ffprobe.exe -v 9 -show_format -show_streams -show_chapters -of json test.mp4

9是输出的详细程度  最详细 0~9  查看容器信息 流信息 章节信息 以及json格式
# ffprobe.exe -v 9 -show_format -show_streams -show_chapters -of json test.mp4
{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "Constrained Baseline",
            "codec_type": "video",
            "codec_tag_string": "avc1",
            "codec_tag": "0x31637661",
            "width": 1920,
            "height": 1080,
            "coded_width": 1920,
            "coded_height": 1080,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 0,
            "pix_fmt": "yuv420p",
            "level": 40,
            "chroma_location": "left",
            "field_order": "progressive",
            "refs": 1,
            "is_avc": "true",
            "nal_length_size": "4",
            "id": "0x1",
            "r_frame_rate": "10/1",
            "avg_frame_rate": "329055/32963",
            "time_base": "1/10240",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 67508224,
            "duration": "6592.600000",
            "bit_rate": "558453",
            "bits_per_raw_sample": "8",
            "nb_frames": "65811",
            "extradata_size": 39,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "VideoHandler",
                "vendor_id": "[0][0][0][0]"
            }
        },
        {
            "index": 1,
            "codec_name": "aac",
            "codec_long_name": "AAC (Advanced Audio Coding)",
            "profile": "LC",
            "codec_type": "audio",
            "codec_tag_string": "mp4a",
            "codec_tag": "0x6134706d",
            "sample_fmt": "fltp",
            "sample_rate": "48000",
            "channels": 2,
            "channel_layout": "stereo",
            "bits_per_sample": 0,
            "initial_padding": 0,
            "id": "0x2",
            "r_frame_rate": "0/0",
            "avg_frame_rate": "0/0",
            "time_base": "1/48000",
            "start_pts": 0,
            "start_time": "0.000000",
            "duration_ts": 316453680,
            "duration": "6592.785000",
            "bit_rate": "128000",
            "nb_frames": "309038",
            "extradata_size": 2,
            "disposition": {
                "default": 1,
                "dub": 0,
                "original": 0,
                "comment": 0,
                "lyrics": 0,
                "karaoke": 0,
                "forced": 0,
                "hearing_impaired": 0,
                "visual_impaired": 0,
                "clean_effects": 0,
                "attached_pic": 0,
                "timed_thumbnails": 0,
                "non_diegetic": 0,
                "captions": 0,
                "descriptions": 0,
                "metadata": 0,
                "dependent": 0,
                "still_image": 0
            },
            "tags": {
                "language": "und",
                "handler_name": "SoundHandler",
                "vendor_id": "[0][0][0][0]"
            }
        }
    ],
    "chapters": [

    ],
    "format": {
        "filename": "test.mp4",
        "nb_streams": 2,
        "nb_programs": 0,
        "format_name": "mov,mp4,m4a,3gp,3g2,mj2",
        "format_long_name": "QuickTime / MOV",
        "start_time": "0.000000",
        "duration": "6592.785000",
        "size": "568219326",
        "bit_rate": "689504",
        "probe_score": 100,
        "tags": {
            "major_brand": "isom",
            "minor_version": "512",
            "compatible_brands": "isomiso2avc1mp41",
            "title": "EVCapture4.0.2杞欢褰曞埗",
            "encoder": "Lavf56.38.102",
            "comment": "鏈棰戠敱婀栧崡涓€鍞俊鎭鎶€寮€鍙戠殑EV褰曞睆杞欢褰曞埗锛寃ww.ieway.cn"
        }
    }
}

ffprobe --help

ffprobe.exe -show_data -show_packets test.mp4

E:\ffmpeg\ffmpeg-2023-11-09-git-acf63d5350-full_build\bin>ffprobe.exe -show_data -show_packets test.mp4
ffprobe version 2023-11-09-git-acf63d5350-full_build-www.gyan.dev Copyright (c) 2007-2023 the FFmpeg developers
  built with gcc 12.2.0 (Rev10, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --pkg-config=pkgconf --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-ffnvcodec --enable-nvdec --enable-nvenc --enable-dxva2 --enable-d3d11va --enable-libvpl --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      58. 32.100 / 58. 32.100
  libavcodec     60. 33.100 / 60. 33.100
  libavformat    60. 17.100 / 60. 17.100
  libavdevice    60.  4.100 / 60.  4.100
  libavfilter     9. 13.100 /  9. 13.100
  libswscale      7.  6.100 /  7.  6.100
  libswresample   4. 13.100 /  4. 13.100
  libpostproc    57.  4.100 / 57.  4.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'test.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    title           : EVCapture4.0.2软件录制
    encoder         : Lavf56.38.102
    comment         : 本视频由湖南一唯信息科技开发的EV录屏软件录制,www.ieway.cn
  Duration: 01:49:52.79, start: 0.000000, bitrate: 689 kb/s
  Stream #0:0[0x1](und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080, 558 kb/s, 9.98 fps, 10 tbr, 10240 tbn (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
  Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]
[PACKET]
codec_type=audio
stream_index=1
pts=-1241
pts_time=-0.025854
dts=-1241
dts_time=-0.025854
duration=1024
duration_time=0.021333
size=341
pos=48
flags=KD_
data=
00000000: 2120 0520 a41b ffc0 0000 0000 0000 0000  ! . ............
00000010: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000020: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000030: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000040: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000050: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000060: 0000 0000 0000 0000 0000 0000 0000 0000  ................

ffprobe.exe -show_format test.mp4

[FORMAT]
filename=test.mp4
nb_streams=2
nb_programs=0
format_name=mov,mp4,m4a,3gp,3g2,mj2
format_long_name=QuickTime / MOV
start_time=0.000000
duration=6592.785000
size=568219326
bit_rate=689504
probe_score=100
TAG:major_brand=isom
TAG:minor_version=512
TAG:compatible_brands=isomiso2avc1mp41
TAG:title=EVCapture4.0.2软件录制
TAG:encoder=Lavf56.38.102
TAG:comment=本视频由湖南一唯信息科技开发的EV录屏软件录制,www.ieway.cn
[/FORMAT]

ffprobe.exe -show_frames test.mp4

可以查看帧类型,索引,关键帧,pts,dts,时长,宽高等

[FRAME]
media_type=audio
stream_index=1
key_frame=1
pts=0
pts_time=0.000000
pkt_dts=0
pkt_dts_time=0.000000
best_effort_timestamp=0
best_effort_timestamp_time=0.000000
pkt_duration=807
pkt_duration_time=0.016813
duration=807
duration_time=0.016813
pkt_pos=389
pkt_size=512
sample_fmt=fltp
nb_samples=807
channels=2
channel_layout=stereo
[/FRAME]
[FRAME]
media_type=video
stream_index=0
key_frame=1
pts=0
pts_time=0.000000
pkt_dts=0
pkt_dts_time=0.000000
best_effort_timestamp=0
best_effort_timestamp_time=0.000000
pkt_duration=1024
pkt_duration_time=0.100000
duration=1024
duration_time=0.100000
pkt_pos=901
pkt_size=142879
width=1920
height=1080
crop_top=0
crop_bottom=0
crop_left=0
crop_right=0
pix_fmt=yuv420p
sample_aspect_ratio=N/A
pict_type=I
coded_picture_number=0
display_picture_number=0
interlaced_frame=0
top_field_first=0
repeat_pict=0
color_range=unknown
color_space=unknown
color_primaries=unknown
color_transfer=unknown
chroma_location=left
[SIDE_DATA]
side_data_type=H.26[45] User Data Unregistered SEI message
[/SIDE_DATA]
[/FRAME]

ffprobe.exe -print_format json -show_streams test.mp4

ffprobe.exe -of json -show_streams test.mp4

可以设置xml,ini,json,cvs,flat等

streamEye工具,可以分析帧,编码等

ffprobe.exe -show_frames -select_streams a -of json test.mp4

-select_streams 可以查看音频 a 视频 v 字幕 a 的帧信息

ffprobe.exe -of json -select_streams v -show_packets -show_entries packet=codec_type,pts_time,flags,pos test.mp4

配合进行过滤参数,显示必要的信息。 配合grep 可以过滤查看关键帧等信息,索引等

ffprobe.exe -v trace test.mp4 2>&1|grep “parent:‘root’” (未验证)

未验证,查看对应的moov位置,ffmpeg也可以

ffplay.exe -ss 30 -t 10 -window_title “hello” test.mp4

time可以查看指令运行时长

ffplay.exe -vcodec h264 test.mp4

指定解码器

ffplay.exe -vst 4 -ast 5 xxx.ts

指定播放的视频流,音频流

ffplay.exe -window_title “窗口标题” -vf “subtitles=input.srt” output.mp4

ffplay.exe -showmode 1 out.mp3

ffplay.exe -debug vis_mb_type -window_title "test " -ss 20 -t 10 -autoexit test.mp4

ffplay.exe -vismv pf test.mp4

b帧 p帧预测

ffplay -flags2 +export_mvs -ss 40 test.mp4 -vf codecview=mv=pf+bf+bb

第四章 mp4格式分析

实际上就是len +type +data的格式,然后内部嵌套

moov可能在最后,对录制,很大的视频挑战比较大。

流式场景下,fmp4 (切片)

把MP4格式下的moov字段中的一些信息放到了moof中。

区分mp4和fmp4的方式,通过mvex box是否存在确定吗?

一般每个Gop作为一个单独分片存储,基于关键帧的分片。 指令如下:

ffmpeg -i xxx.h264 -c:v copy -f mp4 -movflags frag_keyframe+empty_moov out.mp4

CMAF (通用媒体格式)

可扩展的格式,用于打包分段媒体对象,在自适应媒体流中在终端用户设备上传输和解码。

结合了HLS和dash 两种流媒体协议。

MP4分析工具

Elecard StreamEye , MP4Box, mp4info, mediainfo,l-smash, Bento4

vlc也可以?

ffmpeg.exe -h demuxer=mp4 (mp4解封装常用参数)

Demuxer mov,mp4,m4a,3gp,3g2,mj2 [QuickTime / MOV]:
    Common extensions: mov,mp4,m4a,3gp,3g2,mj2,psp,m4b,ism,ismv,isma,f4v,avif.
mov,mp4,m4a,3gp,3g2,mj2 AVOptions:
  -use_absolute_path <boolean>    .D.V....... allow using absolute path when opening alias, this is a possible security issue (default false)
  -seek_streams_individually <boolean>    .D.V....... Seek each stream individually to the closest point (default true)
  -ignore_editlist   <boolean>    .D.V....... Ignore the edit list atom. (default false)
  -advanced_editlist <boolean>    .D.V....... Modify the AVIndex according to the editlists. Use this option to decode in the order specified by the edits. (default true)
  -ignore_chapters   <boolean>    .D.V.......  (default false)
  -use_mfra_for      <int>        .D.V....... use mfra for fragment timestamps (from -1 to 2) (default auto)
     auto            -1           .D.V....... auto
     dts             1            .D.V....... dts
     pts             2            .D.V....... pts
  -use_tfdt          <boolean>    .D.V....... use tfdt for fragment timestamps (default true)
  -export_all        <boolean>    .D.V....... Export unrecognized metadata entries (default false)
  -export_xmp        <boolean>    .D.V....... Export full XMP metadata (default false)
  -activation_bytes  <binary>     .D......... Secret bytes for Audible AAX files
  -audible_key       <binary>     .D......... AES-128 Key for Audible AAXC files
  -audible_iv        <binary>     .D......... AES-128 IV for Audible AAXC files
  -audible_fixed_key <binary>     .D......... Fixed key used for handling Audible AAX files
  -decryption_key    <binary>     .D......... The media decryption key (hex)
  -enable_drefs      <boolean>    .D.V....... Enable external track support. (default false)
  -max_stts_delta    <int>        .D......... treat offsets above this value as invalid (from 0 to UINT32_MAX) (default 4294487295)
  -interleaved_read  <boolean>    .D......... Interleave packets from multiple tracks at demuxer level (default true)

ffmpeg.exe -h muxer=mp4 (mp4封装常用参数)

mov/mp4/tgp/psp/tg2/ipod/ismv/f4v muxer AVOptions:
  -movflags          <flags>      E.......... MOV muxer flags (default 0)
     rtphint                      E.......... Add RTP hint tracks
     empty_moov                   E.......... Make the initial moov atom empty
     frag_keyframe                E.......... Fragment at video keyframes
     frag_every_frame              E.......... Fragment at every frame
     separate_moof                E.......... Write separate moof/mdat atoms for each track
     frag_custom                  E.......... Flush fragments on caller requests
     isml                         E.......... Create a live smooth streaming feed (for pushing to a publishing point)
     faststart                    E.......... Run a second pass to put the index (moov atom) at the beginning of the file
     omit_tfhd_offset              E.......... Omit the base data offset in tfhd atoms
     disable_chpl                 E.......... Disable Nero chapter atom
     default_base_moof              E.......... Set the default-base-is-moof flag in tfhd atoms
     dash                         E.......... Write DASH compatible fragmented MP4
     cmaf                         E.......... Write CMAF compatible fragmented MP4
     frag_discont                 E.......... Signal that the next fragment is discontinuous from earlier ones
     delay_moov                   E.......... Delay writing the initial moov until the first fragment is cut, or until the first fragment flush
     global_sidx                  E.......... Write a global sidx index at the start of the file
     skip_sidx                    E.......... Skip writing of sidx atom
     write_colr                   E.......... Write colr atom even if the color info is unspecified (Experimental, may be renamed or changed, do not use from scripts)
     prefer_icc                   E.......... If writing colr atom prioritise usage of ICC profile if it exists in stream packet side data
     write_gama                   E.......... Write deprecated gama atom
     use_metadata_tags              E.......... Use mdta atom for metadata.
     skip_trailer                 E.......... Skip writing the mfra/tfra/mfro trailer for fragmented files
     negative_cts_offsets              E.......... Use negative CTS offsets (reducing the need for edit lists)
  -moov_size         <int>        E.......... maximum moov size so it can be placed at the begin (from 0 to INT_MAX) (default 0)
  -rtpflags          <flags>      E.......... RTP muxer flags (default 0)
     latm                         E.......... Use MP4A-LATM packetization instead of MPEG4-GENERIC for AAC
     rfc2190                      E.......... Use RFC 2190 packetization instead of RFC 4629 for H.263
     skip_rtcp                    E.......... Don't send RTCP sender reports
     h264_mode0                   E.......... Use mode 0 for H.264 in RTP
     send_bye                     E.......... Send RTCP BYE packets when finishing
  -skip_iods         <boolean>    E.......... Skip writing iods atom. (default true)
  -iods_audio_profile <int>        E.......... iods audio profile atom. (from -1 to 255) (default -1)
  -iods_video_profile <int>        E.......... iods video profile atom. (from -1 to 255) (default -1)
  -frag_duration     <int>        E.......... Maximum fragment duration (from 0 to INT_MAX) (default 0)
  -min_frag_duration <int>        E.......... Minimum fragment duration (from 0 to INT_MAX) (default 0)
  -frag_size         <int>        E.......... Maximum fragment size (from 0 to INT_MAX) (default 0)
  -ism_lookahead     <int>        E.......... Number of lookahead entries for ISM files (from 0 to 255) (default 0)
  -video_track_timescale <int>        E.......... set timescale of all video tracks (from 0 to INT_MAX) (default 0)
  -brand             <string>     E.......... Override major brand
  -use_editlist      <boolean>    E.......... use edit list (default auto)
  -fragment_index    <int>        E.......... Fragment number of the next fragment (from 1 to INT_MAX) (default 1)
  -mov_gamma         <float>      E.......... gamma value for gama atom (from 0 to 10) (default 0)
  -frag_interleave   <int>        E.......... Interleave samples within fragments (max number of consecutive samples, lower is tighter interleaving, but with more overhead) (from 0 to INT_MAX) (default 0)
  -encryption_scheme <string>     E.......... Configures the encryption scheme, allowed values are none, cenc-aes-ctr
  -encryption_key    <binary>     E.......... The media encryption key (hex)
  -encryption_kid    <binary>     E.......... The media encryption key identifier (hex)
  -use_stream_ids_as_track_ids <boolean>    E.......... use stream ids as track ids (default false)
  -write_btrt        <boolean>    E.......... force or disable writing btrt (default auto)
  -write_tmcd        <boolean>    E.......... force or disable writing tmcd (default auto)
  -write_prft        <int>        E.......... Write producer reference time box with specified time source (from 0 to 2) (default 0)
     wallclock       1            E..........
     pts             2            E..........
  -empty_hdlr_name   <boolean>    E.......... write zero-length name string in hdlr atoms within mdia and minf atoms (default false)
  -movie_timescale   <int>        E.......... set movie timescale (from 1 to INT_MAX) (default 1000)
ffmpeg.exe -i input.flv -c copy -f mp4 out.mp4
ffmpeg.exe -i input.flv -c copy -f mp4 -movflags faststart out.mp4

移动moov到mdat前面

ffmpeg.exe -i input.flv -c copy -f mp4 -movflags dashout.mp4

dash格式的mp4文件

ffmpeg.exe -re -i input.mp4 -c copy -movflags isml+frag_keyframe -f ismv stream

isml设置ISML直播流

apple平台兼容: -tag:v hvcl

ffmpeg -i xxx.mp4 -c:v libx265 -c:a aac -crf 25 -tag:v hvcl out.mp4

你可能感兴趣的:(读书,笔记,ffmpeg)