仅隔离输出:FFmpeg



我试图在运行命令时隔离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:AbulDocumentsProjectsIngestQCSource_FolderIRO_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"
}

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

下面准确地提取了(包括({}之间的部分

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

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

方法 b:包含引号的每一行"{或 }':

type test.txt |findstr  "" { }"

插入完整的ffmpeg命令而不是type test.txt应该工作相同。
编辑:正如我从Itwas'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 "" { }"

我在你的问题中得到文本,按名称保存 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"
}

对不起英语...


[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 命令

最新更新