我的转换程序如下:
string toolTemp = fileName.Substring(0, fileName.LastIndexOf('\\'));
string ffmpeg = toolTemp.Substring(0, toolTemp.LastIndexOf('\\') + 1) + PubicMethod.ffmpegtool; //ffmpeg.exe所在位置
if ((!System.IO.File.Exists(ffmpeg)) || (!System.IO.File.Exists(fileName)))
{
return "";
}
//获得图片和(.flv)文件相对路径/最后存储到数据库的路径,如:/Web/User1/00001.jpg
string flv_file = System.IO.Path.ChangeExtension(playFile, ".flv"); //存放flv文件的位置 //截图的尺寸大小,配置在Web.Config中,如:<add key="CatchFlvImgSize" value="240x180" />
string FlvImgSize = PublicMethod.sizeOfImg;
System.Diagnostics.ProcessStartInfo FilestartInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
//FilestartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
FilestartInfo.CreateNoWindow = true;
FilestartInfo.Arguments = " -y -i " + fileName + " -ab 56 -ar 22050 -b 500 -r 15 -s " + widthOfFile + "x" + heightOfFile + " " + flv_file;
FilestartInfo.UseShellExecute = false;
FilestartInfo.RedirectStandardError = true;
FilestartInfo.RedirectStandardOutput = true;
//ImgstartInfo.Arguments = " -i " + fileName + " -y -f image2 -t 0.05 -s " + FlvImgSize + " " + flv_img;
try
{
//转换
System.Diagnostics.Process.Start(FilestartInfo);
//截图
CatchImg(fileName, imgFile);
//System.Diagnostics.Process.Start(ImgstartInfo);
}
catch
{
return "";
}
//
return "";这样程序走通了,但是转换就是不成功!
后来我直接在命令行提示中输入 ffmpeg.exe -y -i C:\01.wmv -ab 24 -ar 22050 -b 300k -s 240x180 C:\test.flv
但总出现
FFmpeg version SVN-r12665, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt
er-lavf --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac --e
nable-libfaad --enable-libgsm --enable-memalign-hack --enable-libmp3lame --enabl
e-libnut --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
--cpu=i686 --extra-ldflags=-static
libavutil version: 49.6.0
libavcodec version: 51.54.0
libavformat version: 52.13.0
libavdevice version: 52.0.0
built on Apr 2 2008 22:35:11, gcc: 4.2.3
Input #0, asf, from '01.wmv':
Duration: 01:23:03.5, start: 3.551000, bitrate: 25 kb/s
Stream #0.0: Audio: 0x000a, 8000 Hz, mono, 8 kb/s
Stream #0.1: Video: MSS2 / 0x3253534D, 704x528, 200 kb/s, 1000.00 tb(r)
Stream #0.2: Invalid Codec type -1
swScaler: Unknown format is not supported as input pixel format
Cannot get resampling context
这样的错误,请问这到底是什么问题呢?是ffmpeg.exe软件的问题吗?谢谢了。
string toolTemp = fileName.Substring(0, fileName.LastIndexOf('\\'));
string ffmpeg = toolTemp.Substring(0, toolTemp.LastIndexOf('\\') + 1) + PubicMethod.ffmpegtool; //ffmpeg.exe所在位置
if ((!System.IO.File.Exists(ffmpeg)) || (!System.IO.File.Exists(fileName)))
{
return "";
}
//获得图片和(.flv)文件相对路径/最后存储到数据库的路径,如:/Web/User1/00001.jpg
string flv_file = System.IO.Path.ChangeExtension(playFile, ".flv"); //存放flv文件的位置 //截图的尺寸大小,配置在Web.Config中,如:<add key="CatchFlvImgSize" value="240x180" />
string FlvImgSize = PublicMethod.sizeOfImg;
System.Diagnostics.ProcessStartInfo FilestartInfo = new System.Diagnostics.ProcessStartInfo(ffmpeg);
//FilestartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
FilestartInfo.CreateNoWindow = true;
FilestartInfo.Arguments = " -y -i " + fileName + " -ab 56 -ar 22050 -b 500 -r 15 -s " + widthOfFile + "x" + heightOfFile + " " + flv_file;
FilestartInfo.UseShellExecute = false;
FilestartInfo.RedirectStandardError = true;
FilestartInfo.RedirectStandardOutput = true;
//ImgstartInfo.Arguments = " -i " + fileName + " -y -f image2 -t 0.05 -s " + FlvImgSize + " " + flv_img;
try
{
//转换
System.Diagnostics.Process.Start(FilestartInfo);
//截图
CatchImg(fileName, imgFile);
//System.Diagnostics.Process.Start(ImgstartInfo);
}
catch
{
return "";
}
//
return "";这样程序走通了,但是转换就是不成功!
后来我直接在命令行提示中输入 ffmpeg.exe -y -i C:\01.wmv -ab 24 -ar 22050 -b 300k -s 240x180 C:\test.flv
但总出现
FFmpeg version SVN-r12665, Copyright (c) 2000-2008 Fabrice Bellard, et al.
configuration: --enable-gpl --enable-postproc --enable-swscale --enable-avfilt
er-lavf --enable-pthreads --enable-liba52 --enable-avisynth --enable-libfaac --e
nable-libfaad --enable-libgsm --enable-memalign-hack --enable-libmp3lame --enabl
e-libnut --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid
--cpu=i686 --extra-ldflags=-static
libavutil version: 49.6.0
libavcodec version: 51.54.0
libavformat version: 52.13.0
libavdevice version: 52.0.0
built on Apr 2 2008 22:35:11, gcc: 4.2.3
Input #0, asf, from '01.wmv':
Duration: 01:23:03.5, start: 3.551000, bitrate: 25 kb/s
Stream #0.0: Audio: 0x000a, 8000 Hz, mono, 8 kb/s
Stream #0.1: Video: MSS2 / 0x3253534D, 704x528, 200 kb/s, 1000.00 tb(r)
Stream #0.2: Invalid Codec type -1
swScaler: Unknown format is not supported as input pixel format
Cannot get resampling context
这样的错误,请问这到底是什么问题呢?是ffmpeg.exe软件的问题吗?谢谢了。
swScaler: Unknown format is not supported as input pixel format
Cannot get resampling context
我估计是你的wmv文件有问题2,测试一下我说的对不对,网上找了一下 在一个ffmpeg.exe
找到个下的地方,为了统一,把地址贴一下哈哈
■ffmpeg_bin-18077.zip
http://abechin.sakura.ne.jp/sblo_files/k-tai-douga/ffmpeg/ffmpeg_bin-18077.zip
■ffmpeg_bin_pentium4-18077.zip (Pentium4最適化版)
http://abechin.sakura.ne.jp/sblo_files/k-tai-douga/ffmpeg/ffmpeg_bin_pentium4-18077.zip
■ffmpeg_bin_core2-18077.zip (Core2最適化版)
http://abechin.sakura.ne.jp/sblo_files/k-tai-douga/ffmpeg/ffmpeg_bin_core2-18077.zip
■ffmpeg_bin_athlon64-18077.zip (Athlon64最適化版)
http://abechin.sakura.ne.jp/sblo_files/k-tai-douga/ffmpeg/ffmpeg_bin_athlon64-18077.zip3,其实下那个都没什么大问题,我下了一个Core2 公司给我的电脑还不错 哈哈4,找遍全盘终于找到一个wmv的文件
马上测试一下
ffmpeg.exe -y -i S-01.wmv -ab 24 -ar 22050 -b 300k -s 240x180 test.flvFFmpeg version SVN-r16517, Copyright (c) 2000-2009 Fabrice Bellard, et al.
configuration: --enable-memalign-hack --enable-postproc --enable-swscale --ena
ble-gpl --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --
enable-libnut --enable-libvorbis --enable-libtheora --enable-libxvid --enable-li
bx264 --disable-ffserver --disable-ffplay --enable-avisynth --enable-small --ena
ble-pthreads --extra-ldflags=-static --extra-cflags=-mtune=pentium4 -mfpmath=sse
-msse
libavutil 49.12. 0 / 49.12. 0
libavcodec 52.10. 0 / 52.10. 0
libavformat 52.23. 1 / 52.23. 1
libavdevice 52. 1. 0 / 52. 1. 0
libswscale 0. 6. 1 / 0. 6. 1
libpostproc 51. 2. 0 / 51. 2. 0
built on Jan 11 2009 05:11:47, gcc: 4.3.2
[wmv3 @ 0x14fca70]Extra data: 8 bits left, value: 0Seems stream 1 codec frame rate differs from container frame rate: 1000.00 (1000
/1) -> 30.00 (30/1)
Input #0, asf, from 'SD1-01.wmv':
Duration: 00:00:27.27, start: 3.000000, bitrate: 1125 kb/s
Stream #0.0: Audio: wmav2, 44100 Hz, stereo, s16, 96 kb/s
Stream #0.1: Video: wmv3, yuv420p, 640x480, 952 kb/s, 30.00 tb(r)
WARNING: The bitrate parameter is set too low. It takes bits/s as argument, not
kbits/s
Output #0, flv, to 'test.flv':
Stream #0.0: Video: flv, yuv420p, 240x180 [PAR 4:3 DAR 16:9], q=2-31, 300 kb
/s, 30.00 tb(c)
Stream #0.1: Audio: libmp3lame, 22050 Hz, stereo, s16, 0 kb/s
Stream mapping:
Stream #0.1 -> #0.0
Stream #0.0 -> #0.1
[wmv3 @ 0x14fca70]Extra data: 8 bits left, value: 0
Press [q] to stop encoding
[libmp3lame @ 0x159f440]lame: output buffer too small (buffer index: 8150, free
bytes: 490)
frame= 867 fps=246 q=2.6 Lsize= 1554kB time=28.90 bitrate= 440.5kbits/s
video:1295kB audio:228kB global headers:0kB muxing overhead 2.054185%5,成功了 哈哈 我估计你那个wmv文件有问题不好意思说了这么多废话,希望对你有帮助
http://topic.csdn.net/u/20091020/09/150ce969-bcdc-480d-905a-9a434d02d0db.html本地可以,但是服务器不行。
怎么回事?