一、FFmpeg命令使用
1、ffmpeg通过-i参数将20200107091837_front.ts作为输入源输入,然后进行转码与转封装操作,最后输出得到output.avi文件
G:\wangqi\work\video>ffmpeg -i 20200107091837_front.ts output.avi
输出如下内容:
ffmpeg version git-2020-01-06-1e3f4b5 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20191125
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 38.100 / 56. 38.100
libavcodec 58. 65.102 / 58. 65.102
libavformat 58. 35.101 / 58. 35.101
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 70.101 / 7. 70.101
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
[aac @ 000001872d391600] Input buffer exhausted before END element found
Input #0, mpegts, from '20200107091837_front.ts':
Duration: 00:00:59.92, start: 0.000000, bitrate: 10140 kb/s
Program 1
Stream #0:0[0x1e1]: Audio: aac (LC) ([15][0][0][0] / 0x000F), 8000 Hz, mono, fltp, 12 kb/s
Stream #0:1[0x1e2]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p(progressive), 1280x720, 30 tbr, 90k tbn, 180k tbc
File 'output.avi' already exists. Overwrite? [y/N] y
Stream mapping:
Stream #0:1 -> #0:0 (h264 (native) -> mpeg4 (native))
Stream #0:0 -> #0:1 (aac (native) -> mp3 (libmp3lame))
Press [q] to stop, [?] for help
[aac @ 000001872e001b00] Input buffer exhausted before END element found
Error while decoding stream #0:0: Invalid data found when processing input
Output #0, avi, to 'output.avi':
Metadata:
ISFT : Lavf58.35.101
Stream #0:0: Video: mpeg4 (FMP4 / 0x34504D46), yuv420p, 1280x720, q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc
Metadata:
encoder : Lavc58.65.102 mpeg4
Side data:
cpb: bitrate max/min/avg: 0/0/200000 buffer size: 0 vbv_delay: N/A
Stream #0:1: Audio: mp3 (libmp3lame) (U[0][0][0] / 0x0055), 8000 Hz, mono, fltp
Metadata:
encoder : Lavc58.65.102 libmp3lame
frame= 1786 fps=425 q=31.0 Lsize= 4260kB time=00:00:59.90 bitrate= 582.5kbits/s speed=14.3x
video:4129kB audio:59kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1.724805%
2、ffprobe 命令分析媒体文件中包的长度、包的类型、帧的信息
G:\wangqi\work\video>ffprobe -show_streams output.avi
输出如下内容:
ffprobe version git-2020-01-06-1e3f4b5 Copyright (c) 2007-2020 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20191125
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 38.100 / 56. 38.100
libavcodec 58. 65.102 / 58. 65.102
libavformat 58. 35.101 / 58. 35.101
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 70.101 / 7. 70.101
libswscale 5. 6.100 / 5. 6.100
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, avi, from 'output.avi':
Metadata:
encoder : Lavf58.35.101
Duration: 00:01:00.05, start: 0.000000, bitrate: 581 kb/s
Stream #0:0: Video: mpeg4 (Simple Profile) (FMP4 / 0x34504D46), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 565 kb/s, 30 fps, 30 tbr, 30 tbn, 30 tbc
Stream #0:1: Audio: mp3 (U[0][0][0] / 0x0055), 8000 Hz, mono, fltp, 8 kb/s
//视频信息
[STREAM]
index=0
codec_name=mpeg4
codec_long_name=MPEG-4 part 2
profile=Simple Profile
codec_type=video
codec_time_base=1/30
codec_tag_string=FMP4
codec_tag=0x34504d46
width=1280
height=720
coded_width=1280
coded_height=720
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=1
color_range=unknown
color_space=unknown
color_transfer=unknown
color_primaries=unknown
chroma_location=left
field_order=unknown
timecode=N/A
refs=1
quarter_sample=false
divx_packed=false
id=N/A
r_frame_rate=30/1
avg_frame_rate=30/1
time_base=1/30
start_pts=0
start_time=0.000000
duration_ts=1796
duration=59.866667
bit_rate=565316
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=1796
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
//音频信息
[STREAM]
index=1
codec_name=mp3
codec_long_name=MP3 (MPEG audio layer 3)
profile=unknown
codec_type=audio
codec_time_base=1/8000
codec_tag_string=U[0][0][0]
codec_tag=0x0055
sample_fmt=fltp
sample_rate=8000
channels=1
channel_layout=mono
bits_per_sample=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=9/125
start_pts=0
start_time=0.000000
duration_ts=834
duration=60.048000
bit_rate=8010
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=834
nb_read_frames=N/A
nb_read_packets=N/A
DISPOSITION:default=0
DISPOSITION:dub=0
DISPOSITION:original=0
DISPOSITION:comment=0
DISPOSITION:lyrics=0
DISPOSITION:karaoke=0
DISPOSITION:forced=0
DISPOSITION:hearing_impaired=0
DISPOSITION:visual_impaired=0
DISPOSITION:clean_effects=0
DISPOSITION:attached_pic=0
DISPOSITION:timed_thumbnails=0
[/STREAM]
3、window上面查看系统当前支持设备
ffmpeg -hide_banner -devices
输出如下:
Devices:
D. = Demuxing supported
.E = Muxing supported
--
D dshow DirectShow capture
D gdigrab GDI API Windows frame grabber
D lavfi Libavfilter virtual input device
E sdl,sdl2 SDL2 output device
D vfwcap VfW video capture
二、ffplay命令的使用
1、从视频的第30秒开始播放,播放10秒钟的文件
ffplay -ss 30 -t 10 output.avi
2、视频播放时播放器的窗口显示标题为自定义标题
ffplay -window_title "hello world" output.avi
3、ffplay 打开网络直播流,则可以使用如下命令:
ffplay -window_title "播放测试" rtmp://58.200.131.2:1935/livetv/hunantv(湖南卫视)
执行完成命令后显示窗口如下所示:
4、播放音频MP3命令
ffplay -i .\周深-欢颜.mp3
4、播放本地mp4
ffplay 4.1.1.程序运行为什么需要内存1.mp4
5、播放pcm原始数据
ffplay -ar 44100 -channels 2 -f s16le -i outpu.pcm