.net core usa Process para ejecutar el comando de linux para informar un error, y ffmpeg obtiene la información amplia y de alta resolución del video

Mi sistema es centos8

Error informado por el sistema:

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 1207
   at WebNetCore5_Img_Storage.Model.Tool.GetVideoInfoByFFmpeg.GetVideoInfo(String videoPath)
   at WebNetCore5_Img_Storage.Controllers.FileUploadController.<>c__DisplayClass5_0.<<UploadBigFile>b__0>d.MoveNext()

Este error suele ser el comando incorrecto
. Es mejor no tener comillas en el comando;

ffmpeg obtiene la información amplia y de alta resolución del video, y los datos de retorno son 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

Devolver datos

{
    
    
    "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();

            //视频信息json
            string videoJson = process.StandardOutput.ReadToEnd();
            Console.WriteLine(videoJson);

            process.WaitForExit();
            process.Dispose();

Supongo que te gusta

Origin blog.csdn.net/u011511086/article/details/114541248
Recomendado
Clasificación