使用Windows Batch从输出中检索信息

时间:2018-05-13 01:46:26

标签: batch-file ffmpeg output batch-processing

我想得到这个FFmpeg输出:

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'D:\Videos\youtube.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.28.100
  Duration: 00:27:58.85, start: 0.000000, bitrate: 12157 kb/s
    Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 12024 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (native) -> hevc (libx265))
  Stream #0:1 -> #0:1 (copy)
Press [q] to stop, [?] for help
Output #0, matroska, to 'D:\Videos\youtube.mkv':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
    Stream #0:0(eng): Video: hevc (libx265), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 23.98 fps, 1k tbn, 23.98 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      encoder         : Lavc57.107.100 libx265
    Stream #0:1(eng): Audio: aac (LC) ([255][0][0][0] / 0x00FF), 48000 Hz, stereo, fltp, 129 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
frame=   19 fps=0.0 q=-0.0 size=       3kB time=00:00:00.98 bitrate=  24.7kbits/s speed= 1.9x    
frame=   26 fps= 25 q=-0.0 size=       3kB time=00:00:01.00 bitrate=  24.1kbits/s speed=0.972x    
frame=   36 fps= 22 q=-0.0 size=       3kB time=00:00:01.47 bitrate=  16.4kbits/s speed=0.913x    
frame=   48 fps= 22 q=-0.0 size=       3kB time=00:00:01.96 bitrate=  12.3kbits/s speed=0.895x    
frame=   61 fps= 22 q=-0.0 size=       3kB time=00:00:02.94 bitrate=   8.2kbits/s speed=1.07x    
frame=   79 fps= 24 q=-0.0 size=       3kB time=00:00:03.43 bitrate=   7.0kbits/s speed=1.05x    
frame=   95 fps= 25 q=-0.0 size=       3kB time=00:00:04.41 bitrate=   5.5kbits/s speed=1.17x    
frame=  107 fps= 25 q=-0.0 size=       3kB time=00:00:04.90 bitrate=   4.9kbits/s speed=1.14x    
frame=  112 fps= 23 q=-0.0 size=       3kB time=00:00:04.90 bitrate=   4.9kbits/s speed=1.02x    
frame=  121 fps= 23 q=-0.0 size=       3kB time=00:00:05.39 bitrate=   4.5kbits/s speed=1.01x    
frame=  130 fps= 22 q=-0.0 size=       3kB time=00:00:05.88 bitrate=   4.1kbits/s speed=0.998x    
frame=  136 fps= 21 q=-0.0 size=    2971kB time=00:00:05.88 bitrate=4133.5kbits/s speed=0.911x    
frame=  142 fps= 20 q=-0.0 size=    2971kB time=00:00:06.37 bitrate=3815.4kbits/s speed=0.912x    
frame=  147 fps= 20 q=-0.0 size=    2971kB time=00:00:06.37 bitrate=3815.4kbits/s speed=0.851x    
frame=  154 fps= 19 q=-0.0 size=    2971kB time=00:00:06.86 bitrate=3543.2kbits/s speed=0.856x    
frame=  160 fps= 19 q=-0.0 size=    2971kB time=00:00:07.36 bitrate=3306.8kbits/s speed=0.862x    
frame=  168 fps= 18 q=-0.0 size=    2971kB time=00:00:07.36 bitrate=3306.8kbits/s speed=0.808x    
frame=  177 fps= 18 q=-0.0 size=    2971kB time=00:00:07.85 bitrate=3100.0kbits/s speed=0.815x    
frame=  190 fps= 19 q=-0.0 size=    2971kB time=00:00:08.32 bitrate=2925.3kbits/s speed=0.818x    
frame=  191 fps= 18 q=-0.0 size=    2971kB time=00:00:08.32 bitrate=2925.3kbits/s speed=0.777x    
frame=  201 fps= 18 q=-0.0 size=    2971kB time=00:00:08.76 bitrate=2775.8kbits/s speed=0.782x    
frame=  212 fps= 18 q=-0.0 size=    2971kB time=00:00:09.23 bitrate=2634.9kbits/s speed=0.788x    
frame=  220 fps= 18 q=-0.0 size=    2971kB time=00:00:09.68 bitrate=2513.0kbits/s speed=0.789x    
frame=  231 fps= 18 q=-0.0 size=    2971kB time=00:00:09.98 bitrate=2437.7kbits/s speed=0.778x    
frame=  240 fps= 17 q=-0.0 Lsize=    6190kB time=00:00:09.98 bitrate=5078.7kbits/s speed=0.726x    
video:6018kB audio:164kB subtitle:0kB other streams:0kB global headers:2kB muxing overhead: 0.129100%

并将frame=fps=值设置为变量。

我想,可以通过输出这个到文本文件来实现(FFmpeg的输出一切向STDERR),并使用FOR与令牌和delims但是,大家可能知道,FFmpeg的实时输出的信息和与#39;我被卡住的地方。是否需要将批处理分解为较小的文件并使用CALL命令获取信息(只是一个想法)?

我需要一些方法来定期检查带有frame =和fps = outputs的行,将它们的值放在变量中,其余的我可能已经知道该怎么做了。

将这些变为变量的目的是计算视频转换的百分比和ETA。

提前致谢。

0 个答案:

没有答案