在连续的完整日志文件中为每个部分匹配REGEX

我有一个视频转换文件的完整日志,看起来像这样:

--------------------------------------------------------------------------------
D:\destination\vid1.mp4
--------------------------------------------------------------------------------
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000020179e89280] st: 1 edit list: 1 Missing key frame while searching for timestamp: 0
[mov,mp4,m4a,3gp,3g2,mj2 @ 0000020179e89280] st: 1 edit list 1 Cannot find an index entry before timestamp: 0.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\source\vid1.mp4':
  Metadata:
    major_brand     : M4V 
    minor_version   : 1
    compatible_brands: isomavc1mp42
    creation_time   : 2020-02-18T20:21:00.000000Z
  Duration: 00:49:31.71, start: 0.000000, bitrate: 5135 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 5001 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default)
    Metadata:
      creation_time   : 2020-02-18T20:21:00.000000Z
      handler_name    : ETI ISO Video Media Handler
      encoder         : Elemental H.264
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2020-02-18T20:21:00.000000Z
      handler_name    : ETI ISO Audio Media Handler
avcuvid: --sub-copy/--vpp-subburn is set, but no subtitle stream found.
Max B frames are 0 frames.
NVEncC (x64) 4.69 (r1408) by rigaya, Mar 25 2020 13:57:52 (VC 1916/Win/avx2)
OS Version     Windows 10 x64 (18363)
CPU            Intel Core i7-7700HQ @ 2.80GHz [TB: 3.59GHz] (4C/8T)
GPU            #0: GeForce GTX 1080 with Max-Q Design (2560 cores, 1468 MHz)[PCIe3x16][442.19]
NVENC / CUDA   NVENC API 9.1, CUDA 10.2, schedule mode: auto
Input Buffers  CUDA, 17 frames
Input Info     avcuvid: H.264/AVC, 1280x720, 30000/1001 fps
Vpp Filters    cspconv(nv12 -> p010)
Output Info    H.265/HEVC main10 @ Level auto
               1280x720p 1:1 29.970fps (30000/1001fps)
               avwriter: hevc, aac => mp4
Encoder Preset default
Rate Control   CQP  I:23  P:23  B:23
Lookahead      off
GOP length     300 frames
B frames       0 frames [ref mode: disabled]
Ref frames     3 frames
AQ             off
CU max / min   auto / auto
Others         mv:auto 
Output #0, mp4, to 'D:\destination\vid1.mp4':
  Metadata:
    encoding_tool   : NVEncC (x64) 4.69
    encoder         : Lavf58.35.101
    Stream #0:0(und): Video: hevc (Main 10) (hev1 / 0x31766568), yuv420p10le(progressive), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 240k tbn (default)
    Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 125 kb/s (default)
    Metadata:
      creation_time   : 2020-02-18T20:21:00.000000Z
      handler_name    : ETI ISO Audio Media Handler
[mp4 @ 0000020115d9b780] Starting second pass: moving the moov atom to the beginning of the file

encoded 89062 frames, 699.78 fps, 1682.57 kbps, 596.06 MB
encode time 0:02:07, CPU: 15.4%, GPU: 12.6%, VE: 96.3%, VD: 54.7%, GPUClock: 1705MHz, VEClock: 1529MHz
frame type IDR   297
frame type I     297,  avgQP  23.00,  total size   10.85 MB
frame type P   88765,  avgQP  23.00,  total size  585.21 MB
--------------------------------------------------------------------------------
D:\destination\vid2.mp4
--------------------------------------------------------------------------------
[wmv3 @ 000001fcd4217a80] Extra data: 8 bits left, value: 0
Input #0, asf, from 'C:\source\vid2.mp4':
  Metadata:
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: M1
    WM/WMADRCPeakReference: 32767
    WM/WMADRCPeakTarget: 32767
    WM/WMADRCAverageReference: 6067
    WM/WMADRCAverageTarget: 6067
    WMFSDKVersion   : 11.0.6000.6346
    IsVBR           : 0
  Duration: 00:29:48.19, start: 0.000000, bitrate: 2628 kb/s
    Stream #0:0(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 720x480, 2500 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc
    Stream #0:1(eng): Audio: wmapro (b[1][0][0] / 0x0162), 48000 Hz, stereo, fltp, 128 kb/s
avcuvid: --sub-copy/--vpp-subburn is set, but no subtitle stream found.
avcuvid: codec wmv3(yuv420p) unable to decode by cuvid.
failed to initialize file reader(s).
Failed to open input file.
--------------------------------------------------------------------------------
D:\destination\vid3.mp4
--------------------------------------------------------------------------------
[wmv3 @ 000001fcd4217a80] Extra data: 8 bits left, value: 0
Input #0, asf, from 'C:\source\vid3.mp4':
  Metadata:
    WMFSDKNeeded    : 0.0.0.0000
    DeviceConformanceTemplate: M1
    WM/WMADRCPeakReference: 32767
    WM/WMADRCPeakTarget: 32767
    WM/WMADRCAverageReference: 6067
    WM/WMADRCAverageTarget: 6067
    WMFSDKVersion   : 11.0.6000.6346
    IsVBR           : 0
  Duration: 00:29:48.19, start: 0.000000, bitrate: 2628 kb/s
    Stream #0:0(eng): Video: wmv3 (Main) (WMV3 / 0x33564D57), yuv420p, 720x480, 2500 kb/s, 29.97 fps, 29.97 tbr, 1k tbn, 1k tbc
    Stream #0:1(eng): Audio: wmapro (b[1][0][0] / 0x0162), 48000 Hz, stereo, fltp, 128 kb/s
avcuvid: --sub-copy/--vpp-subburn is set, but no subtitle stream found.
avcuvid: codec wmv3(yuv420p) unable to decode by cuvid.
failed to initialize file reader(s).
Failed to open input file.

Form that log, each video conversion log is divided in section, separated by the repeated dash. I'm trying to get the source full file name that failed to convert, in this case, C:\source\vid2.mp4 and C:\source\vid3.mp4. Using this regex pattern below however, I get one matched result (vid3.mp4) and one mismatched (vid1.mp4), it matches from line 6 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\source\vid1.mp4': to the end of the log.

(?sm)Input #(?<number>\d+).*?from '(?<filename>.*?)'.*?[A-Za-z]ailed to

任何想法如何解决这个问题?提前致谢。

评论