【问题标题】:isolate the output only: FFmpeg仅隔离输出:FFmpeg
【发布时间】:2020-03-18 12:54:07
【问题描述】:

我试图在运行命令时隔离 ffmpeg 给出的值。

命令是:

ffmpeg -i 03.mxf -c:v copy -c:a pcm_s24le -hide_banner -nostats -af loudnorm=I=-23:TP=-2:LRA=7:print_format=json -f null -

我只想要 JSON 文本:

{
        "input_i" : "-19.90",
        "input_tp" : "-1.69",
        "input_lra" : "2.40",
        "input_thresh" : "-30.39",
        "output_i" : "-23.28",
        "output_tp" : "-5.06",
        "output_lra" : "0.40",
        "output_thresh" : "-33.59",
        "normalization_type" : "dynamic",
        "target_offset" : "0.28"
}

然而,

输出是:

Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Input #0, mxf, from 'D:\Abul\Documents\Projects\IngestQC\Source_Folder\IRO_ROKDSTV_10s_PRO_Valentines2018_Ident_002_00931.mxf':
  Metadata:
    operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
    uid             : c3c82aa7-f530-11e7-8c91-985aebdab411
    generation_uid  : c3c82aa8-f530-11e7-98cb-985aebdab411
    company_name    : Adobe Systems Incorporated
    product_name    : Adobe Media Encoder
    product_version : 12.0.0
    application_platform: Mac OS X
    product_uid     : 0c3919fe-46e8-11e5-a151-feff819cdc9f
    modification_date: 2018-01-09T11:32:25.000000Z
    material_package_umid: 0x060A2B340101010501010D1113000000C8FC790227810580CC9A985AEBDAB411
    timecode        : 00:00:00:00
  Duration: 00:00:10.00, start: 0.000000, bitrate: 52434 kb/s
    Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, unknown/bt709/bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D1213DF61E1C8FC7902278105807C35985AEBDAB411
      file_package_name: Source Package
      track_name      : Track 1
    Stream #0:1: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D1213DF61E1C8FC7902278105807C35985AEBDAB411
      file_package_name: Source Package
      track_name      : Track 2
    Stream #0:2: Audio: pcm_s24le, 48000 Hz, mono, s32 (24 bit), 1152 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D1213DF61E1C8FC7902278105807C35985AEBDAB411
      file_package_name: Source Package
      track_name      : Track 3
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #0:1 -> #0:1 (pcm_s24le (native) -> pcm_s24le (native))
Press [q] to stop, [?] for help
Output #0, null, to 'pipe:':
  Metadata:
    operational_pattern_ul: 060e2b34.04010101.0d010201.01010900
    uid             : c3c82aa7-f530-11e7-8c91-985aebdab411
    generation_uid  : c3c82aa8-f530-11e7-98cb-985aebdab411
    company_name    : Adobe Systems Incorporated
    product_name    : Adobe Media Encoder
    product_version : 12.0.0
    application_platform: Mac OS X
    product_uid     : 0c3919fe-46e8-11e5-a151-feff819cdc9f
    modification_date: 2018-01-09T11:32:25.000000Z
    material_package_umid: 0x060A2B340101010501010D1113000000C8FC790227810580CC9A985AEBDAB411
    timecode        : 00:00:00:00
    encoder         : Lavf58.32.104
    Stream #0:0: Video: mpeg2video (4:2:2), yuv422p(tv, unknown/bt709/bt709, top first), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 50000 kb/s, 25 fps, 25 tbr, 25 tbn, 25 tbc
    Metadata:
      file_package_umid: 0x060A2B340101010501010D1213DF61E1C8FC7902278105807C35985AEBDAB411
      file_package_name: Source Package
      track_name      : Track 1
    Stream #0:1: Audio: pcm_s24le, 192000 Hz, mono, s32 (24 bit), 4608 kb/s
    Metadata:
      file_package_umid: 0x060A2B340101010501010D1213DF61E1C8FC7902278105807C35985AEBDAB411
      file_package_name: Source Package
      track_name      : Track 2
      encoder         : Lavc58.56.101 pcm_s24le
frame=  250 fps=0.0 q=-1.0 Lsize=N/A time=00:00:10.00 bitrate=N/A speed=  21x
video:60771kB audio:5625kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown
[Parsed_loudnorm_0 @ 0000018c941ce700]
{
        "input_i" : "-19.90",
        "input_tp" : "-1.69",
        "input_lra" : "2.40",
        "input_thresh" : "-30.39",
        "output_i" : "-23.28",
        "output_tp" : "-5.06",
        "output_lra" : "0.40",
        "output_thresh" : "-33.59",
        "normalization_type" : "dynamic",
        "target_offset" : "0.28"
}

我可以在命令中输入什么来隔离它?

【问题讨论】:

  • |findstr /bc:" \"" 应该可以。 (cmets 编辑连续的空格 - 应该有八个)
  • 嗨@Stephan,我添加了这个但仍然得到完整的日志
  • 检查是否是TAB 而不是SPACEs

标签: windows cmd ffmpeg


【解决方案1】:

我在您的问题中收到文本,按名称 ffmepg.log 保存,然后尝试一些选项...

这是我所拥有的最好的......

@echo off 

2>log.log ffmpeg -i 03.mxf -c:v copy -c:a pcm_s24le -hide_banner -nostats -af loudnorm=I=-23:TP=-2:LRA=7:print_format=json -f null -

rem :: for get output in screen :: 
type log.log|findstr  "\{ \"\ \:\ \" }" | find /v "#" 

rem :: for get output in a file "fflog.log"" ::
type log.log|findstr  "\{ \"\ \:\ \" }" | find /v "#" >fflog.log

screen 和/或您的文件日志 fflog.log 中的结果:


{
        "input_i" : "-19.90",
        "input_tp" : "-1.69",
        "input_lra" : "2.40",
        "input_thresh" : "-30.39",
        "output_i" : "-23.28",
        "output_tp" : "-5.06",
        "output_lra" : "0.40",
        "output_thresh" : "-33.59",
        "normalization_type" : "dynamic",
        "target_offset" : "0.28"
}

对不起英文...


【讨论】:

  • 我不知道ffmpeg。它真的在 STDERR 上输出吗?
  • 这个肯定是在stderr里出来的,测试一下就知道了!
  • 我不会下载和安装我不需要的程序并学习它的用法。这就是我问的原因。谢谢你的澄清。
【解决方案2】:

以下内容准确提取(包括){} 之间的部分

方法a:每行只有一个字符或以八个空格开头(仔细检查-它可能是TAB):

type test.txt |findstr /r /bc:"        .*" /c:"^.$"

方法 b:每行包含一个引号 "{ 或 }`:

type test.txt |findstr  "\" { }"

插入完整的 ffmpeg 命令而不是 type test.txt 应该可以正常工作。
编辑: 正如我从 Itwasn'tMe 那里了解到的,ffmpeg 在 STDERR 上输出这些内容。所以真正的代码应该是(假设ffmpeg 语法在你的问题中是正确的):

ffmpeg -i 03.mxf -c:v copy -c:a pcm_s24le -hide_banner -nostats -af loudnorm=I=-23:TP=-2:LRA=7:print_format=json -f null - 2>&1 | findstr "\" { }"

【讨论】:

    【解决方案3】:

    剪切[Parsed_loudnorm'之前(包括)之前的所有行:

    ffmpeg -i input.mp4 -vn -sn -dn -pass 1                            \
    -af "loudnorm=print_format=json" -f null - 2>&1  |  sed '1,/^\[Parsed_loudnorm/d'
    
    • 2>&1因为相关信息都在stderr,我统一到stdout
    • sed 命令found here

    【讨论】:

      猜你喜欢
      • 2017-06-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-15
      • 1970-01-01
      • 2010-11-09
      相关资源
      最近更新 更多