ffmpegのインストール、ffprobe、ffplay の簡単な使い方

2023年8月10日

https://github.com/BtbN/FFmpeg-Builds/releases から、

をダウンロードして、解凍して、binにパスを通して、

カメラ繋げて、以下のコマンドを投入する。

C:\Users\ebata>ffplay -i rtsp://192.168.0.2/ONVIF/Streaming/channels/3

と、こんな感じで、動画が出てくる。

C:\Users\ebata>ffprobe -v error -show_entries stream=codec_type,width,height -i rtsp://192.168.0.2/ONVIF/Streaming/channels/3
[STREAM]
codec_type=video
width=640
height=360
[/STREAM]
[STREAM]
codec_type=audio
[/STREAM]
[STREAM]
codec_type=data
[/STREAM]

C:\Users\ebata>ffprobe -v error -show_entries stream=codec_type,width,height -i rtsp://192.168.0.2/ONVIF/Streaming/channels/0
[h264 @ 00000168d79bc9c0] left block unavailable for requested intra4x4 mode -1
[h264 @ 00000168d79bc9c0] error while decoding MB 0 27, bytestream 59839
[STREAM]
codec_type=video
width=1920
height=1080
[/STREAM]
[STREAM]
codec_type=audio
[/STREAM]
[STREAM]
codec_type=data
[/STREAM]

 

C:\Users\ebata>ffprobe -v error -show_format -show_streams -i rtsp://192.168.0.2/ONVIF/Streaming/channels/3
[STREAM]
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=[0][0][0][0]
codec_tag=0x0000
width=640
height=360
coded_width=640
coded_height=360
closed_captions=0
film_grain=0
has_b_frames=0
sample_aspect_ratio=1:1
display_aspect_ratio=16:9
pix_fmt=yuv420p
level=31
color_range=tv
color_space=bt709
color_transfer=bt709
color_primaries=bt709
chroma_location=left
field_order=progressive
refs=1
is_avc=false
nal_length_size=0
id=N/A
r_frame_rate=5/1
avg_frame_rate=5/1
time_base=1/90000
start_pts=17635
start_time=0.195944
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
extradata_size=58
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
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]
[STREAM]
index=1
codec_name=pcm_mulaw
codec_long_name=PCM mu-law / G.711 mu-law
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=s16
sample_rate=8000
channels=1
channel_layout=unknown
bits_per_sample=8
initial_padding=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/8000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=64000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
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
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]
[STREAM]
index=2
codec_name=unknown
codec_long_name=unknown
profile=unknown
codec_type=data
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
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
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]
[FORMAT]
filename=rtsp://192.168.0.2/ONVIF/Streaming/channels/3
nb_streams=3
nb_programs=0
format_name=rtsp
format_long_name=RTSP input
start_time=0.000000
duration=N/A
size=N/A
bit_rate=N/A
probe_score=100
TAG:title=RTSP/RTP stream from HDIPCam
[/FORMAT]

C:\Users\ebata>ffprobe -v error -show_format -show_streams -i rtsp://192.168.0.2/ONVIF/Streaming/channels/0
[STREAM]
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=[0][0][0][0]
codec_tag=0x0000
width=1920
height=1080
coded_width=1920
coded_height=1080
closed_captions=0
film_grain=0
has_b_frames=0
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=false
nal_length_size=0
id=N/A
r_frame_rate=30/1
avg_frame_rate=30/1
time_base=1/90000
start_pts=4354
start_time=0.048378
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=8
nb_frames=N/A
nb_read_frames=N/A
nb_read_packets=N/A
extradata_size=61
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
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]
[STREAM]
index=1
codec_name=pcm_mulaw
codec_long_name=PCM mu-law / G.711 mu-law
profile=unknown
codec_type=audio
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
sample_fmt=s16
sample_rate=8000
channels=1
channel_layout=unknown
bits_per_sample=8
initial_padding=0
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/8000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=64000
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
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
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]
[STREAM]
index=2
codec_name=unknown
codec_long_name=unknown
profile=unknown
codec_type=data
codec_tag_string=[0][0][0][0]
codec_tag=0x0000
id=N/A
r_frame_rate=0/0
avg_frame_rate=0/0
time_base=1/90000
start_pts=0
start_time=0.000000
duration_ts=N/A
duration=N/A
bit_rate=N/A
max_bit_rate=N/A
bits_per_raw_sample=N/A
nb_frames=N/A
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
DISPOSITION:captions=0
DISPOSITION:descriptions=0
DISPOSITION:metadata=0
DISPOSITION:dependent=0
DISPOSITION:still_image=0
[/STREAM]
[FORMAT]
filename=rtsp://192.168.0.2/ONVIF/Streaming/channels/0
nb_streams=3
nb_programs=0
format_name=rtsp
format_long_name=RTSP input
start_time=0.000000
duration=N/A
size=N/A
bit_rate=N/A
probe_score=100
TAG:title=RTSP/RTP stream from HDIPCam
[/FORMAT]

ffplayは、これでかなり描画が早くなる。(VLCと同程度になった→ ということは、VLCもフレーム落しをしているんだな、多分)

ffplay -fflags nobuffer -flags low_delay -framedrop -i srt://192.168.1.15:12345

■ffmpegでSRTストリームを10秒間録画する方法

ffmpeg -i "srt://192.168.1.15:12345" -t 10 output.mp4

#3 30/1 max=30 3543KB
#3 10/1 max=10 4529KB
#3 5/1 max=5 


2023年8月10日2023,江端さんの技術メモ

Posted by ebata