FFMPEG出现线程错误:线程正在中止

时间:2018-07-20 19:21:58

标签: .net multithreading video encoding ffmpeg

我正在使用FFMPEG将视频文件从一种文件类型转换为另一种文件类型。我通过ASP.NET Web界面进行操作,用户可以在其中上传文件,并且转换是在.NET“线程”中进行的,例如:

trd = New Thread(Sub(sender) TestSub(folder,interv,objCounter,fname,fversource,fverdest,fext,fhost))
trd.Priority = ThreadPriority.Lowest
trd.Start

发生转换时,我正在使用FFMPEG“ -progress”参数记录转换的进度。

如果我不使用线程,则会得到一个完整的日志,看起来像下面的输出。但是,当我在线程中运行它时,转换仍然成功进行,但是我从.NET收到此错误消息:“线程被中止。”在第46行之后...无论文件类型,文件大小等如何,它总是在第46行之后出现错误。我需要从线程中的执行中捕获其余的输出(就像在线程外运行时一样)。有人可以帮忙吗?

P.S。,我试图延长服务器超时时间,但这样(对服务器没有帮助):web.config文件中的httpRuntime executeTimeout =“ 600”。

P.P.S,发现了一些有趣的东西。我正在使用StreamReader捕获输出,并将StreamReader的每一行记录到一个输出文件中,如下所示:

Dim ffReader As StreamReader
prcFFMPEG.Start
ffReader = prcFFMPEG.StandardError

While Not ffReader.EndOfStream
    strFFOUT = "Test:" & ffReader.ReadLine
    LogConversion(fhost,"strFFOUT(ffReader.ReadLine): " & (strFFOUT).ToString)
End While

这是一个奇怪的部分:在While / EndWhile循环中,如果我只打印“ Test”而不是ffReader.ReadLine,它将运行,我得到的行数更多,并且线程中止,但我看到FFMPEG仍在运行任务管理器。如果我让它在任务管理器中运行,然后使用ffReader.ReadLine重新运行代码,它将打印出所有内容,且没有错误/中止。但是,如果我在任务管理器中结束后台任务,则会再次遇到相同的问题和错误。

strFFOUT(0): ffmpeg version N-67331-g547fce9 Copyright (c) 2000-2014 the FFmpeg developers
strFFOUT(1): built on Nov 1 2014 22:01:52 with gcc 4.9.1 (GCC)
strFFOUT(2): configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --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-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-zlib
strFFOUT(3): libavutil 54. 11.100 / 54. 11.100
strFFOUT(4): libavcodec 56. 10.101 / 56. 10.101
strFFOUT(5): libavformat 56. 12.100 / 56. 12.100
strFFOUT(6): libavdevice 56. 2.100 / 56. 2.100
strFFOUT(7): libavfilter 5. 2.101 / 5. 2.101
strFFOUT(8): libswscale 3. 1.101 / 3. 1.101
strFFOUT(9): libswresample 1. 1.100 / 1. 1.100
strFFOUT(10): libpostproc 53. 3.100 / 53. 3.100
strFFOUT(11): [mov,mp4,m4a,3gp,3g2,mj2 @ 02a28700] overread end of atom 'colr' by 1 bytes
strFFOUT(12): Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\inetpub\wwwroot\site\short_sample.mp4':
strFFOUT(13): Metadata:
strFFOUT(14): major_brand : mp42
strFFOUT(15): minor_version : 0
strFFOUT(16): compatible_brands: mp42isomavc1
strFFOUT(17): creation_time : 2010-03-20 21:29:11
strFFOUT(18): encoder : HandBrake 0.9.4 2009112300
strFFOUT(19): Duration: 00:00:05.57, start: 0.000000, bitrate: 551 kb/s
strFFOUT(20): Stream #0:0(und): Video: h264 (Constrained Baseline) (avc1 / 0x31637661), yuv420p(tv, bt709), 560x320, 465 kb/s, 30 fps, 30 tbr, 90k tbn, 60 tbc (default)
strFFOUT(21): Metadata:
strFFOUT(22): creation_time : 2010-03-20 21:29:11
strFFOUT(23): encoder : JVT/AVC Coding
strFFOUT(24): Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 83 kb/s (default)
strFFOUT(25): Metadata:
strFFOUT(26): creation_time : 2010-03-20 21:29:11
strFFOUT(27): [libx264 @ 02a2e840] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX AVX2 FMA3 LZCNT BMI2
strFFOUT(28): [libx264 @ 02a2e840] profile High, level 2.1
strFFOUT(29): [libx264 @ 02a2e840] 264 - core 142 r2479 dd79a61 - H.264/MPEG-4 AVC codec - Copyleft 2003-2014 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=cqp mbtree=0 qp=23 ip_ratio=1.40 pb_ratio=1.30 aq=0
strFFOUT(30): Output #0, mp4, to 'C:\inetpub\wwwroot\site\short_sample3.mp4':
strFFOUT(31): Metadata:
strFFOUT(32): major_brand : mp42
strFFOUT(33): minor_version : 0
strFFOUT(34): compatible_brands: mp42isomavc1
strFFOUT(35): encoder : Lavf56.12.100
strFFOUT(36): Stream #0:0(und): Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 480x320, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
strFFOUT(37): Metadata:
strFFOUT(38): creation_time : 2010-03-20 21:29:11
strFFOUT(39): encoder : Lavc56.10.101 libx264
strFFOUT(40): Stream #0:1(eng): Audio: aac (libvo_aacenc) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, s16, 128 kb/s (default)
strFFOUT(41): Metadata:
strFFOUT(42): creation_time : 2010-03-20 21:29:11
strFFOUT(43): encoder : Lavc56.10.101 libvo_aacenc
strFFOUT(44): Stream mapping:
strFFOUT(45): Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
strFFOUT(46): Stream #0:1 -> #0:1 (aac (native) -> aac (libvo_aacenc))
strFFOUT(47): frame= 96 fps=0.0 q=23.0 size= 146kB time=00:00:03.37 bitrate= 355.3kbits/s 
strFFOUT(48): frame= 166 fps=0.0 q=-1.0 Lsize= 274kB time=00:00:05.58 bitrate= 401.7kbits/s 
strFFOUT(49): 
strFFOUT(50): video:179kB audio:87kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.677233%
strFFOUT(51): [libx264 @ 02a2e840] frame I:1 Avg QP:20.00 size: 19154
strFFOUT(52): [libx264 @ 02a2e840] frame P:48 Avg QP:23.00 size: 1976
strFFOUT(53): [libx264 @ 02a2e840] frame B:117 Avg QP:24.63 size: 588
strFFOUT(54): [libx264 @ 02a2e840] consecutive B-frames: 3.6% 0.0% 21.7% 74.7%
strFFOUT(55): [libx264 @ 02a2e840] mb I I16..4: 46.2% 21.2% 32.7%
strFFOUT(56): [libx264 @ 02a2e840] mb P I16..4: 1.1% 0.3% 0.2% P16..4: 29.1% 7.5% 7.3% 0.0% 0.0% skip:54.3%
strFFOUT(57): [libx264 @ 02a2e840] mb B I16..4: 0.0% 0.0% 0.1% B16..8: 17.5% 3.6% 1.2% direct: 1.1% skip:76.4% L0:39.0% L1:49.6% BI:11.4%
strFFOUT(58): [libx264 @ 02a2e840] 8x8 transform intra:21.9% inter:51.2%
strFFOUT(59): [libx264 @ 02a2e840] coded y,uvDC,uvAC intra: 40.4% 70.7% 40.6% inter: 5.8% 10.3% 3.0%
strFFOUT(60): [libx264 @ 02a2e840] i16 v,h,dc,p: 0% 25% 1% 74%
strFFOUT(61): [libx264 @ 02a2e840] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 9% 36% 14% 5% 7% 4% 13% 4% 8%
strFFOUT(62): [libx264 @ 02a2e840] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 16% 25% 12% 4% 8% 8% 13% 6% 8%
strFFOUT(63): [libx264 @ 02a2e840] i8c dc,h,v,p: 49% 35% 10% 6%
strFFOUT(64): [libx264 @ 02a2e840] Weighted P-Frames: Y:0.0% UV:0.0%
strFFOUT(65): [libx264 @ 02a2e840] ref P L0: 65.7% 5.6% 18.5% 10.3%
strFFOUT(66): [libx264 @ 02a2e840] ref B L0: 79.0% 14.9% 6.0%
strFFOUT(67): [libx264 @ 02a2e840] ref B L1: 91.1% 8.9%
strFFOUT(68): [libx264 @ 02a2e840] kb/s:264.22

0 个答案:

没有答案