本文主要是介绍.net core使用Process执行linux命令报错,ffmpeg获取视频的宽高分辨率信息,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
我的系统是centos8
系统报的错误:
System.InvalidOperationException: Cannot start process because a file name has not been provided.at System.Diagnostics.Process.Start() in /_/src/libraries/System.Diagnostics.Process/src/System/Diagnostics/Process.cs:line 1207at WebNetCore5_Img_Storage.Model.Tool.GetVideoInfoByFFmpeg.GetVideoInfo(String videoPath)at WebNetCore5_Img_Storage.Controllers.FileUploadController.<>c__DisplayClass5_0.<<UploadBigFile>b__0>d.MoveNext()
这个错误一般是命令不对
命令里面最好没有引号;
ffmpeg获取视频的宽高分辨率信息,返回数据是json
ffprobe -select_streams v -show_entries format=duration,size,bit_rate,filename -show_streams -v quiet -of json -i /upload/20210308_163751_259_a3f4.mp4
ffprobe -v quiet -print_format json -show_streams IMG_0837.MOV
ffprobe -select_streams v -show_entries format=duration,size,bit_rate,filename -show_streams -v quiet -of json -i IMG_0837.MOV
ffprobe -select_streams v -show_entries format=duration,size,bit_rate,filename -show_streams -v quiet -of json -i VID_20210307_111234.mp4
返回数据
{"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_time_base": "3157/187500","codec_tag_string": "avc1","codec_tag": "0x31637661","width": 1920,"height": 1080,"coded_width": 1920,"coded_height": 1088,"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","refs": 1,"is_avc": "true","nal_length_size": "4","r_frame_rate": "179/6","avg_frame_rate": "93750/3157","time_base": "1/90000","start_pts": 0,"start_time": "0.000000","duration_ts": 530376,"duration": "5.893067","bit_rate": "14239766","bits_per_raw_sample": "8","nb_frames": "175","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},"tags": {"creation_time": "2021-03-07T03:12:33.000000Z","language": "eng","handler_name": "VideoHandle"}}],"format": {"filename": "/wzfgs_img_storage/tuku.img_linux/upload/20210308_173136_349_2ca0.mp4","duration": "5.893000","size": "11033567","bit_rate": "14978539"}
}
var process = new Process{StartInfo = new ProcessStartInfo("ffprobe", "-select_streams v -show_entries format=duration,size,bit_rate,filename -show_streams -v quiet -of json -i /upload/20210308_163751_259_a3f4.mp4"){RedirectStandardOutput = true,UseShellExecute = false}};process.Start();//视频信息jsonstring videoJson = process.StandardOutput.ReadToEnd();Console.WriteLine(videoJson);process.WaitForExit();process.Dispose();
这篇关于.net core使用Process执行linux命令报错,ffmpeg获取视频的宽高分辨率信息的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!