asp.net 用 ffmpeg 获取不到视频的全部信息

米大爷 2013-07-08 02:56:04
使用ffmpeg 获取视频信息 用winform获取出来的都正常
改成webform后 获取出来的信息 就少了一节 代码都是一样的 求解。。。

WinForm:
ffmpeg version N-54362-ge0be3cb Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 2 2013 22:15:59 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.100 / 55. 18.100
libavformat 55. 11.100 / 55. 11.100
libavdevice 55. 2.100 / 55. 2.100
libavfilter 3. 77.101 / 3. 77.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'E:\file\20120928155859_0156.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp42mp41
creation_time : 2012-05-31 14:33:42
Duration: 00:01:51.64, start: 0.000000, bitrate: 12246 kb/s
Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 12067 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc
Metadata:
creation_time : 2012-05-31 14:33:42
handler_name : Mainconcept MP4 Video Media Handler
Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 157 kb/s
Metadata:
creation_time : 2012-05-31 14:33:42
handler_name : Mainconcept MP4 Sound Media Handler
At least one output file must be specified





WebForm:
ffmpeg version N-54362-ge0be3cb Copyright (c) 2000-2013 the FFmpeg developers
built on Jul 2 2013 22:15:59 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 38.100 / 52. 38.100
libavcodec 55. 18.100 / 55. 18.100
libavformat 55. 11.100 / 55. 11.100
libavdevice 55. 2.100 / 55. 2.100
libavfilter 3. 77.101 / 3. 77.101
libswscale 2. 3.100 / 2. 3.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100


...全文
437 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
米大爷 2013-07-19
  • 打赏
  • 举报
回复
找到原因了 是版本的问题 我用的最新版的 在webfrom下就出现获取不到完整信息的问题了 用 ffmpeg-20121125-git-26c531c-win32-static.7z 版本的就没有问题 下载地址 http://ffmpeg.zeranoe.com/builds/win32/static/
webdiyer 2013-07-11
  • 打赏
  • 举报
回复
ffprobe可以将视频信息以json的格式输出,获取很方便的,我用过
米大爷 2013-07-10
  • 打赏
  • 举报
回复
引用 5 楼 webdiyer 的回复:
获取视频信息应该用ffprobe
使用 ffprobe 在winform 里可以获取到信息 但用在webform里就什么都获取不到了 使用ffmpeg 在webform里可以获取下面的信息 ffmpeg version N-54362-ge0be3cb Copyright (c) 2000-2013 the FFmpeg developers built on Jul 2 2013 22:15:59 with gcc 4.7.3 (GCC) configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib libavutil 52. 38.100 / 52. 38.100 libavcodec 55. 18.100 / 55. 18.100 libavformat 55. 11.100 / 55. 11.100 libavdevice 55. 2.100 / 55. 2.100 libavfilter 3. 77.101 / 3. 77.101 libswscale 2. 3.100 / 2. 3.100 libswresample 0. 17.102 / 0. 17.102 libpostproc 52. 3.100 / 52. 3.100
米大爷 2013-07-10
  • 打赏
  • 举报
回复
上面的第二个方法复制错了

private string RunProcess(string Parameters, bool UseShellExecute)
        {
             
            Process p = new Process();
            p.StartInfo.FileName = this.FFmpegPath;
            p.StartInfo.Arguments = Parameters;
            p.StartInfo.CreateNoWindow = true;
             
            if (!UseShellExecute)
            {
                p.StartInfo.UseShellExecute = UseShellExecute;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
            }
            string output = null; StreamReader srOutput = null;
            try
            {
                p.Start();//启动线程 
                p.WaitForExit();
                srOutput = p.StandardError;
                output = srOutput.ReadToEnd();
                System.Threading.Thread.Sleep(100);
            }
            catch (Exception)
            {
                output = string.Empty;
            }
            finally
            {
                if (srOutput != null)
                {
                    srOutput.Close();
                    srOutput.Dispose();
                }
                p.Close();//关闭进程 
                p.Dispose();//释放资源 
            }
 
            return output;
        }
米大爷 2013-07-10
  • 打赏
  • 举报
回复

public void GetVideoInfo(VideoFile input)
        {
            string Params = string.Format("-i {0}", input.Path);
            string output = RunProcess(Params, false);
            input.RawInfo = output;
            input.Duration = ExtractDuration(input.RawInfo);
            input.BitRate = ExtractBitrate(input.RawInfo);
            input.RawAudioFormat = ExtractRawAudioFormat(input.RawInfo);
            input.AudioFormat = ExtractAudioFormat(input.RawAudioFormat);
            input.RawVideoFormat = ExtractRawVideoFormat(input.RawInfo);
            input.VideoFormat = ExtractVideoFormat(input.RawVideoFormat);
            input.Width = ExtractVideoWidth(input.RawInfo);
            input.Height = ExtractVideoHeight(input.RawInfo);
            input.infoGathered = true;
        }




       private string RunProcess(string Parameters, bool UseShellExecute)
        {
            
            Process p = new Process();
            p.StartInfo.FileName = this.FFmpegPath;
            p.StartInfo.Arguments = Parameters;
            p.StartInfo.CreateNoWindow = true;
            
            if (!UseShellExecute)
            {
                p.StartInfo.UseShellExecute = UseShellExecute;
                p.StartInfo.RedirectStandardOutput = true;
                p.StartInfo.RedirectStandardError = true;
            }
            string output = null; StreamReader srOutput = null;
            try
            {
                string s = p.StandardOutput.ReadToEnd();
                s = p.StandardError.ReadToEnd();
                p.Start();//启动线程 
                p.WaitForExit();
                s = p.StandardOutput.ReadToEnd();
                srOutput = p.StandardError;
                output = srOutput.ReadToEnd();
                System.Threading.Thread.Sleep(100);
            }
            catch (Exception)
            {
                output = string.Empty;
            }
            finally
            {
                if (srOutput != null)
                {
                    srOutput.Close();
                    srOutput.Dispose();
                }
                p.Close();//关闭进程 
                p.Dispose();//释放资源 
            }

            return output;
        }



webdiyer 2013-07-10
  • 打赏
  • 举报
回复
获取视频信息应该用ffprobe
米大爷 2013-07-09
  • 打赏
  • 举报
回复
没有人。。。
饕餮123 2013-07-09
  • 打赏
  • 举报
回复
引用 3 楼 helloworld123helojkl 的回复:
给贴点代码看看吧,我用的时候没发现有这种问题
米大爷 2013-07-09
  • 打赏
  • 举报
回复
米大爷 2013-07-08
  • 打赏
  • 举报
回复
没有人遇到过吗

62,041

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧