网站建设需要哪些,南昌网站建设700起,app下载量排名,黄页88网推广服务参考链接
ffmpeg Documentation作者#xff1a;smallest_one 链接#xff1a;FFmpeg命令行工具-实用命令 - 简书
目录
1#xff0c;help命令使用 1.1 ffmpeg命令的语法结构1.2 获取详细的help信息1.3 打印帮助或者支持能力的信息1.4 全局选项1.5 文件选项1.6 视频/音频/字…参考链接
ffmpeg Documentation作者smallest_one 链接FFmpeg命令行工具-实用命令 - 简书
目录
1help命令使用 1.1 ffmpeg命令的语法结构1.2 获取详细的help信息1.3 打印帮助或者支持能力的信息1.4 全局选项1.5 文件选项1.6 视频/音频/字幕相关选项2流选择选项3视频封装解封装 3.1 视频格式转换3.2 分离/合并视频音频流3.3 截取视频片段3.4 视频转换为m3u8格式3.5 把视频文件推送到rtmp服务器3.6 对视频进行切片4视频解码编码 4.1 视频截图4.2 视频/图片尺寸修改4.3 分离视频的YUV通道分量4.4 图片序列与视频的互相转换5视频filter 5.1 视频加水印overlay5.2 视频旋转transpose5.3 调色3DLutFilter5.4 图像/视频转换成黑白的hue5.5 裁剪视频crop5.6 视频尺寸缩放scale5.7 视频中去水印delogo5.8 给视频或图像加上黑边pad5.9 计算psnr/ssim5.10 视频按时间拼接5.11 视频左右拼接5.12 打印视频帧的一些信息showinfo5.13 生成纯色的图片5.14 打印帧序号/pts到视频帧水印drawtext6音频解码编码 PCM原始数据和WAV格式转换7音频filter 倍速atempo8字幕相关 8.1 字幕文件转换8.2 集成字幕到视频文件9ffplay命令 9.1 ffplay播放yuv视频数据9.2 ffplay播放PCM音频数据9.3 ffplay播放音频并显示波形图9.4 ffplay指定显示宽高10ffprobe命令 10.1 ffprobe查看媒体文件的信息10.2 ffprobe查看时间戳11其他 11.1 ffmpeg或ffplay 打开 DEBUG 日志输出11.2 FFmpeg命令日志输出到文件11.3 打印支持DirectShow的设备列表
1help命令使用
ffmpeg -help终端打印帮助信息打印ffmpeg以及各个模块的版本信息
chy-cpabeubuntu:~/ffmpeg-source/ffmpeg$ ffmpeg -help
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Hyper fast Audio and Video encoder
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.Print help / information / capabilities:
-L show license
-h topic show help
-? topic show help
-help topic show help
--help topic show help
-version show version
-buildconf show build configuration
-formats show available formats
-muxers show available muxers
-demuxers show available demuxers
-devices show available devices
-codecs show available codecs
-decoders show available decoders
-encoders show available encoders
-bsfs show available bit stream filters
-protocols show available protocols
-filters show available filters
-pix_fmts show available pixel formats
-layouts show standard channel layouts
-sample_fmts show available audio sample formats
-dispositions show available stream dispositions
-colors show available color names
-sources device list sources of the input device
-sinks device list sinks of the output device
-hwaccels show available HW acceleration methodsGlobal options (affect whole program instead of just one file):
-loglevel loglevel set logging level
-v loglevel set logging level
-report generate a report
-max_alloc bytes set maximum size of a single allocated block
-y overwrite output files
-n never overwrite output files
-ignore_unknown Ignore unknown stream types
-filter_threads number of non-complex filter threads
-filter_complex_threads number of threads for -filter_complex
-stats print progress report during encoding
-max_error_rate maximum error rate ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-vol volume change audio volume (256normal)Per-file main options:
-f fmt force format
-c codec codec name
-codec codec codec name
-pre preset preset name
-map_metadata outfile[,metadata]:infile[,metadata] set metadata information of outfile from infile
-t duration record or transcode duration seconds of audio/video
-to time_stop record or transcode stop time
-fs limit_size set the limit file size in bytes
-ss time_off set the start time offset
-sseof time_off set the start time offset relative to EOF
-seek_timestamp enable/disable seeking by timestamp with -ss
-timestamp time set the recording timestamp (now to set the current time)
-metadata stringstring add metadata
-program titlestring:stnumber... add program with specified streams
-target type specify target file type (vcd, svcd, dvd, dv or dv50 with optional prefixes pal-, ntsc- or film-)
-apad audio pad
-frames number set the number of frames to output
-filter filter_graph set stream filtergraph
-filter_script filename read stream filtergraph description from a file
-reinit_filter reinit filtergraph on input parameter changes
-discard discard
-disposition dispositionVideo options:
-vframes number set the number of video frames to output
-r rate set frame rate (Hz value, fraction or abbreviation)
-fpsmax rate set max frame rate (Hz value, fraction or abbreviation)
-s size set frame size (WxH or abbreviation)
-aspect aspect set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-vn disable video
-vcodec codec force video codec (copy to copy stream)
-timecode hh:mm:ss[:;.]ff set initial TimeCode value.
-pass n select the pass number (1 to 3)
-vf filter_graph set video filters
-ab bitrate audio bitrate (please use -b:a)
-b bitrate video bitrate (please use -b:v)
-dn disable dataAudio options:
-aframes number set the number of audio frames to output
-aq quality set audio quality (codec-specific)
-ar rate set audio sampling rate (in Hz)
-ac channels set number of audio channels
-an disable audio
-acodec codec force audio codec (copy to copy stream)
-vol volume change audio volume (256normal)
-af filter_graph set audio filtersSubtitle options:
-s size set frame size (WxH or abbreviation)
-sn disable subtitle
-scodec codec force subtitle codec (copy to copy stream)
-stag fourcc/tag force subtitle tag/fourcc
-fix_sub_duration fix subtitles duration
-canvas_size size set canvas size (WxH or abbreviation)
-spre preset set the subtitle options to the indicated preset1.1 ffmpeg命令的语法结构
ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...options对输入和输出均有影响的选项[[infile options] -i infile] 指定输入选项和输入文件 ... 表示可以包含多个输入文件{[outfile options] outfile} 指定输出选项和输出文件 ... 表示可以包含多个输出文件
1.2 获取详细的help信息
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. -h long: 打印更多的选项参数-h full: 打印所有的选项参数包括所有针对于format和codec的选项信息特别的长-h typename: 打印指定名称的decoder/encoder/demuxer/muxer/filter的所有选项信息man ffmpeg: 查看ffmpeg的帮助手册特别注意 重点使用 -h typename例如查看libx264支持的参数 ffmpeg -h encoderlibx264
chy-cpabeubuntu:~/ffmpeg-source/ffmpeg$ ffmpeg -h encoderlibx264
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Encoder libx264 [libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10]:General capabilities: dr1 delay threads Threading capabilities: otherSupported pixel formats: yuv420p yuvj420p yuv422p yuvj422p yuv444p yuvj444p nv12 nv16 nv21
libx264 AVOptions:-preset string E..V....... Set the encoding preset (cf. x264 --fullhelp) (default medium)-tune string E..V....... Tune the encoding params (cf. x264 --fullhelp)-profile string E..V....... Set profile restrictions (cf. x264 --fullhelp) -fastfirstpass boolean E..V....... Use fast settings when encoding first pass (default true)-level string E..V....... Specify level (as defined by Annex A)-passlogfile string E..V....... Filename for 2 pass stats-wpredp string E..V....... Weighted prediction for P-frames-a53cc boolean E..V....... Use A53 Closed Captions (if available) (default true)-x264opts string E..V....... x264 options-crf float E..V....... Select the quality for constant quality mode (from -1 to FLT_MAX) (default -1)-crf_max float E..V....... In CRF mode, prevents VBV from lowering quality beyond this point. (from -1 to FLT_MAX) (default -1)-qp int E..V....... Constant quantization parameter rate control method (from -1 to INT_MAX) (default -1)-aq-mode int E..V....... AQ method (from -1 to INT_MAX) (default -1)none 0 E..V.......variance 1 E..V....... Variance AQ (complexity mask)autovariance 2 E..V....... Auto-variance AQautovariance-biased 3 E..V....... Auto-variance AQ with bias to dark scenes-aq-strength float E..V....... AQ strength. Reduces blocking and blurring in flat and textured areas. (from -1 to FLT_MAX) (default -1)-psy boolean E..V....... Use psychovisual optimizations. (default auto)-psy-rd string E..V....... Strength of psychovisual optimization, in psy-rd:psy-trellis format.-rc-lookahead int E..V....... Number of frames to look ahead for frametype and ratecontrol (from -1 to INT_MAX) (default -1)-weightb boolean E..V....... Weighted prediction for B-frames. (default auto)-weightp int E..V....... Weighted prediction analysis method. (from -1 to INT_MAX) (default -1)none 0 E..V.......simple 1 E..V.......smart 2 E..V.......-ssim boolean E..V....... Calculate and print SSIM stats. (default auto)-intra-refresh boolean E..V....... Use Periodic Intra Refresh instead of IDR frames. (default auto)-bluray-compat boolean E..V....... Bluray compatibility workarounds. (default auto)-b-bias int E..V....... Influences how often B-frames are used (from INT_MIN to INT_MAX) (default INT_MIN)-b-pyramid int E..V....... Keep some B-frames as references. (from -1 to INT_MAX) (default -1)none 0 E..V.......strict 1 E..V....... Strictly hierarchical pyramidnormal 2 E..V....... Non-strict (not Blu-ray compatible)-mixed-refs boolean E..V....... One reference per partition, as opposed to one reference per macroblock (default auto)-8x8dct boolean E..V....... High profile 8x8 transform. (default auto)-fast-pskip boolean E..V....... (default auto)-aud boolean E..V....... Use access unit delimiters. (default auto)-mbtree boolean E..V....... Use macroblock tree ratecontrol. (default auto)-deblock string E..V....... Loop filter parameters, in alpha:beta form.-cplxblur float E..V....... Reduce fluctuations in QP (before curve compression) (from -1 to FLT_MAX) (default -1)-partitions string E..V....... A comma-separated list of partitions to consider. Possible values: p8x8, p4x4, b8x8, i8x8, i4x4, none, all-direct-pred int E..V....... Direct MV prediction mode (from -1 to INT_MAX) (default -1)none 0 E..V.......spatial 1 E..V.......temporal 2 E..V.......auto 3 E..V.......-slice-max-size int E..V....... Limit the size of each slice in bytes (from -1 to INT_MAX) (default -1)-stats string E..V....... Filename for 2 pass stats-nal-hrd int E..V....... Signal HRD information (requires vbv-bufsize; cbr not allowed in .mp4) (from -1 to INT_MAX) (default -1)none 0 E..V.......vbr 1 E..V.......cbr 2 E..V.......-avcintra-class int E..V....... AVC-Intra class 50/100/200/300/480 (from -1 to 480) (default -1)-me_method int E..V....... Set motion estimation method (from -1 to 4) (default -1)dia 0 E..V.......hex 1 E..V.......umh 2 E..V.......esa 3 E..V.......tesa 4 E..V.......-motion-est int E..V....... Set motion estimation method (from -1 to 4) (default -1)dia 0 E..V.......hex 1 E..V.......umh 2 E..V.......esa 3 E..V.......tesa 4 E..V.......-forced-idr boolean E..V....... If forcing keyframes, force them as IDR frames. (default false)-coder int E..V....... Coder type (from -1 to 1) (default default)default -1 E..V.......cavlc 0 E..V.......cabac 1 E..V.......vlc 0 E..V.......ac 1 E..V.......-b_strategy int E..V....... Strategy to choose between I/P/B-frames (from -1 to 2) (default -1)-chromaoffset int E..V....... QP difference between chroma and luma (from INT_MIN to INT_MAX) (default 0)-sc_threshold int E..V....... Scene change threshold (from INT_MIN to INT_MAX) (default -1)-noise_reduction int E..V....... Noise reduction (from INT_MIN to INT_MAX) (default -1)-udu_sei boolean E..V....... Use user data unregistered SEI if available (default false)-x264-params dictionary E..V....... Override the x264 configuration using a :-separated list of keyvalue parameters1.3 打印帮助或者支持能力的信息
获取help信息打印各种格式支持的能力
Print help / information / capabilities:
-L show license
-h topic show help
-? topic show help
-help topic show help
--help topic show help
-version show version
-buildconf show build configuration
-formats show available formats
-muxers show available muxers
-demuxers show available demuxers
-devices show available devices
-codecs show available codecs
-decoders show available decoders
-encoders show available encoders
-bsfs show available bit stream filters
-protocols show available protocols
-filters show available filters
-pix_fmts show available pixel formats
-layouts show standard channel layouts
-sample_fmts show available audio sample formats
-dispositions show available stream dispositions
-colors show available color names
-sources device list sources of the input device
-sinks device list sinks of the output device
-hwaccels show available HW acceleration methods
1.4 全局选项 全局选项说明
Global options (affect whole program instead of just one file):
-loglevel loglevel set logging level
-v loglevel set logging level
-report generate a report
-max_alloc bytes set maximum size of a single allocated block
-y overwrite output files
-n never overwrite output files
-ignore_unknown Ignore unknown stream types
-filter_threads number of non-complex filter threads
-filter_complex_threads number of threads for -filter_complex
-stats print progress report during encoding
-max_error_rate maximum error rate ratio of decoding errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.
-vol volume change audio volume (256normal)
1.5 文件选项
针对每个文件可以指定的选项例-f fmt指定的文件的格式
Per-file main options:
-f fmt force format
-c codec codec name
-codec codec codec name
-pre preset preset name
-map_metadata outfile[,metadata]:infile[,metadata] set metadata information of outfile from infile
-t duration record or transcode duration seconds of audio/video
-to time_stop record or transcode stop time
-fs limit_size set the limit file size in bytes
-ss time_off set the start time offset
-sseof time_off set the start time offset relative to EOF
-seek_timestamp enable/disable seeking by timestamp with -ss
-timestamp time set the recording timestamp (now to set the current time)
-metadata stringstring add metadata
-program titlestring:stnumber... add program with specified streams
-target type specify target file type (vcd, svcd, dvd, dv or dv50 with optional prefixes pal-, ntsc- or film-)
-apad audio pad
-frames number set the number of frames to output
-filter filter_graph set stream filtergraph
-filter_script filename read stream filtergraph description from a file
-reinit_filter reinit filtergraph on input parameter changes
-discard discard
-disposition disposition
1.6 视频/音频/字幕相关选项 针对视频/音频/字幕相关的选项
Video options:
-vframes number set the number of video frames to output
-r rate set frame rate (Hz value, fraction or abbreviation)
-fpsmax rate set max frame rate (Hz value, fraction or abbreviation)
-s size set frame size (WxH or abbreviation)
-aspect aspect set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)
-vn disable video
-vcodec codec force video codec (copy to copy stream)
-timecode hh:mm:ss[:;.]ff set initial TimeCode value.
-pass n select the pass number (1 to 3)
-vf filter_graph set video filters
-ab bitrate audio bitrate (please use -b:a)
-b bitrate video bitrate (please use -b:v)
-dn disable dataAudio options:
-aframes number set the number of audio frames to output
-aq quality set audio quality (codec-specific)
-ar rate set audio sampling rate (in Hz)
-ac channels set number of audio channels
-an disable audio
-acodec codec force audio codec (copy to copy stream)
-vol volume change audio volume (256normal)
-af filter_graph set audio filtersSubtitle options:
-s size set frame size (WxH or abbreviation)
-sn disable subtitle
-scodec codec force subtitle codec (copy to copy stream)
-stag fourcc/tag force subtitle tag/fourcc
-fix_sub_duration fix subtitles duration
-canvas_size size set canvas size (WxH or abbreviation)
-spre preset set the subtitle options to the indicated preset2流选择选项
媒体格式如Mp4、AVI等内部包含了多种类型的流 FFmpeg可以识别5种流类型音频 audio a附件 attachment t数据 data d字幕 subtitle s视频 video v使用 -map选择需要的流语法如下 file_number:stream_type[:stream_number] file_number: 文件索引stream_number 流索引 特别的流选择指令 -map 0 选择所有的流类型和其中所有的流-map i:v 选择文件i中的所有视频流-map i:a 选择文件i中的所有音频流-map i:s 选择文件i中的所有字幕流
3视频封装解封装
3.1 视频格式转换
FFmpeg笔记--vcodec和-c:v,-acodec和-c:a的区别_木杉的博客-CSDN博客_ffmpeg vcodecffmpeg - Difference between -c:v and -vcodec, and -c:a and -acodec? - Super Useravi 转 MP4 ffmpeg -i /home/chy-cpabe/Videos/video_avi.avi -c:a copy -c:v copy /home/chy-cpabe/Videos/avi_2_mp4.mp4mp4 转 tsffmpeg系列之mp4与ts格式转换_starmier的博客-CSDN博客_ffmpeg mp4转ts
chy-cpabeubuntu:~/ffmpeg-source/ffmpeg$ ffmpeg -i /home/chy-cpabe/Videos/avi_2_mp4.mp4 /home/chy-cpabe/Videos/mp4_2_ts.ts
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from /home/chy-cpabe/Videos/avi_2_mp4.mp4:Metadata:major_brand : isomminor_version : 512compatible_brands: isomiso2mp41encoder : Lavf59.23.100Duration: 00:00:45.13, start: 0.000000, bitrate: 1632 kb/sStream #0:0[0x1](und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 1500 kb/s, 24 fps, 24 tbr, 12288 tbn (default)Metadata:handler_name : VideoHandlervendor_id : [0][0][0][0]Stream #0:1[0x2](und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)Metadata:handler_name : SoundHandlervendor_id : [0][0][0][0]
Stream mapping:Stream #0:0 - #0:0 (mpeg4 (native) - mpeg2video (native))Stream #0:1 - #0:1 (mp3 (mp3float) - mp2 (native))
Press [q] to stop, [?] for help
Output #0, mpegts, to /home/chy-cpabe/Videos/mp4_2_ts.ts:Metadata:major_brand : isomminor_version : 512compatible_brands: isomiso2mp41encoder : Lavf59.23.100Stream #0:0(und): Video: mpeg2video (Main), yuv420p(progressive), 480x360 [SAR 1:1 DAR 4:3], q2-31, 200 kb/s, 24 fps, 90k tbn (default)Metadata:handler_name : VideoHandlervendor_id : [0][0][0][0]encoder : Lavc59.27.100 mpeg2videoSide data:cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/AStream #0:1(und): Audio: mp2, 44100 Hz, stereo, s16, 384 kb/s (default)Metadata:handler_name : SoundHandlervendor_id : [0][0][0][0]encoder : Lavc59.27.100 mp2
frame 1082 fps622 q31.0 Lsize 4504kB time00:00:45.04 bitrate 819.1kbits/s speed25.9x
video:1968kB audio:2111kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 10.405245%3.2 分离/合并视频音频流
分离音频流 ffmpeg -i input-video -vn -c:a copy output-audio -vn表示不要视频-acodec copy表示拷贝输入视频的音频流输出文件 例如 output.wav
chy-cpabeubuntu:~/ffmpeg-source/ffmpeg$ ffmpeg -i /home/chy-cpabe/Videos/video_avi.avi -vn -c:a copy /home/chy-cpabe/Videos/video_avi.wav
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, avi, from /home/chy-cpabe/Videos/video_avi.avi:Metadata:software : Lavf54.59.106Duration: 00:00:45.13, start: 0.000000, bitrate: 1640 kb/sStream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 1501 kb/s, 24 fps, 24 tbr, 24 tbnStream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 128 kb/s
Output #0, wav, to /home/chy-cpabe/Videos/video_avi.wav:Metadata:software : Lavf54.59.106ISFT : Lavf59.23.100Stream #0:0: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 128 kb/s
Stream mapping:Stream #0:1 - #0:0 (copy)
Press [q] to stop, [?] for help
size 704kB time00:00:45.03 bitrate 128.0kbits/s speed6.41e03x
video:0kB audio:704kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.014572%分离视频流 ffmpeg -i input-video -c:v copy -an output-video -an表示不要音频-vcodec copy表示拷贝输入视频的视频流同时分离音频和视频流 ffmpeg -i input-video -c:v copy -an output-video -c:a copy -vn output-audio ffmpeg -i /home/chy-cpabe/Videos/video_avi.avi -c:v copy -an /home/chy-cpabe/Videos/video_mp4_1.mp4 -c:a copy -vn /home/chy-cpabe/Videos/video_avi_1.wav合并视频音频流 ffmpeg -i video_file -i audio_file -c:v copy -c:a copy output_file ffmpeg -i /home/chy-cpabe/Videos/video_avi_1.wav -i /home/chy-cpabe/Videos/video_mp4_1.mp4 -c:v copy -c:v copy /home/chy-cpabe/Videos/merge.mp43.3 截取视频片段
截取视频片段 ffmpeg -ss 5 -i input.mp4 -t 10 -c:v copy -c:a copy output.mp4 -ss 5指定从输入视频第5秒开始截取-t 10指明最多截取10秒而-c:v copy -c:a copy标示视频与音频的编码不发生改变而是直接复制这样会大大提升速度因为这样就不需要完全解码视频例子ffmpeg -ss 5 -i merge.mp4 -t 10 -c:v copy -c:a copy merge_5-15.mp4截取10s到20s 这个存在一个问题音频数据流与先前保持不变视频数据流 只显示10-20的数据ffmpeg -i input.mp4 -c:v libx264 -filter:v selectbetween(t\, 10\, 20) out.mp4从头截取前10帧 ffmpeg -i input.mp4 -c:v libx264 -filter:v selectgt(n\, -1) -vframes 10 out.mp4ffmpeg -i input.mp4 -c:v libx264 -filter:v selectbetween(n\, 0\, 9) out.mp4中间截取 10-20 帧 ffmpeg -i input.mp4 -c:v libx264 -filter:v selectbetween(n\, 10\, 20) out.mp4
3.4 视频转换为m3u8格式 ffmpeg -i yoona.mp4 -c copy -map 0 -f segment -segment_list yoona.m3u8 -segment_time 10 yoona-%04d.ts 形成一个以m3u8结尾的视频文件并进一步进行数据切分形成以 yoona-%04d.ts命名规则以ts结尾的的视频切片 ffmpeg -i output20.mp4 -codec copy -hls_list_size 0 -hls_wrap 0 -strict -2 -vbsf h264_mp4toannexb -absf aac_adtstoasc -f hls -hls_base_url https://test.com/ test.m3u8 -hls_time n: 设置每片的长度默认值为2。单位为秒。即EXTINF tag对应的值。hls_time设置后效果不一定准确会受到关键帧大小及其他因素影响。如果需要相对非常准确的切片可以添加hls_flags的子参数split_by_time来保证生成的切片能够与hls_time设置的切片时长差不多。split_by_time参数必须与hls_time配合使用并且使用split_by_time参数有可能会影响首画面体验例如花屏或者首画面显示慢的问题因为视频的第一帧不一定是关键帧。-hls_list_size n:设置播放列表保存的最多条目设置为0会保存有所片信息默认值为5。为了解决这个问题需要指定参数-hls_list_size 0这样就能包含所有的片段。-hls_wrap n:设置多少片之后开始覆盖如果设置为0则不会覆盖默认值为0.这个选项能够避免在磁盘上存储过多的 片而且能够限制写入磁盘的最多的片的数量。-hls_start_number n:设置播放列表中sequence number的值为number默认值为0。注意播放列表的sequence number 对每个segment来说都必须是唯一的而且它不能和片的文件名当使用wrap选项时文件名有可能会重复使用混淆h264_mp4toannexb h264有两种封装一种是annexb模式传统模式有startcodeSPS和PPS是在ES中vlc里打开编码器信息中显示h264一种是mp4模式一般mp4 mkv会有没有startcodeSPS和PPS以及其它信息被封装在container中每一个frame前面是这个frame的长度,vlc里打开编码器信息中显示avc1。很多解码器只支持annexb这种模式因此需要将mp4做转换。aac_adtstoasc将AAC编码器编码后的原始码流ADTS头 ES流封装为MP4或者FLV或者MOV等格式时需要先将ADTS头转换为MPEG-4 AudioSpecficConfig 将音频相关编解码参数提取出来并将原始码流中的ADTS头去掉只剩下ES流相反从MP4或者FLV或者MOV等格式文件中解封装出AAC码流只有ES流时需要在解析出的AAC码流前添加ADTS头含音频相关编解码参数hls_base_url 参数用于为M3U8列表的文件路径设置前置基本路径参数因为在FFmpeg中生成M3U8时写入的TS切片路径默认为M3U8生成的路径相同但是实际上TS所存储的路径既可以为本地绝对路径也可以为相对路
3.5 把视频文件推送到rtmp服务器
ffmpeg -re -i jack.mp4 -c copy -f flv rtmp://host/live/test 需要搭建 支持rtmp协议的服务器
3.6 对视频进行切片
均匀切片 ffmpeg -i input.mp4 -c copy -f segment -segment_format mp4 -segment_time 300 -reset_timestamps 1 test_output-%d.mp4 将input.mp4 切换为5分钟时长的视频片段 300 / 60 5使用ffmpeg -h muxersegment 查询segment muxer的参数按照时间点进行视频裁剪 ffmpeg -i input.mp4 -c copy -f segment -segment_format mp4 -segment_times 60,120,150 -reset_timestamps 1 test_output-%d.mp4 在第60秒 120秒 150秒 这三个时间点进行数据切片
4视频解码编码
4.1 视频截图
获取指定时间点的截图
ffmpeg -ss 01:23:45 -i input -vframes 1 -q:v 2 output.jpg-i input file the path to the input file
-ss 01:23:45 seek the position to the specified timestamp
-vframes 1 only handle one video frame
-q:v 2 to control output quality. Full range is a linear scale of 1-31 where a lower value results in a higher quality. 2-5 is a good range to try.
output.jpg output filename, should have a well-known extension
截取指定帧序号的图像 帧序号从0开始ffmpeg -i input -vf selecteq(n\,34) -vframes 1 out.png例子ffmpeg -i test.mp4 -vf selecteq(n\,6) -vframes 1 output_1.png
4.2 视频/图片尺寸修改
安装imagemagickapt-get install imagemagick用identify命令查看图片信息 数据信息较少 包括文件名图像格式图像大小图像深度颜色空间文件大小用户时间等例如参考链接ImageMagick(2) identify展示图像详细信息_落叶_小唱的博客-CSDN博客
chy-cpabeubuntu:~/Videos$ identify -verbose output.png
Image: output.pngFormat: PNG (Portable Network Graphics)Mime type: image/pngClass: DirectClassGeometry: 1920x108000Resolution: 1x1Print size: 1920x1080Units: UndefinedType: TrueColorEndianess: UndefinedColorspace: sRGBDepth: 8-bitChannel depth:red: 8-bitgreen: 8-bitblue: 8-bitChannel statistics:Pixels: 2073600Red:min: 0 (0)max: 255 (1)mean: 131.067 (0.513989)standard deviation: 56.6858 (0.222297)kurtosis: -1.2skewness: -0.241095entropy: 0.923994Green:min: 0 (0)max: 255 (1)mean: 147.134 (0.576995)standard deviation: 62.2514 (0.244123)kurtosis: -1.2576skewness: -0.216637entropy: 0.933398Blue:min: 0 (0)max: 255 (1)mean: 147.762 (0.579459)standard deviation: 66.8398 (0.262117)kurtosis: -1.27695skewness: -0.220383entropy: 0.936936Image statistics:Overall:min: 0 (0)max: 255 (1)mean: 141.988 (0.556814)standard deviation: 62.0647 (0.243391)kurtosis: -1.15139skewness: -0.182663entropy: 0.931443Rendering intent: PerceptualGamma: 0.50994Chromaticity:red primary: (0.64,0.33)green primary: (0.3,0.6)blue primary: (0.15,0.06)white point: (0.3127,0.329)Background color: whiteBorder color: srgb(223,223,223)Matte color: grey74Transparent color: blackInterlace: NoneIntensity: UndefinedCompose: OverPage geometry: 1920x108000Dispose: UndefinedIterations: 0Compression: ZipOrientation: UndefinedProperties:date:create: 2022-05-15T00:04:35-07:00date:modify: 2022-05-15T00:04:35-07:00png:cHRM: chunk was found (see Chromaticity, above)png:gAMA: gamma0.50994 (See Gamma, above)png:IHDR.bit-depth-orig: 8png:IHDR.bit_depth: 8png:IHDR.color-type-orig: 2png:IHDR.color_type: 2 (Truecolor)png:IHDR.interlace_method: 0 (Not interlaced)png:IHDR.width,height: 1920, 1080png:pHYs: x_res1, y_res1, units0signature: 102364a6ba97efa6c6693cdca6ecbc0df735fa8532195c0c7b21aec0c3e254f9Artifacts:filename: output.pngverbose: trueTainted: FalseFilesize: 2.39MBNumber pixels: 2.074MPixels per second: 29.62MBUser time: 0.050uElapsed time: 0:01.070Version: ImageMagick 6.9.7-4 Q16 x86_64 20170114 http://www.imagemagick.org修改 图片的储存大小为先前的一半ffmpeg -i sample.jpg -s w*h out.jpg ffmpeg -i output.png -s 960*540 output_change.png4.3 分离视频的YUV通道分量
ffmpeg -i jack.mp4 -filter_complex extractplanesyuv[y][u][v] -map [y] jack_y.mp4 -map [u] jack_u.mp4 -map [v] jack_v.mp4 https://zh.wikipedia.org/zh-sg/YUV
chy-cpabeubuntu:~/Videos$ ffmpeg -i test.mp4 -filter_complex extractplanesyuv[y][u][v] -map [y] out_y.mp4 -map [u] out_u.mp4 -map [v] out_v.mp4
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from test.mp4:Metadata:major_brand : M4V minor_version : 1compatible_brands: isomavc1mp42creation_time : 2021-02-14T02:11:02.000000ZDuration: 00:00:23.36, start: 0.000000, bitrate: 6313 kb/sStream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 6147 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)Metadata:creation_time : 2021-02-14T02:11:02.000000Zhandler_name : ETI ISO Video Media Handlervendor_id : [0][0][0][0]encoder : Elemental H.264Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)Metadata:creation_time : 2021-02-14T02:11:02.000000Zhandler_name : ETI ISO Audio Media Handlervendor_id : [0][0][0][0]
Stream mapping:Stream #0:0 (h264) - extractplanes:defaultextractplanes - Stream #0:0 (libx264)extractplanes - Stream #1:0 (libx264)extractplanes - Stream #2:0 (libx264)
Press [q] to stop, [?] for help
[swscaler 0x559284e90c40] [swscaler 0x559284e9dc40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284e90c40] [swscaler 0x559284eba2c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284e90c40] [swscaler 0x559284ed4580] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284e90c40] [swscaler 0x559284eee840] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284e90c40] [swscaler 0x559284f08b00] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284e90c40] [swscaler 0x559284f22dc0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284e90c40] [swscaler 0x559284f3d080] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284e90c40] [swscaler 0x559284f57340] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284e90c40] [swscaler 0x559284f72540] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x559284f95b40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x559284fafe00] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x559284fca0c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x559284fe4380] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x559284ffe640] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x559285018900] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x559285033b00] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x55928504a140] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284f88b80] [swscaler 0x559285064400] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x55928508b680] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x5592850b4980] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x5592850dbe40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x5592850f3ec0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x559285123380] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x55928514a840] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x559285171d00] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x559285189d80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55928507e6c0] [swscaler 0x5592851b9240] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284eb83c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f70680] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284ee6080] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f55480] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f62440] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284eff1c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284e90c40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f20f80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f2fd80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284eb83c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f70680] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284ee6080] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f55480] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f62440] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284eff1c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284e90c40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f20f80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f31bc0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284eb83c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f70680] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284ee6080] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f55480] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f62440] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284eff1c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284e90c40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f20f80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284ed2700] [swscaler 0x559284f2fd80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284fadf80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284fe2500] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285031c40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284ff4f40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285001f00] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285016ac0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284f88b40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x5592850482c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285055280] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284fadf80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284fe2500] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285031c40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284ff4f40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285001f00] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285016ac0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285023ac0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284f8c840] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x5592850482c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284fadf80] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284fe2500] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285031c40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284ff4f40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285001f00] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285016ac0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559285023ac0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x559284f8c840] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x559284fc8240] [swscaler 0x5592850482c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x55928515f080] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285197340] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x5592851b5580] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x5592850bc280] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285175980] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x5592850da000] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285091140] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285114380] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x55928513f580] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x55928515f080] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285197340] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285150480] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x5592850b68c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285173c40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x5592850da000] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x55928507e4c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285094bc0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x55928512e880] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x55928515f080] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285197340] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285150480] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x5592850b68c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285173c40] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x5592850da000] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x55928507e4c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x559285094bc0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x5592851a8400] [swscaler 0x55928512e880] deprecated pixel format used, make sure you did set range correctly
[libx264 0x559283ebb640] using SAR1/1
[libx264 0x559283ebb640] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 0x559283ebb640] profile High 4:4:4 Predictive, level 4.0, 4:4:4 8-bit
[libx264 0x559283ebb640] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac1 ref3 deblock1:0:0 analyse0x1:0x111 mehex subme7 psy1 psy_rd1.00:0.00 mixed_ref1 me_range16 chroma_me1 trellis1 8x8dct0 cqm0 deadzone21,11 fast_pskip1 chroma_qp_offset4 threads12 lookahead_threads2 sliced_threads0 nr0 decimate1 interlaced0 bluray_compat0 constrained_intra0 bframes3 b_pyramid2 b_adapt1 b_bias0 direct1 weightb1 open_gop0 weightp2 keyint250 keyint_min23 scenecut40 intra_refresh0 rc_lookahead40 rccrf mbtree1 crf23.0 qcomp0.60 qpmin0 qpmax69 qpstep4 ip_ratio1.40 aq1:1.00
Output #0, mp4, to out_y.mp4:Metadata:major_brand : M4V minor_version : 1compatible_brands: isomavc1mp42encoder : Lavf59.23.100Stream #0:0: Video: h264 (avc1 / 0x31637661), yuvj444p(pc, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q2-31, 23.98 fps, 24k tbnMetadata:encoder : Lavc59.27.100 libx264Side data:cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[libx264 0x559283e909c0] using SAR1/1
[libx264 0x559283e909c0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 0x559283e909c0] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 0x559283e909c0] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac1 ref3 deblock1:0:0 analyse0x1:0x111 mehex subme7 psy1 psy_rd1.00:0.00 mixed_ref1 me_range16 chroma_me1 trellis1 8x8dct0 cqm0 deadzone21,11 fast_pskip1 chroma_qp_offset4 threads12 lookahead_threads2 sliced_threads0 nr0 decimate1 interlaced0 bluray_compat0 constrained_intra0 bframes3 b_pyramid2 b_adapt1 b_bias0 direct1 weightb1 open_gop0 weightp2 keyint250 keyint_min23 scenecut40 intra_refresh0 rc_lookahead40 rccrf mbtree1 crf23.0 qcomp0.60 qpmin0 qpmax69 qpstep4 ip_ratio1.40 aq1:1.00
Output #1, mp4, to out_u.mp4:Metadata:major_brand : M4V minor_version : 1compatible_brands: isomavc1mp42encoder : Lavf59.23.100Stream #1:0: Video: h264 (avc1 / 0x31637661), yuvj444p(pc, bt709, progressive), 960x540 [SAR 1:1 DAR 16:9], q2-31, 23.98 fps, 24k tbnMetadata:encoder : Lavc59.27.100 libx264Side data:cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[libx264 0x559283ec5680] using SAR1/1
[libx264 0x559283ec5680] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 0x559283ec5680] profile High 4:4:4 Predictive, level 3.1, 4:4:4 8-bit
[libx264 0x559283ec5680] 264 - core 152 r2854 e9a5903 - H.264/MPEG-4 AVC codec - Copyleft 2003-2017 - http://www.videolan.org/x264.html - options: cabac1 ref3 deblock1:0:0 analyse0x1:0x111 mehex subme7 psy1 psy_rd1.00:0.00 mixed_ref1 me_range16 chroma_me1 trellis1 8x8dct0 cqm0 deadzone21,11 fast_pskip1 chroma_qp_offset4 threads12 lookahead_threads2 sliced_threads0 nr0 decimate1 interlaced0 bluray_compat0 constrained_intra0 bframes3 b_pyramid2 b_adapt1 b_bias0 direct1 weightb1 open_gop0 weightp2 keyint250 keyint_min23 scenecut40 intra_refresh0 rc_lookahead40 rccrf mbtree1 crf23.0 qcomp0.60 qpmin0 qpmax69 qpstep4 ip_ratio1.40 aq1:1.00
Output #2, mp4, to out_v.mp4:Metadata:major_brand : M4V minor_version : 1compatible_brands: isomavc1mp42encoder : Lavf59.23.100Stream #2:0: Video: h264 (avc1 / 0x31637661), yuvj444p(pc, bt709, progressive), 960x540 [SAR 1:1 DAR 16:9], q2-31, 23.98 fps, 24k tbnMetadata:encoder : Lavc59.27.100 libx264Side data:cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame 560 fps 13 q-1.0 Lq-1.0 q-1.0 size 15581kB time00:00:23.23 bitrate5494.4kbits/s speed0.556x
video:17234kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[libx264 0x559283ebb640] frame I:3 Avg QP:20.11 size:127210
[libx264 0x559283ebb640] frame P:204 Avg QP:22.05 size: 51523
[libx264 0x559283ebb640] frame B:353 Avg QP:25.57 size: 14319
[libx264 0x559283ebb640] consecutive B-frames: 3.2% 36.4% 5.4% 55.0%
[libx264 0x559283ebb640] mb I I16..4: 43.2% 0.0% 56.8%
[libx264 0x559283ebb640] mb P I16..4: 16.9% 0.0% 8.5% P16..4: 39.6% 15.0% 5.4% 0.0% 0.0% skip:14.6%
[libx264 0x559283ebb640] mb B I16..4: 1.7% 0.0% 0.7% B16..8: 44.4% 5.9% 0.8% direct: 2.2% skip:44.2% L0:43.1% L1:48.9% BI: 8.0%
[libx264 0x559283ebb640] coded y,u,v intra: 28.8% 0.0% 0.0% inter: 14.0% 0.0% 0.0%
[libx264 0x559283ebb640] i16 v,h,dc,p: 51% 24% 14% 11%
[libx264 0x559283ebb640] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 25% 18% 21% 5% 7% 5% 8% 4% 6%
[libx264 0x559283ebb640] Weighted P-Frames: Y:5.4% UV:0.0%
[libx264 0x559283ebb640] ref P L0: 65.1% 19.9% 10.6% 4.1% 0.3%
[libx264 0x559283ebb640] ref B L0: 92.5% 6.0% 1.5%
[libx264 0x559283ebb640] ref B L1: 98.6% 1.4%
[libx264 0x559283ebb640] kb/s:5462.08
[libx264 0x559283e909c0] frame I:13 Avg QP:12.93 size: 4437
[libx264 0x559283e909c0] frame P:214 Avg QP:16.17 size: 2041
[libx264 0x559283e909c0] frame B:333 Avg QP:16.81 size: 871
[libx264 0x559283e909c0] consecutive B-frames: 3.2% 51.1% 4.3% 41.4%
[libx264 0x559283e909c0] mb I I16..4: 86.6% 0.0% 13.4%
[libx264 0x559283e909c0] mb P I16..4: 16.9% 0.0% 0.3% P16..4: 24.3% 3.5% 1.7% 0.0% 0.0% skip:53.3%
[libx264 0x559283e909c0] mb B I16..4: 0.4% 0.0% 0.0% B16..8: 26.6% 1.8% 0.0% direct: 0.1% skip:71.0% L0:44.5% L1:55.2% BI: 0.4%
[libx264 0x559283e909c0] coded y,u,v intra: 1.9% 0.0% 0.0% inter: 0.9% 0.0% 0.0%
[libx264 0x559283e909c0] i16 v,h,dc,p: 62% 23% 11% 4%
[libx264 0x559283e909c0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 25% 33% 1% 1% 1% 1% 0% 0%
[libx264 0x559283e909c0] Weighted P-Frames: Y:0.5% UV:0.0%
[libx264 0x559283e909c0] ref P L0: 74.1% 3.1% 16.5% 6.2% 0.0%
[libx264 0x559283e909c0] ref B L0: 88.4% 9.7% 1.9%
[libx264 0x559283e909c0] ref B L1: 98.5% 1.5%
[libx264 0x559283e909c0] kb/s:268.71
[libx264 0x559283ec5680] frame I:12 Avg QP:13.33 size: 5060
[libx264 0x559283ec5680] frame P:255 Avg QP:16.90 size: 2326
[libx264 0x559283ec5680] frame B:293 Avg QP:17.38 size: 888
[libx264 0x559283ec5680] consecutive B-frames: 3.9% 78.6% 1.1% 16.4%
[libx264 0x559283ec5680] mb I I16..4: 83.6% 0.0% 16.4%
[libx264 0x559283ec5680] mb P I16..4: 17.8% 0.0% 0.3% P16..4: 26.9% 4.2% 2.1% 0.0% 0.0% skip:48.6%
[libx264 0x559283ec5680] mb B I16..4: 0.3% 0.0% 0.0% B16..8: 28.3% 1.9% 0.0% direct: 0.1% skip:69.3% L0:40.1% L1:59.5% BI: 0.4%
[libx264 0x559283ec5680] coded y,u,v intra: 1.9% 0.0% 0.0% inter: 1.4% 0.0% 0.0%
[libx264 0x559283ec5680] i16 v,h,dc,p: 61% 23% 12% 4%
[libx264 0x559283ec5680] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 38% 25% 34% 1% 1% 1% 1% 0% 0%
[libx264 0x559283ec5680] Weighted P-Frames: Y:0.8% UV:0.0%
[libx264 0x559283ec5680] ref P L0: 75.7% 4.3% 14.4% 5.5% 0.1%
[libx264 0x559283ec5680] ref B L0: 88.6% 10.5% 0.9%
[libx264 0x559283ec5680] ref B L1: 99.4% 0.6%
[libx264 0x559283ec5680] kb/s:313.094.4 图片序列与视频的互相转换
ffmpeg -i %04d.jpg output.mp4 把0001.jpg、0002.jpg、0003.jpg等编码成output.mp4ffmpeg -i input.mp4 %04d.jpg 把input.mp4变成0001.jpg等%04d.jpg表示从1开始用0补全的4位整数为文件名的jpg文件序列
5视频filter
5.1 视频加水印overlay
ffmpeg -i xizong.mp4 -i fleight.jpg -filter_complex overlayW-w-5:5 -codec:a copy xizong_fleight.mp4在右上角加水印边距为5像素将一张图片作为水印 添加在 右上角
5.2 视频旋转transpose
顺时针旋转90度 ffmpeg -i input -vf transpose1 output顺时针旋转180度 ffmpeg -i in.mp4 -vf transpose1,transpose1 out.mp4
5.3 调色3DLutFilter
应用颜色查找表Lut有‘nearest’、‘trilinear’、‘tetrahedral’三种插值算法命令行调用如下 ffmpeg -i log.mp4 -vf lut3dfileDK79.cube out.mp4 存在问题 找不到 DK79.cube
5.4 图像/视频转换成黑白的
图像转换成黑白的 ffmpeg -i sample.png -vf hues0 output.png把视频转换为黑白的 ffmpeg -i julin_5s.mp4 -vf hues0 -c:a copy julin_monochrome.mp4
5.5 裁剪视频crop
使用-crop选项语法如下cropow[:oh[:x[:y[:keep_aspect]]]] ow、oh表示裁减之后输出视频的宽和高 x、y表示在输入视频上开始裁减的横坐标和纵坐标keep_aspect: 1表示保持裁剪后输出的纵横比与输入一致0表示不保持裁剪输入视频的左三分之一 ffmpeg -i input -vf cropiw/3:ih :0:0 output裁剪输入视频的中间三分之一 ffmpeg -i input -vf cropiw/3:ih :iw/3:0 output裁剪输入视频的右三分之一: ffmpeg -i input -vf cropiw/3:ih :iw/3*2:0 output裁剪中间一半区域 ffmpeg -i input -vf cropiw/2:ih/2 output
5.6 视频尺寸缩放scale
将输入的1920*1080 缩小到 960*540 输出ffmpeg -i input.mp4 -vf scale960:540 output.mp4如果540不写写成-1即scale960:-1, 那也是可以的ffmpeg会通知缩放滤镜在输出时保持原始的宽高比。
5.7 视频中去水印delogo
使用delogo filter它对logo周围像素的简单插值来实现。只需设置一个覆盖logo的矩形。在每个方向上紧靠矩形外的下一个像素的值将用于计算矩形内的插值像素值。语法-vf delogox:y:w:h[:t[:show]] x:y 离左上角的坐标w:h logo的宽和高show默认值0若设置为1指定区域的边界会绘制一个绿色的矩形框用于找到合适的x、y、w、h参数例子ffmpeg -i pic_video.mp4 -filter_complex delogox1800:y20:w80:h80:show1 dellogo.mp4使用ffmpeg视频去水印__sleeping的博客-CSDN博客_ffmpeg去除视频水印5.8 给视频或图像加上黑边pad
比如一个输入视频尺寸是1280x534想加上黑边变成1280x720使用下面的命令可以实现ffmpeg -i input.mp4 -vf pad1280:720:0:93:black output.mp4按照从左到右的顺序依次为“宽”、“高”、“X坐标”和“Y坐标”宽和高指的是输入视频尺寸包含加黑边的尺寸X、Y指的是视频所在位置 默认是加黑色的边black可以不写。 上面的命令中93是根据(720-534) / 2计算得到如果视频原始1920x800的话完整的语法应该是 ffmpeg -i input.mp4 -vf scale1280:534,pad1280:720:0:93:black 先将视频缩小到1280x534然后在加入黑边变成1280x720将1280x534的视频放置在x0y93的地方。例子ffmpeg -i pic_video.mp4 -vf scale1280:534,pad1280:720:0:93:red red_dellogo.mp4 5.9 计算psnr/ssim
分析 psnr 主要是针对转码前的视频和转码后的视频的对比如果转码是降分辨率对比的时候还需要对源视频加 -s widthxhigh保证分辨率一致再做 psnr 和 ssim 的计算psnrffmpeg -i src.mp4 -i dst.mp4 -lavfi psnrstats_filepsnr.log -f null -ssimffmpeg -i src.mp4 -i dst.mp4 -lavfi ssimstats_filessim.log -f null -同时计算psnr和ssimffmpeg -i main.mpg -i ref.mpg -lavfi ssim;[0:v][1:v]psnr -f null -
实际操作
计算psnr和ssim主要目的是 视频转码前后的对比因此第一步 将avi格式的视频转换为MP4格式的视频ffmpeg -i test_avi.avi -c:a copy -c:v copy avi_2_mp4.mp4计算 psnrffmpeg -i test_avi.avi -i avi_2_mp4.mp4 -lavfi psnrstats_filepsnr.log -f null -
chy-cpabeubuntu:~/Videos$ ffmpeg -i test_avi.avi -i avi_2_mp4.mp4 -lavfi psnrstats_filepsnr.log -f null -
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, avi, from test_avi.avi:Metadata:software : Lavf54.59.106Duration: 00:00:45.13, start: 0.000000, bitrate: 1640 kb/sStream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 1501 kb/s, 24 fps, 24 tbr, 24 tbnStream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 128 kb/s
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from avi_2_mp4.mp4:Metadata:major_brand : isomminor_version : 512compatible_brands: isomiso2mp41encoder : Lavf59.23.100Duration: 00:00:45.13, start: 0.000000, bitrate: 1632 kb/sStream #1:0[0x1](und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 1500 kb/s, 24 fps, 24 tbr, 12288 tbn (default)Metadata:handler_name : VideoHandlervendor_id : [0][0][0][0]Stream #1:1[0x2](und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)Metadata:handler_name : SoundHandlervendor_id : [0][0][0][0]
Stream mapping:Stream #0:0 (mpeg4) - psnr (graph 0)Stream #1:0 (mpeg4) - psnr (graph 0)psnr:default (graph 0) - Stream #0:0 (wrapped_avframe)Stream #0:1 - #0:1 (mp3 (mp3float) - pcm_s16le (native))
Press [q] to stop, [?] for help
[Parsed_psnr_0 0x55b9216da140] not matching timebases found between first input: 1/24 and second input 1/12288, results may be incorrect!
Output #0, null, to pipe::Metadata:software : Lavf54.59.106encoder : Lavf59.23.100Stream #0:0: Video: wrapped_avframe, yuv420p(progressive), 480x360 [SAR 1:1 DAR 4:3], q2-31, 200 kb/s, 24 fps, 24 tbnMetadata:encoder : Lavc59.27.100 wrapped_avframeStream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/sMetadata:encoder : Lavc59.27.100 pcm_s16le
frame 1082 fps0.0 q-0.0 LsizeN/A time00:00:45.12 bitrateN/A speed54.4x 计算 ssimffmpeg -i test_avi.avi -i avi_2_mp4.mp4 -lavfi ssimstats_filessim.log -f null -
chy-cpabeubuntu:~/Videos$ ffmpeg -i test_avi.avi -i avi_2_mp4.mp4 -lavfi ssimstats_filessim.log -f null -
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, avi, from test_avi.avi:Metadata:software : Lavf54.59.106Duration: 00:00:45.13, start: 0.000000, bitrate: 1640 kb/sStream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 1501 kb/s, 24 fps, 24 tbr, 24 tbnStream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 128 kb/s
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from avi_2_mp4.mp4:Metadata:major_brand : isomminor_version : 512compatible_brands: isomiso2mp41encoder : Lavf59.23.100Duration: 00:00:45.13, start: 0.000000, bitrate: 1632 kb/sStream #1:0[0x1](und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 1500 kb/s, 24 fps, 24 tbr, 12288 tbn (default)Metadata:handler_name : VideoHandlervendor_id : [0][0][0][0]Stream #1:1[0x2](und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)Metadata:handler_name : SoundHandlervendor_id : [0][0][0][0]
Stream mapping:Stream #0:0 (mpeg4) - ssim (graph 0)Stream #1:0 (mpeg4) - ssim (graph 0)ssim:default (graph 0) - Stream #0:0 (wrapped_avframe)Stream #0:1 - #0:1 (mp3 (mp3float) - pcm_s16le (native))
Press [q] to stop, [?] for help
[Parsed_ssim_0 0x5588afcef640] not matching timebases found between first input: 1/24 and second input 1/12288, results may be incorrect!
Output #0, null, to pipe::Metadata:software : Lavf54.59.106encoder : Lavf59.23.100Stream #0:0: Video: wrapped_avframe, yuv420p(progressive), 480x360 [SAR 1:1 DAR 4:3], q2-31, 200 kb/s, 24 fps, 24 tbnMetadata:encoder : Lavc59.27.100 wrapped_avframeStream #0:1: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/sMetadata:encoder : Lavc59.27.100 pcm_s16le
frame 1082 fps0.0 q-0.0 LsizeN/A time00:00:45.12 bitrateN/A speed 49x
video:499kB audio:7758kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_ssim_0 0x5588afcef640] SSIM Y:1.000000 (inf) U:1.000000 (inf) V:1.000000 (inf) All:1.000000 (inf)同时计算 psnr 和 ssimffmpeg -i test_avi.avi -i avi_2_mp4.mp4 -lavfi ssim;[0:v][1:v]psnr -f null -
chy-cpabeubuntu:~/Videos$ ffmpeg -i test_avi.avi -i avi_2_mp4.mp4 -lavfi ssim;[0:v][1:v]psnr -f null -
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, avi, from test_avi.avi:Metadata:software : Lavf54.59.106Duration: 00:00:45.13, start: 0.000000, bitrate: 1640 kb/sStream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 1501 kb/s, 24 fps, 24 tbr, 24 tbnStream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 44100 Hz, stereo, fltp, 128 kb/s
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from avi_2_mp4.mp4:Metadata:major_brand : isomminor_version : 512compatible_brands: isomiso2mp41encoder : Lavf59.23.100Duration: 00:00:45.13, start: 0.000000, bitrate: 1632 kb/sStream #1:0[0x1](und): Video: mpeg4 (Simple Profile) (mp4v / 0x7634706D), yuv420p, 480x360 [SAR 1:1 DAR 4:3], 1500 kb/s, 24 fps, 24 tbr, 12288 tbn (default)Metadata:handler_name : VideoHandlervendor_id : [0][0][0][0]Stream #1:1[0x2](und): Audio: mp3 (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default)Metadata:handler_name : SoundHandlervendor_id : [0][0][0][0]
Stream mapping:Stream #0:0 (mpeg4) - ssim (graph 0)Stream #0:0 (mpeg4) - psnr (graph 0)Stream #1:0 (mpeg4) - ssim (graph 0)Stream #1:0 (mpeg4) - psnr (graph 0)ssim:default (graph 0) - Stream #0:0 (wrapped_avframe)psnr:default (graph 0) - Stream #0:1 (wrapped_avframe)Stream #0:1 - #0:2 (mp3 (mp3float) - pcm_s16le (native))
Press [q] to stop, [?] for help
[Parsed_ssim_0 0x564524f58100] not matching timebases found between first input: 1/24 and second input 1/12288, results may be incorrect!
[Parsed_psnr_1 0x564524f58540] not matching timebases found between first input: 1/24 and second input 1/12288, results may be incorrect!
Output #0, null, to pipe::Metadata:software : Lavf54.59.106encoder : Lavf59.23.100Stream #0:0: Video: wrapped_avframe, yuv420p(progressive), 480x360 [SAR 1:1 DAR 4:3], q2-31, 200 kb/s, 24 fps, 24 tbn (default)Metadata:encoder : Lavc59.27.100 wrapped_avframeStream #0:1: Video: wrapped_avframe, yuv420p(progressive), 480x360 [SAR 1:1 DAR 4:3], q2-31, 200 kb/s, 24 fps, 24 tbnMetadata:encoder : Lavc59.27.100 wrapped_avframeStream #0:2: Audio: pcm_s16le, 44100 Hz, stereo, s16, 1411 kb/sMetadata:encoder : Lavc59.27.100 pcm_s16le
frame 1082 fps855 q-0.0 Lq-0.0 sizeN/A time00:00:45.12 bitrateN/A speed35.7x
video:997kB audio:7758kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_ssim_0 0x564524f58100] SSIM Y:1.000000 (inf) U:1.000000 (inf) V:1.000000 (inf) All:1.000000 (inf)
[Parsed_psnr_1 0x564524f58540] PSNR y:inf u:inf v:inf average:inf min:inf max:inf5.10 视频按时间拼接
使用 FFmpeg 的 concat工具 进行多个视频的拼接首先创建一个文本文件包含需要拼接的文件的列表命令ffmpeg -f concat -i filelist.txt -c copy concat.mp4如果文件列表编码格式不一致好像会出现问题
5.11 视频左右拼接
命令ffmpeg -ss 00:05:00 -i v1.mp4 -ss 00:05:00 -i v2.mp4 -filter_complex [0:v]cropiw/2:ih:0:0[v1];[1:v]cropiw/2:ih:iw/2:0[v2];[v1][v2]hstack[v3];[v3]drawboxiw/2-1:0:2:ih[v4] -map [v4] -map 0:a -c:a copy -c:v libx264 -t 00:01:00 -y out.mp4
5.12 打印视频帧的一些信息showinfo
命令 ffmpeg -hide_banner -i v.mp4 -vf showinfo -frames:v 1 -f null /dev/null
chy-cpabeubuntu:~/Videos$ ffmpeg -hide_banner -i merge_out.mp4 -vf showinfo -frames:v 1 -f null /dev/null
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from merge_out.mp4:Metadata:major_brand : isomminor_version : 512compatible_brands: isomiso2avc1mp41encoder : Lavf59.23.100Duration: 00:00:12.01, start: 0.000000, bitrate: 6159 kb/sStream #0:0[0x1](und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], 5965 kb/s, 23.98 fps, 23.98 tbr, 24k tbn (default)Metadata:handler_name : VideoHandlervendor_id : [0][0][0][0]Stream #0:1[0x2](und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 159 kb/s (default)Metadata:handler_name : ETI ISO Audio Media Handlervendor_id : [0][0][0][0]
Stream mapping:Stream #0:0 - #0:0 (h264 (native) - wrapped_avframe (native))Stream #0:1 - #0:1 (aac (native) - pcm_s16le (native))
Press [q] to stop, [?] for help
[Parsed_showinfo_0 0x55e361c8ca80] config in time_base: 1/24000, frame_rate: 24000/1001
[Parsed_showinfo_0 0x55e361c8ca80] config out time_base: 0/0, frame_rate: 0/0
[Parsed_showinfo_0 0x55e361c8ca80] n: 0 pts: 0 pts_time:0 pos: 39765 fmt:yuv420p sar:1/1 s:1920x1080 i:P iskey:1 type:I checksum:E0A9A036 plane_checksum:[24B5FB04 BEEA8563 06F21FC0] mean:[150 131 117] stdev:[48.8 2.5 2.7]
[Parsed_showinfo_0 0x55e361c8ca80] side data - User Data Unregistered:
[Parsed_showinfo_0 0x55e361c8ca80] UUIDdc45e9bd-e6d9-48b7-962c-d820d923eeef
[Parsed_showinfo_0 0x55e361c8ca80] User Data78323634202d20636f7265203135322072323835342065396135393033202d20482e3236342f4d5045472d342041564320636f646563202d20436f70796c65667420323030332d32303137202d20687474703a2f2f7777772e766964656f6c616e2e6f72672f783236342e68746d6c202d206f7074696f6e733a2063616261633d31207265663d33206465626c6f636b3d313a303a3020616e616c7973653d3078333a3078313133206d653d686578207375626d653d37207073793d31207073795f72643d312e30303a302e3030206d697865645f7265663d31206d655f72616e67653d3136206368726f6d615f6d653d31207472656c6c69733d31203878386463743d312063716d3d3020646561647a6f6e653d32312c313120666173745f70736b69703d31206368726f6d615f71705f6f66667365743d2d3220746872656164733d3132206c6f6f6b61686561645f746872656164733d3220736c696365645f746872656164733d30206e723d3020646563696d6174653d3120696e7465726c616365643d3020626c757261795f636f6d7061743d3020636f6e73747261696e65645f696e7472613d3020626672616d65733d3320625f707972616d69643d3220625f61646170743d3120625f626961733d30206469726563743d3120776569676874623d31206f70656e5f676f703d3020776569676874703d32206b6579696e743d323530206b6579696e745f6d696e3d3233207363656e656375743d343020696e7472615f726566726573683d302072635f6c6f6f6b61686561643d34302072633d637266206d62747265653d31206372663d32332e302071636f6d703d302e36302071706d696e3d302071706d61783d3639207170737465703d342069705f726174696f3d312e34302061713d313a312e303000
[Parsed_showinfo_0 0x55e361c8ca80]
[Parsed_showinfo_0 0x55e361c8ca80] color_range:unknown color_space:unknown color_primaries:unknown color_trc:unknown
Output #0, null, to /dev/null:Metadata:major_brand : isomminor_version : 512compatible_brands: isomiso2avc1mp41encoder : Lavf59.23.100Stream #0:0(und): Video: wrapped_avframe, yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q2-31, 200 kb/s, 23.98 fps, 23.98 tbn (default)Metadata:handler_name : VideoHandlervendor_id : [0][0][0][0]encoder : Lavc59.27.100 wrapped_avframeStream #0:1(und): Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s (default)Metadata:handler_name : ETI ISO Audio Media Handlervendor_id : [0][0][0][0]encoder : Lavc59.27.100 pcm_s16le
[Parsed_showinfo_0 0x55e361c8ca80] n: 1 pts: 1001 pts_time:0.0417083 pos: 226274 fmt:yuv420p sar:1/1 s:1920x1080 i:P iskey:0 type:B checksum:BEF57B91 plane_checksum:[90B31BAC 69027BD1 6593E405] mean:[149 131 117] stdev:[48.9 2.5 2.7]
[Parsed_showinfo_0 0x55e361c8ca80] color_range:unknown color_space:unknown color_primaries:unknown color_trc:unknown
frame 1 fps0.0 q-0.0 LsizeN/A time00:00:00.33 bitrateN/A speed3.57x
video:0kB audio:63kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown5.13 生成纯色的图片
ffmpeg -f lavfi -i colorBlack:640x480 -frames:v 1 -y black.jpgFFmpeg Filters Documentation
chy-cpabeubuntu:~/Videos$ ffmpeg -f lavfi -i colorblue:1920*1080 -frames:v 1 -y blue.jpg
ffmpeg version N-106797-g580fb6a8c9 Copyright (c) 2000-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, lavfi, from colorblue:1920*1080:Duration: N/A, start: 0.000000, bitrate: N/AStream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn
Stream mapping:Stream #0:0 - #0:0 (rawvideo (native) - mjpeg (native))
Press [q] to stop, [?] for help
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c59e32c0] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c5a26680] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c5a69600] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c5aaa680] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c5aed600] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c5b30580] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c5b71600] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c5bb4580] deprecated pixel format used, make sure you did set range correctly
[swscaler 0x55e4c59d5c40] [swscaler 0x55e4c5bf5600] deprecated pixel format used, make sure you did set range correctly
Output #0, image2, to blue.jpg:Metadata:encoder : Lavf59.23.100Stream #0:0: Video: mjpeg, yuvj420p(pc, progressive), 1920x1080 [SAR 1:1 DAR 16:9], q2-31, 200 kb/s, 25 fps, 25 tbnMetadata:encoder : Lavc59.27.100 mjpegSide data:cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
frame 1 fps0.0 q2.2 LsizeN/A time00:00:00.04 bitrateN/A speed1.62x
video:12kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown5.14 打印帧序号/pts到视频帧水印drawtext
打印帧序号 缺乏msyh.ttf文件 无法执行ffmpeg -i test.mp4 -vf drawtextfontcolorred:fontsize40:fontfilemsyh.ttf:line_spacing7:text%{n}:x50:y50 -vsync 0 -y out.mp4打印帧pts 缺乏msyh.ttf文件 无法执行ffmpeg -i test.mp4 -vf drawtextfontcolorred:fontsize30:fontfilemsyh.ttf:line_spacing7:text%{pts}:x50:y50 -vsync 0 -y out.mp4打印帧类型 ffmpeg -i test.mp4 -vf 缺乏msyh.ttf文件 无法执行 drawtextfontcolorred:fontsize20:fontfilemsyh.ttf:line_spacing7:text%{pict_type}:x50:y50 -vsync 0 -y out.mp4把视频的pts[时间戳]添加为视频水印精度到毫秒 存在问题ffmpeg -i test.mp4 -vf “drawtextfontsize60:text’%{pts:hms}’” -c:v libx264 -c copy -f mp4 output.mp4 -y
chy-cpabeubuntu:~/Videos$ ffmpeg -i test.mp4 -vf drawtextfontsize60:text%{pts:hms} -c:v libx264 -c:a copy -f mp4 out.mp4
[Parsed_drawtext_0 0x55c79b280d00] No font filename provided
[AVFilterGraph 0x55c79b27f9c0] Error initializing filter drawtext with args fontsize60:text%{pts:hms}
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #0:0
Conversion failed!
6音频解码编码
PCM原始数据和WAV格式转换
wav格式转换为PCM裸流ffmpeg -i xizong.wav -f f32le -ar 44100 -acodec pcm_f32le output_f32le.raw 参数说明 -f f32le … 浮点数32为小字端的采样格式-ar 44100 … 采样频率-ac 2 … 声道数量使用命令 将 MP3格式的数据转化为 wav格式的数据 $ ffmpeg -i sample.mp3 -acodec pcm_s16le -ar 44100 sample.wavaudio - Convert mp3 to wav using FFmpeg for VBR - Super User
7音频filter
倍速atempo
速度减半 ffmpeg -i input.mp3 -af atempo0.5 output.mp32倍速率 ffmpeg -i input.mp3 -af atempo2 output.mp3
8字幕相关
8.1 字幕文件转换
字幕文件的类型有很多常见的有 .srt 和 .ass文件等
//将.srt文件转换成.ass文件
ffmpeg -i subtitle.srt subtitle.ass将.ass文件转换成.srt文件
ffmpeg -i subtitle.ass subtitle.srt
8.2 集成字幕到视频文件
ffmpeg -i input.mp4 -i subtitles.srt -c:s mov_text -c:v copy -c:a copy output.mp4出问题
9ffplay命令
9.1 ffplay播放yuv视频数据
ffplay -f 文件格式 -pix_fmt 像素格式 -video_size 视频尺寸 文件名
示例
ffplay -f rawvideo -pix_fmt yuv420p -video_size 848x480 yuv_video
ffplay -f rawvideo -pixel_format yuyv422 -video_size 848*480 test_YUV.yuvffplay 播放yuv视频_sunxiaopengsun的博客-CSDN博客_ffplay播放yuv ffmpeg mp4转yuv - zhaogaojian - 博客园9.2 ffplay播放PCM音频数据
ffplay -f 格式名 -ac 声道数 -ar 采样率 文件名
示例
ffplay -f f32le -ac 1 -ar 48000 pcm_audio
例子 ffplay -f s16be -ac 1 -ar 16000 mp3_pcm.pcm 前提操作MP3 转 PCM 使用范例 大段数据格式 ffmpeg -i test.mp3 -f s16be -ar 16000 -ac 1 -acodec pcm_s16be pcm16k.pcm小端数据格式 ffmpeg -i test.mp3 -f s16le -ar 16000 -ac 1 -acodec pcm_s16le pcm16k.pcm说明: -acodec pcm_s16be输出pcm格式采用signed 16编码字节序为大尾端小尾端为le)-ar 16000: 采样率为16000-ac 1: 声道数为1 例子 ffmpeg -i 漠河舞厅.mp3 -f s16be -ar 16000 -ac 1 -acodec pcm_s16be mp3_pcm.pcmffmpeg mp3转pcm指令_keepGoing_keepGoing的博客-CSDN博客_ffmpeg mp3转pcm
9.3 ffplay播放音频并显示波形图
ffplay -showmode 1 simple.mp49.4 ffplay指定显示宽高
ffplay -x 1208 -y 720 avi_2_mp4.mp4
10ffprobe命令
10.1 ffprobe查看媒体文件的信息
ffprobe target.mp4 -show_format -show_streams -print_format json -loglevel fatal -print_format json: 结果以json格式呈现-show_format: 打印封装格式信息在format节点中 -show_streams: 打印流信息在streams节点中
chy-cpabeubuntu:~/Videos$ ffprobe test.mp4 -show_format -show_streams -print_format json -loglevel fatal
{streams: [{index: 0,codec_name: h264,codec_long_name: H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10,profile: High,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: 1,sample_aspect_ratio: 1:1,display_aspect_ratio: 16:9,pix_fmt: yuv420p,level: 40,color_range: tv,color_space: bt709,color_transfer: bt709,color_primaries: bt709,chroma_location: left,field_order: progressive,refs: 1,is_avc: true,nal_length_size: 4,id: 0x1,r_frame_rate: 24000/1001,avg_frame_rate: 24000/1001,time_base: 1/24000,start_pts: 0,start_time: 0.000000,duration_ts: 560560,duration: 23.356667,bit_rate: 6147092,bits_per_raw_sample: 8,nb_frames: 560,extradata_size: 60,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,captions: 0,descriptions: 0,metadata: 0,dependent: 0,still_image: 0},tags: {creation_time: 2021-02-14T02:11:02.000000Z,language: und,handler_name: ETI ISO Video Media Handler,vendor_id: [0][0][0][0],encoder: Elemental H.264}},{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,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: 1118656,duration: 23.305333,bit_rate: 160137,nb_frames: 1094,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,captions: 0,descriptions: 0,metadata: 0,dependent: 0,still_image: 0},tags: {creation_time: 2021-02-14T02:11:02.000000Z,language: und,handler_name: ETI ISO Audio Media Handler,vendor_id: [0][0][0][0]}}],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: 23.356667,size: 18431676,bit_rate: 6313118,probe_score: 100,tags: {major_brand: M4V ,minor_version: 1,compatible_brands: isomavc1mp42,creation_time: 2021-02-14T02:11:02.000000Z}}
}10.2 ffprobe查看时间戳
首先将MP4视频数据转化为 ts数据ffmpeg -i input.mp4 output.ts查看视频dts
ffprobe -show_packets -select_streams v 1.ts | grep dts_time
chy-cpabeubuntu:~/Videos$ ffprobe -show_packets -select_streams v test_ts.ts | grep dts_time
ffprobe version N-106797-g580fb6a8c9 Copyright (c) 2007-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, mpegts, from test_ts.ts:Duration: 00:00:23.37, start: 1.431689, bitrate: 3724 kb/sProgram 1 Metadata:service_name : Service01service_provider: FFmpegStream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbnSide data:cpb: bitrate max/min/avg: 0/0/0 buffer size: 49152 vbv_delay: N/AStream #0:1[0x101](und): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 384 kb/s
dts_time1.400000
dts_time1.441711
dts_time1.483422
dts_time1.525133
dts_time1.566833
dts_time1.608544
dts_time1.650256
dts_time1.691967
dts_time1.733667
dts_time1.775378
dts_time1.817089
dts_time1.858800
dts_time1.900500
dts_time1.942211
dts_time1.983922
dts_time2.025633
dts_time2.067333
dts_time2.109044
dts_time2.150756
dts_time2.192467
dts_time2.234167
dts_time2.275878
dts_time2.317589
dts_time2.359300
dts_time2.401000
dts_time2.442711
dts_time2.484422
dts_time2.526133
dts_time2.567833
dts_time2.609544
dts_time2.651256
dts_time2.692967
dts_time2.734667
dts_time2.776378
dts_time2.818089
dts_time2.859800
dts_time2.901500
dts_time2.943211
dts_time2.984922
dts_time3.026633
dts_time3.068333
dts_time3.110044
dts_time3.151756
dts_time3.193467
dts_time3.235167
dts_time3.276878
dts_time3.318589
dts_time3.360300
dts_time3.402000
dts_time3.443711
dts_time3.485422
dts_time3.527133
dts_time3.568833
dts_time3.610544
dts_time3.652256
dts_time3.693967
dts_time3.735667
dts_time3.777378
dts_time3.819089
dts_time3.860800
dts_time3.902500
dts_time3.944211
dts_time3.985922
dts_time4.027633
dts_time4.069333
dts_time4.111044
dts_time4.152756
dts_time4.194467
dts_time4.236167
dts_time4.277878
dts_time4.319589
dts_time4.361300
dts_time4.403000
dts_time4.444711
dts_time4.486422
dts_time4.528133
dts_time4.569833
dts_time4.611544
dts_time4.653256
dts_time4.694967
dts_time4.736667
dts_time4.778378
dts_time4.820089
dts_time4.861800
dts_time4.903500
dts_time4.945211
dts_time4.986922
dts_time5.028633
dts_time5.070333
dts_time5.112044
dts_time5.153756
dts_time5.195467
dts_time5.237167
dts_time5.278878
dts_time5.320589
dts_time5.362300
dts_time5.404000
dts_time5.445711
dts_time5.487422
dts_time5.529133
dts_time5.570833
dts_time5.612544
dts_time5.654256
dts_time5.695967
dts_time5.737667
dts_time5.779378
dts_time5.821089
dts_time5.862800
dts_time5.904500
dts_time5.946211
dts_time5.987922
dts_time6.029633
dts_time6.071333
dts_time6.113044
dts_time6.154756
dts_time6.196467
dts_time6.238167
dts_time6.279878
dts_time6.321589
dts_time6.363300
dts_time6.405000
dts_time6.446711
dts_time6.488422
dts_time6.530133
dts_time6.571833
dts_time6.613544
dts_time6.655256
dts_time6.696967
dts_time6.738667
dts_time6.780378
dts_time6.822089
dts_time6.863800
dts_time6.905500
dts_time6.947211
dts_time6.988922
dts_time7.030633
dts_time7.072333
dts_time7.114044
dts_time7.155756
dts_time7.197467
dts_time7.239167
dts_time7.280878
dts_time7.322589
dts_time7.364300
dts_time7.406000
dts_time7.447711
dts_time7.489422
dts_time7.531133
dts_time7.572833
dts_time7.614544
dts_time7.656256
dts_time7.697967
dts_time7.739667
dts_time7.781378
dts_time7.823089
dts_time7.864800
dts_time7.906500
dts_time7.948211
dts_time7.989922
dts_time8.031633
dts_time8.073333
dts_time8.115044
dts_time8.156756
dts_time8.198467
dts_time8.240167
dts_time8.281878
dts_time8.323589
dts_time8.365300
dts_time8.407000
dts_time8.448711
dts_time8.490422
dts_time8.532133
dts_time8.573833
dts_time8.615544
dts_time8.657256
dts_time8.698967
dts_time8.740667
dts_time8.782378
dts_time8.824089
dts_time8.865800
dts_time8.907500
dts_time8.949211
dts_time8.990922
dts_time9.032633
dts_time9.074333
dts_time9.116044
dts_time9.157756
dts_time9.199467
dts_time9.241167
dts_time9.282878
dts_time9.324589
dts_time9.366300
dts_time9.408000
dts_time9.449711
dts_time9.491422
dts_time9.533133
dts_time9.574833
dts_time9.616544
dts_time9.658256
dts_time9.699967
dts_time9.741667
dts_time9.783378
dts_time9.825089
dts_time9.866800
dts_time9.908500
dts_time9.950211
dts_time9.991922
dts_time10.033633
dts_time10.075333
dts_time10.117044
dts_time10.158756
dts_time10.200467
dts_time10.242167
dts_time10.283878
dts_time10.325589
dts_time10.367300
dts_time10.409000
dts_time10.450711
dts_time10.492422
dts_time10.534133
dts_time10.575833
dts_time10.617544
dts_time10.659256
dts_time10.700967
dts_time10.742667
dts_time10.784378
dts_time10.826089
dts_time10.867800
dts_time10.909500
dts_time10.951211
dts_time10.992922
dts_time11.034633
dts_time11.076333
dts_time11.118044
dts_time11.159756
dts_time11.201467
dts_time11.243167
dts_time11.284878
dts_time11.326589
dts_time11.368300
dts_time11.410000
dts_time11.451711
dts_time11.493422
dts_time11.535133
dts_time11.576833
dts_time11.618544
dts_time11.660256
dts_time11.701967
dts_time11.743667
dts_time11.785378
dts_time11.827089
dts_time11.868800
dts_time11.910500
dts_time11.952211
dts_time11.993922
dts_time12.035633
dts_time12.077333
dts_time12.119044
dts_time12.160756
dts_time12.202467
dts_time12.244167
dts_time12.285878
dts_time12.327589
dts_time12.369300
dts_time12.411000
dts_time12.452711
dts_time12.494422
dts_time12.536133
dts_time12.577833
dts_time12.619544
dts_time12.661256
dts_time12.702967
dts_time12.744667
dts_time12.786378
dts_time12.828089
dts_time12.869800
dts_time12.911500
dts_time12.953211
dts_time12.994922
dts_time13.036633
dts_time13.078333
dts_time13.120044
dts_time13.161756
dts_time13.203467
dts_time13.245167
dts_time13.286878
dts_time13.328589
dts_time13.370300
dts_time13.412000
dts_time13.453711
dts_time13.495422
dts_time13.537133
dts_time13.578833
dts_time13.620544
dts_time13.662256
dts_time13.703967
dts_time13.745667
dts_time13.787378
dts_time13.829089
dts_time13.870800
dts_time13.912500
dts_time13.954211
dts_time13.995922
dts_time14.037633
dts_time14.079333
dts_time14.121044
dts_time14.162756
dts_time14.204467
dts_time14.246167
dts_time14.287878
dts_time14.329589
dts_time14.371300
dts_time14.413000
dts_time14.454711
dts_time14.496422
dts_time14.538133
dts_time14.579833
dts_time14.621544
dts_time14.663256
dts_time14.704967
dts_time14.746667
dts_time14.788378
dts_time14.830089
dts_time14.871800
dts_time14.913500
dts_time14.955211
dts_time14.996922
dts_time15.038633
dts_time15.080333
dts_time15.122044
dts_time15.163756
dts_time15.205467
dts_time15.247167
dts_time15.288878
dts_time15.330589
dts_time15.372300
dts_time15.414000
dts_time15.455711
dts_time15.497422
dts_time15.539133
dts_time15.580833
dts_time15.622544
dts_time15.664256
dts_time15.705967
dts_time15.747667
dts_time15.789378
dts_time15.831089
dts_time15.872800
dts_time15.914500
dts_time15.956211
dts_time15.997922
dts_time16.039633
dts_time16.081333
dts_time16.123044
dts_time16.164756
dts_time16.206467
dts_time16.248167
dts_time16.289878
dts_time16.331589
dts_time16.373300
dts_time16.415000
dts_time16.456711
dts_time16.498422
dts_time16.540133
dts_time16.581833
dts_time16.623544
dts_time16.665256
dts_time16.706967
dts_time16.748667
dts_time16.790378
dts_time16.832089
dts_time16.873800
dts_time16.915500
dts_time16.957211
dts_time16.998922
dts_time17.040633
dts_time17.082333
dts_time17.124044
dts_time17.165756
dts_time17.207467
dts_time17.249167
dts_time17.290878
dts_time17.332589
dts_time17.374300
dts_time17.416000
dts_time17.457711
dts_time17.499422
dts_time17.541133
dts_time17.582833
dts_time17.624544
dts_time17.666256
dts_time17.707967
dts_time17.749667
dts_time17.791378
dts_time17.833089
dts_time17.874800
dts_time17.916500
dts_time17.958211
dts_time17.999922
dts_time18.041633
dts_time18.083333
dts_time18.125044
dts_time18.166756
dts_time18.208467
dts_time18.250167
dts_time18.291878
dts_time18.333589
dts_time18.375300
dts_time18.417000
dts_time18.458711
dts_time18.500422
dts_time18.542133
dts_time18.583833
dts_time18.625544
dts_time18.667256
dts_time18.708967
dts_time18.750667
dts_time18.792378
dts_time18.834089
dts_time18.875800
dts_time18.917500
dts_time18.959211
dts_time19.000922
dts_time19.042633
dts_time19.084333
dts_time19.126044
dts_time19.167756
dts_time19.209467
dts_time19.251167
dts_time19.292878
dts_time19.334589
dts_time19.376300
dts_time19.418000
dts_time19.459711
dts_time19.501422
dts_time19.543133
dts_time19.584833
dts_time19.626544
dts_time19.668256
dts_time19.709967
dts_time19.751667
dts_time19.793378
dts_time19.835089
dts_time19.876800
dts_time19.918500
dts_time19.960211
dts_time20.001922
dts_time20.043633
dts_time20.085333
dts_time20.127044
dts_time20.168756
dts_time20.210467
dts_time20.252167
dts_time20.293878
dts_time20.335589
dts_time20.377300
dts_time20.419000
dts_time20.460711
dts_time20.502422
dts_time20.544133
dts_time20.585833
dts_time20.627544
dts_time20.669256
dts_time20.710967
dts_time20.752667
dts_time20.794378
dts_time20.836089
dts_time20.877800
dts_time20.919500
dts_time20.961211
dts_time21.002922
dts_time21.044633
dts_time21.086333
dts_time21.128044
dts_time21.169756
dts_time21.211467
dts_time21.253167
dts_time21.294878
dts_time21.336589
dts_time21.378300
dts_time21.420000
dts_time21.461711
dts_time21.503422
dts_time21.545133
dts_time21.586833
dts_time21.628544
dts_time21.670256
dts_time21.711967
dts_time21.753667
dts_time21.795378
dts_time21.837089
dts_time21.878800
dts_time21.920500
dts_time21.962211
dts_time22.003922
dts_time22.045633
dts_time22.087333
dts_time22.129044
dts_time22.170756
dts_time22.212467
dts_time22.254167
dts_time22.295878
dts_time22.337589
dts_time22.379300
dts_time22.421000
dts_time22.462711
dts_time22.504422
dts_time22.546133
dts_time22.587833
dts_time22.629544
dts_time22.671256
dts_time22.712967
dts_time22.754667
dts_time22.796378
dts_time22.838089
dts_time22.879800
dts_time22.921500
dts_time22.963211
dts_time23.004922
dts_time23.046633
dts_time23.088333
dts_time23.130044
dts_time23.171756
dts_time23.213467
dts_time23.255167
dts_time23.296878
dts_time23.338589
dts_time23.380300
dts_time23.422000
dts_time23.463711
dts_time23.505422
dts_time23.547133
dts_time23.588833
dts_time23.630544
dts_time23.672256
dts_time23.713967
dts_time23.755667
dts_time23.797378
dts_time23.839089
dts_time23.880800
dts_time23.922500
dts_time23.964211
dts_time24.005922
dts_time24.047633
dts_time24.089333
dts_time24.131044
dts_time24.172756
dts_time24.214467
dts_time24.256167
dts_time24.297878
dts_time24.339589
dts_time24.381300
dts_time24.423000
dts_time24.464711
dts_time24.506422
dts_time24.548133
dts_time24.589833
dts_time24.631544
dts_time24.673256
dts_time24.714967查看视频pts
ffprobe -show_packets -select_streams v 1.ts | grep pts_time
chy-cpabeubuntu:~/Videos$ ffprobe -show_packets -select_streams v test_ts.ts | grep pts_time
ffprobe version N-106797-g580fb6a8c9 Copyright (c) 2007-2022 the FFmpeg developersbuilt with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)configuration: --prefix/home/chy-cpabe/ffmpeg_build --pkg-config-flags--static --extra-cflags-I/home/chy-cpabe/ffmpeg_build/include --extra-ldflags-L/home/chy-cpabe/ffmpeg_build/lib --extra-libs-lpthread -lm --ldg --bindir/home/chy-cpabe/bin --enable-gpl --enable-gnutls --enable-libass --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfreelibavutil 57. 24.101 / 57. 24.101libavcodec 59. 27.100 / 59. 27.100libavformat 59. 23.100 / 59. 23.100libavdevice 59. 6.100 / 59. 6.100libavfilter 8. 37.100 / 8. 37.100libswscale 6. 6.100 / 6. 6.100libswresample 4. 6.100 / 4. 6.100libpostproc 56. 5.100 / 56. 5.100
Input #0, mpegts, from test_ts.ts:Duration: 00:00:23.37, start: 1.431689, bitrate: 3724 kb/sProgram 1 Metadata:service_name : Service01service_provider: FFmpegStream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, bt709, progressive), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 90k tbnSide data:cpb: bitrate max/min/avg: 0/0/0 buffer size: 49152 vbv_delay: N/AStream #0:1[0x101](und): Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, fltp, 384 kb/s
pts_time1.441711
pts_time1.483422
pts_time1.525133
pts_time1.566833
pts_time1.608544
pts_time1.650256
pts_time1.691967
pts_time1.733667
pts_time1.775378
pts_time1.817089
pts_time1.858800
pts_time1.900500
pts_time1.942211
pts_time1.983922
pts_time2.025633
pts_time2.067333
pts_time2.109044
pts_time2.150756
pts_time2.192467
pts_time2.234167
pts_time2.275878
pts_time2.317589
pts_time2.359300
pts_time2.401000
pts_time2.442711
pts_time2.484422
pts_time2.526133
pts_time2.567833
pts_time2.609544
pts_time2.651256
pts_time2.692967
pts_time2.734667
pts_time2.776378
pts_time2.818089
pts_time2.859800
pts_time2.901500
pts_time2.943211
pts_time2.984922
pts_time3.026633
pts_time3.068333
pts_time3.110044
pts_time3.151756
pts_time3.193467
pts_time3.235167
pts_time3.276878
pts_time3.318589
pts_time3.360300
pts_time3.402000
pts_time3.443711
pts_time3.485422
pts_time3.527133
pts_time3.568833
pts_time3.610544
pts_time3.652256
pts_time3.693967
pts_time3.735667
pts_time3.777378
pts_time3.819089
pts_time3.860800
pts_time3.902500
pts_time3.944211
pts_time3.985922
pts_time4.027633
pts_time4.069333
pts_time4.111044
pts_time4.152756
pts_time4.194467
pts_time4.236167
pts_time4.277878
pts_time4.319589
pts_time4.361300
pts_time4.403000
pts_time4.444711
pts_time4.486422
pts_time4.528133
pts_time4.569833
pts_time4.611544
pts_time4.653256
pts_time4.694967
pts_time4.736667
pts_time4.778378
pts_time4.820089
pts_time4.861800
pts_time4.903500
pts_time4.945211
pts_time4.986922
pts_time5.028633
pts_time5.070333
pts_time5.112044
pts_time5.153756
pts_time5.195467
pts_time5.237167
pts_time5.278878
pts_time5.320589
pts_time5.362300
pts_time5.404000
pts_time5.445711
pts_time5.487422
pts_time5.529133
pts_time5.570833
pts_time5.612544
pts_time5.654256
pts_time5.695967
pts_time5.737667
pts_time5.779378
pts_time5.821089
pts_time5.862800
pts_time5.904500
pts_time5.946211
pts_time5.987922
pts_time6.029633
pts_time6.071333
pts_time6.113044
pts_time6.154756
pts_time6.196467
pts_time6.238167
pts_time6.279878
pts_time6.321589
pts_time6.363300
pts_time6.405000
pts_time6.446711
pts_time6.488422
pts_time6.530133
pts_time6.571833
pts_time6.613544
pts_time6.655256
pts_time6.696967
pts_time6.738667
pts_time6.780378
pts_time6.822089
pts_time6.863800
pts_time6.905500
pts_time6.947211
pts_time6.988922
pts_time7.030633
pts_time7.072333
pts_time7.114044
pts_time7.155756
pts_time7.197467
pts_time7.239167
pts_time7.280878
pts_time7.322589
pts_time7.364300
pts_time7.406000
pts_time7.447711
pts_time7.489422
pts_time7.531133
pts_time7.572833
pts_time7.614544
pts_time7.656256
pts_time7.697967
pts_time7.739667
pts_time7.781378
pts_time7.823089
pts_time7.864800
pts_time7.906500
pts_time7.948211
pts_time7.989922
pts_time8.031633
pts_time8.073333
pts_time8.115044
pts_time8.156756
pts_time8.198467
pts_time8.240167
pts_time8.281878
pts_time8.323589
pts_time8.365300
pts_time8.407000
pts_time8.448711
pts_time8.490422
pts_time8.532133
pts_time8.573833
pts_time8.615544
pts_time8.657256
pts_time8.698967
pts_time8.740667
pts_time8.782378
pts_time8.824089
pts_time8.865800
pts_time8.907500
pts_time8.949211
pts_time8.990922
pts_time9.032633
pts_time9.074333
pts_time9.116044
pts_time9.157756
pts_time9.199467
pts_time9.241167
pts_time9.282878
pts_time9.324589
pts_time9.366300
pts_time9.408000
pts_time9.449711
pts_time9.491422
pts_time9.533133
pts_time9.574833
pts_time9.616544
pts_time9.658256
pts_time9.699967
pts_time9.741667
pts_time9.783378
pts_time9.825089
pts_time9.866800
pts_time9.908500
pts_time9.950211
pts_time9.991922
pts_time10.033633
pts_time10.075333
pts_time10.117044
pts_time10.158756
pts_time10.200467
pts_time10.242167
pts_time10.283878
pts_time10.325589
pts_time10.367300
pts_time10.409000
pts_time10.450711
pts_time10.492422
pts_time10.534133
pts_time10.575833
pts_time10.617544
pts_time10.659256
pts_time10.700967
pts_time10.742667
pts_time10.784378
pts_time10.826089
pts_time10.867800
pts_time10.909500
pts_time10.951211
pts_time10.992922
pts_time11.034633
pts_time11.076333
pts_time11.118044
pts_time11.159756
pts_time11.201467
pts_time11.243167
pts_time11.284878
pts_time11.326589
pts_time11.368300
pts_time11.410000
pts_time11.451711
pts_time11.493422
pts_time11.535133
pts_time11.576833
pts_time11.618544
pts_time11.660256
pts_time11.701967
pts_time11.743667
pts_time11.785378
pts_time11.827089
pts_time11.868800
pts_time11.910500
pts_time11.952211
pts_time11.993922
pts_time12.035633
pts_time12.077333
pts_time12.119044
pts_time12.160756
pts_time12.202467
pts_time12.244167
pts_time12.285878
pts_time12.327589
pts_time12.369300
pts_time12.411000
pts_time12.452711
pts_time12.494422
pts_time12.536133
pts_time12.577833
pts_time12.619544
pts_time12.661256
pts_time12.702967
pts_time12.744667
pts_time12.786378
pts_time12.828089
pts_time12.869800
pts_time12.911500
pts_time12.953211
pts_time12.994922
pts_time13.036633
pts_time13.078333
pts_time13.120044
pts_time13.161756
pts_time13.203467
pts_time13.245167
pts_time13.286878
pts_time13.328589
pts_time13.370300
pts_time13.412000
pts_time13.453711
pts_time13.495422
pts_time13.537133
pts_time13.578833
pts_time13.620544
pts_time13.662256
pts_time13.703967
pts_time13.745667
pts_time13.787378
pts_time13.829089
pts_time13.870800
pts_time13.912500
pts_time13.954211
pts_time13.995922
pts_time14.037633
pts_time14.079333
pts_time14.121044
pts_time14.162756
pts_time14.204467
pts_time14.246167
pts_time14.287878
pts_time14.329589
pts_time14.371300
pts_time14.413000
pts_time14.454711
pts_time14.496422
pts_time14.538133
pts_time14.579833
pts_time14.621544
pts_time14.663256
pts_time14.704967
pts_time14.746667
pts_time14.788378
pts_time14.830089
pts_time14.871800
pts_time14.913500
pts_time14.955211
pts_time14.996922
pts_time15.038633
pts_time15.080333
pts_time15.122044
pts_time15.163756
pts_time15.205467
pts_time15.247167
pts_time15.288878
pts_time15.330589
pts_time15.372300
pts_time15.414000
pts_time15.455711
pts_time15.497422
pts_time15.539133
pts_time15.580833
pts_time15.622544
pts_time15.664256
pts_time15.705967
pts_time15.747667
pts_time15.789378
pts_time15.831089
pts_time15.872800
pts_time15.914500
pts_time15.956211
pts_time15.997922
pts_time16.039633
pts_time16.081333
pts_time16.123044
pts_time16.164756
pts_time16.206467
pts_time16.248167
pts_time16.289878
pts_time16.331589
pts_time16.373300
pts_time16.415000
pts_time16.456711
pts_time16.498422
pts_time16.540133
pts_time16.581833
pts_time16.623544
pts_time16.665256
pts_time16.706967
pts_time16.748667
pts_time16.790378
pts_time16.832089
pts_time16.873800
pts_time16.915500
pts_time16.957211
pts_time16.998922
pts_time17.040633
pts_time17.082333
pts_time17.124044
pts_time17.165756
pts_time17.207467
pts_time17.249167
pts_time17.290878
pts_time17.332589
pts_time17.374300
pts_time17.416000
pts_time17.457711
pts_time17.499422
pts_time17.541133
pts_time17.582833
pts_time17.624544
pts_time17.666256
pts_time17.707967
pts_time17.749667
pts_time17.791378
pts_time17.833089
pts_time17.874800
pts_time17.916500
pts_time17.958211
pts_time17.999922
pts_time18.041633
pts_time18.083333
pts_time18.125044
pts_time18.166756
pts_time18.208467
pts_time18.250167
pts_time18.291878
pts_time18.333589
pts_time18.375300
pts_time18.417000
pts_time18.458711
pts_time18.500422
pts_time18.542133
pts_time18.583833
pts_time18.625544
pts_time18.667256
pts_time18.708967
pts_time18.750667
pts_time18.792378
pts_time18.834089
pts_time18.875800
pts_time18.917500
pts_time18.959211
pts_time19.000922
pts_time19.042633
pts_time19.084333
pts_time19.126044
pts_time19.167756
pts_time19.209467
pts_time19.251167
pts_time19.292878
pts_time19.334589
pts_time19.376300
pts_time19.418000
pts_time19.459711
pts_time19.501422
pts_time19.543133
pts_time19.584833
pts_time19.626544
pts_time19.668256
pts_time19.709967
pts_time19.751667
pts_time19.793378
pts_time19.835089
pts_time19.876800
pts_time19.918500
pts_time19.960211
pts_time20.001922
pts_time20.043633
pts_time20.085333
pts_time20.127044
pts_time20.168756
pts_time20.210467
pts_time20.252167
pts_time20.293878
pts_time20.335589
pts_time20.377300
pts_time20.419000
pts_time20.460711
pts_time20.502422
pts_time20.544133
pts_time20.585833
pts_time20.627544
pts_time20.669256
pts_time20.710967
pts_time20.752667
pts_time20.794378
pts_time20.836089
pts_time20.877800
pts_time20.919500
pts_time20.961211
pts_time21.002922
pts_time21.044633
pts_time21.086333
pts_time21.128044
pts_time21.169756
pts_time21.211467
pts_time21.253167
pts_time21.294878
pts_time21.336589
pts_time21.378300
pts_time21.420000
pts_time21.461711
pts_time21.503422
pts_time21.545133
pts_time21.586833
pts_time21.628544
pts_time21.670256
pts_time21.711967
pts_time21.753667
pts_time21.795378
pts_time21.837089
pts_time21.878800
pts_time21.920500
pts_time21.962211
pts_time22.003922
pts_time22.045633
pts_time22.087333
pts_time22.129044
pts_time22.170756
pts_time22.212467
pts_time22.254167
pts_time22.295878
pts_time22.337589
pts_time22.379300
pts_time22.421000
pts_time22.462711
pts_time22.504422
pts_time22.546133
pts_time22.587833
pts_time22.629544
pts_time22.671256
pts_time22.712967
pts_time22.754667
pts_time22.796378
pts_time22.838089
pts_time22.879800
pts_time22.921500
pts_time22.963211
pts_time23.004922
pts_time23.046633
pts_time23.088333
pts_time23.130044
pts_time23.171756
pts_time23.213467
pts_time23.255167
pts_time23.296878
pts_time23.338589
pts_time23.380300
pts_time23.422000
pts_time23.463711
pts_time23.505422
pts_time23.547133
pts_time23.588833
pts_time23.630544
pts_time23.672256
pts_time23.713967
pts_time23.755667
pts_time23.797378
pts_time23.839089
pts_time23.880800
pts_time23.922500
pts_time23.964211
pts_time24.005922
pts_time24.047633
pts_time24.089333
pts_time24.131044
pts_time24.172756
pts_time24.214467
pts_time24.256167
pts_time24.297878
pts_time24.339589
pts_time24.381300
pts_time24.423000
pts_time24.464711
pts_time24.506422
pts_time24.548133
pts_time24.589833
pts_time24.631544
pts_time24.673256
pts_time24.714967
pts_time24.756667查看视频流前几帧的pts
ffprobe -v error -of compact -read_intervals %#10 -show_packets -select_streams v 1.ts
chy-cpabeubuntu:~/Videos$ ffprobe -v error -of compact -read_intervals %#10 -show_packets -select_streams v test_ts.ts
packet|codec_typevideo|stream_index0|pts129754|pts_time1.441711|dts126000|dts_time1.400000|duration3753|duration_time0.041700|size111660|pos564|flagsK_|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts133508|pts_time1.483422|dts129754|dts_time1.441711|duration3753|duration_time0.041700|size146109|pos114680|flags__|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts137262|pts_time1.525133|dts133508|dts_time1.483422|duration3753|duration_time0.041700|size108658|pos266584|flags__|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts141015|pts_time1.566833|dts137262|dts_time1.525133|duration3753|duration_time0.041700|size56978|pos378068|flags__|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts144769|pts_time1.608544|dts141015|dts_time1.566833|duration3753|duration_time0.041700|size32869|pos438792|flags__|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts148523|pts_time1.650256|dts144769|dts_time1.608544|duration3753|duration_time0.041700|size20103|pos474888|flags__|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts152277|pts_time1.691967|dts148523|dts_time1.650256|duration3753|duration_time0.041700|size16245|pos498388|flags__|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts156030|pts_time1.733667|dts152277|dts_time1.691967|duration3753|duration_time0.041700|size9676|pos517564|flags__|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts159784|pts_time1.775378|dts156030|dts_time1.733667|duration3753|duration_time0.041700|size7591|pos529972|flags__|side_data|side_data_typeMPEGTS Stream ID|id224packet|codec_typevideo|stream_index0|pts163538|pts_time1.817089|dts159784|dts_time1.775378|duration3753|duration_time0.041700|size6535|pos540688|flags__|side_data|side_data_typeMPEGTS Stream ID|id224查看关键帧的pts
ffprobe -v error -select_streams v:0 -show_entries packetpts_time,flags -of csvprint_section0 input.mp4 | awk -F, /K/ {print $1}
查看关键帧 帧间 的间隔
./ffprobe -of compact -select_streams v -show_packets test.mp4| grep K_ | awk BEGIN{FS|;last-1}{split($5,a,); if(last ! -1) {print Keframe pos: a[2] , Interval: a[2]-last seconds} else {print Keyframe: a[2]}; lasta[2]}
11其他
11.1 ffmpeg或ffplay 打开 DEBUG 日志输出
ffplay -v debug $URLAPI中开启debug日志 av_log_set_level(AV_LOG_DEBUG);
11.2 FFmpeg命令日志输出到文件
执行ffmpeg或者ffprobe输出重定向到文件的时候发现文件是空的。 可以采用下面的方式。ffprobe xxx file 21shell输出分好多种0表示键盘输出1表示屏幕输出2表示错误输出。cmd file只是把屏幕输出重定向到文件中。调用ffmpeg相关命令打印信息都被终端认为是错误输出但是一般情况下这种信息也会输出到屏幕上,所以我们可以在屏幕上看到它。但是当我们想重定向到文件中却被系统认为是错误输出而忽略。21表示错误输出重定向到屏幕输出。标明其后面跟的是一个文件描述符而不是一个文件名。
11.3 打印支持DirectShow的设备列表
打印支持DirectShow的设备列表 ffmpeg -list_devices true -f dshow -i dummy打开名称为“Lenovo EasyCamera”的摄像头 ffmpeg -f dshow -i videoLenovo EasyCamera