Search code examples
windowscmdffmpeg

isolate the output only: FFmpeg


I'm trying to isolate the value given by ffmpeg when running a command.

The command is:

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 -

I only want the JSON text:

{
        "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"
}

However,

The output is:

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"
}

What can I put in the command to isolate this?


Solution

  • The following extracts exactly the part between (including) { and }

    Method a: every line that has only one character or starts with eight spaces (double-check - it might be a TAB instead):

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

    Method b: every line that contains a quote " or a { or a }`:

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

    inserting your complete ffmpeg command instead of type test.txt should work the same.
    Edit: As I learned from Itwasn'tMe, ffmpeg outputs that stuff on STDERR. So the real code should be (assuming the ffmpeg syntax is correct in your question):

    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 "\" { }"