我尝试使用ffmpeg从mp4文件中提取一部分,但它返回的文件为空,请您帮忙检查一下吗?真的让我发疯了……在此先感谢您!
1。我试图将输出文件设置为另一个文件(不是自我替换),并且可以工作。 2.我试图通过ajax将文件名发回客户端,但无法加载视频,但可以在服务器上播放(ffmpeg生成的文件未损坏) 3.我关闭了本地主机,然后重新启动,可以正确加载mp4文件。
-问题 1.上传到服务器的文件是否已被占用?(我试图删除它,它是可行的,并且在生成原始文件后已经调用了dispose)
2。为什么我重新启动本地主机,它变得可行?关闭本地主机期间做了什么?
for C# code to save file,please refer to below
HttpPostedFileWrapper video---param
string extension = new FileInfo(video.FileName).Extension;
string videoId = DateTime.Now.Ticks.ToString();
string filePath =HttpContext.Current.Server.MapPath("~/video/" + videoId + extension);
var videoFile = File.Create(filePath);
video.InputStream.Seek(0, SeekOrigin.Begin);
video.InputStream.CopyTo(videoFile);
videoFile.Close();
videoFile.Dispose();
有关ffmpeg的信息,请参阅下文
E:\tools\ticon\ffmpeg-20180619-a990184-win64-static\bin>ffmpeg -ss 1.67 -t 4.10 -i E:\MyMVCProj\MyMVCProj\MyMVCProj\video\7802334805.mp4 -vcodec copy -acodec copy E:\MyMVCProj\MyMVCProj\MyMVCProj\video\7802334805.mp4 -y
ffmpeg version N-91330-ga990184007 Copyright (c) 2000-2018 the FFmpeg developers
built with gcc 7.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth
libavutil 56. 18.102 / 56. 18.102
libavcodec 58. 20.103 / 58. 20.103
libavformat 58. 17.100 / 58. 17.100
libavdevice 58. 4.101 / 58. 4.101
libavfilter 7. 25.100 / 7. 25.100
libswscale 5. 2.100 / 5. 2.100
libswresample 3. 2.100 / 3. 2.100
libpostproc 55. 2.100 / 55. 2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from
'E:\MyMVCProj\MyMVCProj\MyMVCProj\video\7802334805.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
creation_time : 2018-06-21T11:26:01.000000Z
Duration: 00:00:09.80, start: 0.000000, bitrate: 1284 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 62 kb/s (default)
Metadata:
creation_time : 2018-06-21T11:26:01.000000Z
handler_name : Core Media Audio
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709, progressive), 960x540, 1216 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
rotate : 90
creation_time : 2018-06-21T11:26:01.000000Z
handler_name : Core Media Video
Side data:
displaymatrix: rotation of -90.00 degrees
Output #0, mp4, to 'E:\MyMVCProj\MyMVCProj\MyMVCProj\video\7802334805.mp4':
Metadata:
major_brand : mp42
minor_version : 1
compatible_brands: mp41mp42isom
encoder : Lavf58.17.100
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, smpte170m/bt709/bt709, progressive), 960x540, q=2-31, 1216 kb/s, 30 fps, 30 tbr, 19200 tbn, 600 tbc (default)
Metadata:
rotate : 90
creation_time : 2018-06-21T11:26:01.000000Z
handler_name : Core Media Video
Side data:
displaymatrix: rotation of -90.00 degrees
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 62 kb/s (default)
Metadata:
creation_time : 2018-06-21T11:26:01.000000Z
handler_name : Core Media Audio
Stream mapping:
Stream #0:1 -> #0:0 (copy)
Stream #0:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
frame= 0 fps=0.0 q=-1.0 Lsize= 0kB time=00:00:00.00 bitrate=N/A speed= 0x
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
答案 0 :(得分:0)
[已解决] ffmpeg最新版本必须包含一些致命错误,我将其降级为先前版本,并且可以正常工作。