VideoHelp Forum


Try DVDFab Video Downloader and rip Netflix video! Or Try DVDFab and copy Blu-rays! or rip iTunes movies!
+ Reply to Thread
Results 1 to 13 of 13
Thread
  1. Member
    Join Date
    Jan 2009
    Location
    United Kingdom
    Search Comp PM
    I need ffprobe to pass the width and height values to ffmpeg as I want it to automatically set the aspect ratio.

    This is what I use to see what the rez is so far:

    Code:
    for %%i in ("%~nx1") do (
    C:\ffmpeg-4.2.2-win32-static\bin\ffprobe.exe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 "%%i"
    )
    I drag the video file onto the bat file and it will print the width and height in the console. So far, so good, I can see it pulls the values correctly.

    But I need to pass it to ffmpeg so I can do a simple division to set the aspect ratio in ffmpeg command:

    Code:
    -aspect: width/height
    I dont know how to pass the ffprobe values to ffmpeg.

    Help appreciated.
    Quote Quote  
  2. Member metis's Avatar
    Join Date
    Jan 2021
    Location
    Spain
    Search Comp PM
    You have to read out the FFProbe-Output and copy the obtained Width/Height-Values to the FFmpeg-CommandLine.

    To do it via a Script, use -report to print the Output to a Log-File.
    Then parse that Log-File for the Video's Width&Height and copy them to Your FFmpeg-CommandLine.

    For how to do it programmatically (what I like better), take a Look here:
    http://forum.lazarus.freepascal.org/index.php/topic,43411.0.html
    -> GoTo "RunFFmpeg".
    This App is actually designed to run any Multimedia-Task with one App via the FFmpeg-CommandLine-Tools
    'ffmpeg.exe', 'ffprobe.exe' and 'ffplay.exe'.
    You may extract from the SourceCode whatever You need for Your Purpose (I'm the Author).

    Or take my FFmpeg-Player, where You can adjust the AspectRatio (and all other VideoImage-Params) continuously, while
    Watching a Video, thus time-consuming Transcoding is not needed any more:
    https://forum.lazarus.freepascal.org/index.php/topic,26666.msg311955.html#msg311955
    -> GoTo "Adapt any MRL to any Screen".

    An other outstanding Feature of this Player is the optional AudioOutput via Portaudio, that
    supports ASIO for low-latency real-time Audio, e.g. required for VJ-ing.

    The Player there is still with 'SDL1'. Currently, I'm updating the entire Code to 'SDL2', The updated Version will work the same
    Way, plus some more Features, like horizontal/vertical Flip and continuous Rotation of the Videoimage and Touchscreen-Support.

    Hope, I could help You.
    Last edited by metis; 2nd Feb 2021 at 11:43.
    Life could be so easy, if there weren't those f*** Details.
    Quote Quote  
  3. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Well, if you use mediainfo, here's an alternative sample example

    Code:
    set tempfile=.\tempfile.tmp
    set mediainfoexe=C:\software\mediainfo\mediainfo.exe
    set mp4_filename=sopme_mp4_file.mp4
    Call :get_mediainfo_parameter "Video" "DisplayAspectRatio/String" "V_DisplayAspectRatio_String" "%~mp4_filename" 
    set "V_DisplayAspectRatio_String_slash=!V_DisplayAspectRatio_String::=/!
    REM Now do something using variable "V_DisplayAspectRatio_String_slash!"
    REM eg ffmpeg ... -vf "setdar=!V_DisplayAspectRatio_String_slash!" ...
    exit
    
    REM get a parameter from mediainfo
    :get_mediainfo_parameter
    REM DO NOT SET @setlocal ENABLEDELAYEDEXPANSION
    REM DO NOT SET @setlocal enableextensions
    REM ensure no trailing spaces in any of the lines in this routine !!
    set mi_Section=%~1
    set mi_Parameter=%~2
    set mi_Variable=%~3
    set mi_Filename=%~4
    set "mi_var="
    DEL /F "!tempfile!" >NUL 2>&1
    REM Note \r\n is Windows new-line, which is for the case of multiple audio streams, 
    REM it outputs a result for each stream on a new line, the first stream being the first entry,
    REM and the first audio stream should be the one we need. 
    REM Set /p from an input file reads the first line.
    "!mediainfoexe!" "--Inform=!mi_Section!;%%!mi_Parameter!%%\r\n" "!mi_Filename!" > "!tempfile!"
    set /p mi_var=<"!tempfile!"
    set !mi_Variable!=!mi_var!
    REM ECHO !DATE! !TIME! "!mi_Variable!=!mi_var!" from "!mi_Section!" "!mi_Parameter!"
    REM ECHO !DATE! !TIME! "!mi_Variable!=!mi_var!" from "!mi_Section!" "!mi_Parameter!"
    DEL /F "!tempfile!" >NUL 2>&1
    goto :eof
    One could perhaps contemplate fetching other characteristics as well, eg
    Code:
    Call :get_mediainfo_parameter_legacy "Video" "Codec" "V_Codec_legacy" "%~f1" 
    Call :get_mediainfo_parameter_legacy "Video" "Format" "V_Format_legacy" "%~f1" 
    REM
    Call :get_mediainfo_parameter_legacy "Audio" "Codec" "A_Codec_legacy" "%~f1" 
    Call :get_mediainfo_parameter_legacy "Audio" "CodecID" "A_CodecID_legacy" "%~f1" 
    Call :get_mediainfo_parameter_legacy "Audio" "Format" "A_Format_legacy" "%~f1" 
    Call :get_mediainfo_parameter_legacy "Audio" "Video_Delay" "A_Video_Delay_ms_legacy" "%~f1" 
    IF /I "!A_Video_Delay_ms_legacy!" == "" (
    	set /a "A_Audio_Delay_ms_legacy=0"
    ) ELSE (
    	set /a "A_Audio_Delay_ms_legacy=0 - !A_Video_Delay_ms_legacy!"
    )
    ECHO !DATE! !TIME! "A_Video_Delay_ms_legacy=!A_Video_Delay_ms_legacy!" 
    ECHO !DATE! !TIME! "A_Audio_Delay_ms_legacy=!A_Audio_Delay_ms_legacy!" Calculated 
    REM
    Call :get_mediainfo_parameter "General" "VideoCount" "G_VideoCount" "%~f1" 
    Call :get_mediainfo_parameter "General" "AudioCount" "G_AudioCount" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration" "G_Duration_ms" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration/String" "G_Duration_String" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration/String1" "G_Duration_String1" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration/String2" "G_Duration_String2" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration/String3" "G_Duration_String3" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration/String4" "G_Duration_String4" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration/String5" "G_Duration_String5" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration_Start" "G_Start" "%~f1" 
    Call :get_mediainfo_parameter "General" "Duration_End" "G_End" "%~f1" 
    REM
    Call :get_mediainfo_parameter "Video" "CodecID" "V_CodecID" "%~f1" 
    Call :get_mediainfo_parameter "Video" "CodecID/String" "V_CodecID_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format" "V_Format" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format/String" "V_Format_string" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format_Version" "V_Format_Version" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format_Profile" "V_Format_Profile" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format_Level" "V_Format_Level" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format_Tier" "V_Format_Tier" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format_Compression" "V_Format_Compression" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format_Commercial" "V_Format_Commercial" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Format_Commercial_IfAny" "V_Format_Commercial_IfAny" "%~f1" 
    Call :get_mediainfo_parameter "Video" "StreamKind" "V_StreamKind" "%~f1" 
    Call :get_mediainfo_parameter "Video" "StreamKind/String" "V_StreamKind_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "InternetMediaType" "V_InternetMediaType" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration" "V_Duration_ms" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration/String" "V_Duration_ms_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration/String1" "V_Duration_ms_String1" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration/String2" "V_Duration_ms_String2" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration/String3" "V_Duration_ms_String3" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration/String4" "V_Duration_ms_String4" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration/String5" "V_Duration_ms_String5" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration_Start" "V_Duration_Start" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Duration_End" "V_Duration_End" "%~f1" 
    REM
    Call :get_mediainfo_parameter "Video" "Source_Duration" "V_Source_Duration_ms" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_Duration/String" "V_Source_Duration_ms_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_Duration/String1" "V_Source_Duration_ms_String1" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_Duration/String2" "V_Source_Duration_ms_String2" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_Duration/String3" "V_Source_Duration_ms_String3" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_Duration/String4" "V_Source_Duration_ms_String4" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_Duration/String5" "V_Source_Duration_ms_String5" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_Duration_Start" "V_Source_Duration_Start" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_Duration_End" "V_Source_Duration_End" "%~f1" 
    REM
    Call :get_mediainfo_parameter "Video" "BitRate_Mode" "V_BitRate_Mode" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitRate_Mode/String" "V_BitRate_Mode_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitRate" "V_BitRate" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitRate/String" "V_BitRate_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitRate_Minimum" "V_BitRate_Minimum" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitRate_Minimum/String" "V_BitRate_Minimum_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitRate_Maximum" "V_BitRate_Maximum" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitRate_Maximum/String" "V_BitRate_Maximum_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BufferSize" "V_BufferSize" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Bits-(Pixel*Frame)" "V_Bits_Pixel_Frame" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitDepth" "V_BitDepth" "%~f1" 
    Call :get_mediainfo_parameter "Video" "BitDepth/String" "V_BitDepth_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Width" "V_Width" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Height" "V_Height" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Stored_Width" "V_Stored_Width" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Stored_Height" "V_Stored_Height" "%~f1" 
    Call :get_mediainfo_parameter "Video" "PixelAspectRatio" "V_PixelAspectRatio" "%~f1" 
    Call :get_mediainfo_parameter "Video" "PixelAspectRatio/String" "V_PixelAspectRatio_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "PixelAspectRatio_Original" "V_PixelAspectRatio_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "PixelAspectRatio_Original/String" "V_PixelAspectRatio_Original_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "DisplayAspectRatio" "V_DisplayAspectRatio" "%~f1" 
    Call :get_mediainfo_parameter "Video" "DisplayAspectRatio/String" "V_DisplayAspectRatio_String" "%~f1" 
    set "V_DisplayAspectRatio_String_slash=!V_DisplayAspectRatio_String::=/!"
    Call :get_mediainfo_parameter "Video" "DisplayAspectRatio_Original" "V_DisplayAspectRatio_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "DisplayAspectRatio_Original/String" "V_DisplayAspectRatio_Original_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Rotation" "V_Rotation" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Rotation/String" "V_Rotation_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Mode" "V_FrameRate_Mode" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Mode/String" "V_FrameRate_Mode_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Mode_Original" "V_FrameRate_Mode_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Mode_Original/String" "V_FrameRate_Mode_Original_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate" "V_FrameRate" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate/String" "V_FrameRate_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Minimum" "V_FrameRate_Minimum" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Minimum/String" "V_FrameRate_Minimum_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Nominal" "V_FrameRate_Nominal" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Nominal/String" "V_FrameRate_Nominal_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Maximum" "V_FrameRate_Maximum" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Maximum/String" "V_FrameRate_Maximum_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Original" "V_FrameRate_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Original/String" "V_FrameRate_Original_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Num" "V_FrameRate_Num" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Den" "V_FrameRate_Den" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Original_Num" "V_FrameRate_Original_Num" "%~f1" 
    Call :get_mediainfo_parameter "Video" "FrameRate_Original_Den" "V_FrameRate_Original_Den" "%~f1" 
    REM
    Call :get_mediainfo_parameter "Video" "FrameCount" "V_FrameCount" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Source_FrameCount" "V_Source_FrameCount" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Standard" "V_Standard" "%~f1" 
    REM
    Call :get_mediainfo_parameter "Video" "ColorSpace" "V_ColorSpace" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ChromaSubsampling" "V_ChromaSubsampling" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ChromaSubsampling/String" "V_ChromaSubsampling_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ChromaSubsampling_Position" "V_ChromaSubsampling_Position" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Gop_OpenClosed" "V_Gop_OpenClosed" "%~f1" 
    Call :get_mediainfo_parameter "Video" "Gop_OpenClosed/String" "V_Gop_OpenClosed_String" "%~f1" 
    REM
    Call :get_mediainfo_parameter "Video" "ScanType" "V_ScanType" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanType/String" "V_ScanType_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanType_Original" "V_ScanType_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanType_Original/String" "V_ScanType_Original_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanType_StoreMethod" "V_ScanType_StoreMethod" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanType_StoreMethod_FieldsPerBlock" "V_ScanType_StoreMethod_FieldsPerBlock" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanType_StoreMethod/String" "V_ScanType_StoreMethod_String" "%~f1" 
    IF /I "!V_ScanType!" == "" (
    	ECHO !DATE! !TIME! "V_ScanType blank, setting V_ScanType=Progressive"
    	ECHO !DATE! !TIME! "V_ScanType blank, setting V_ScanType=Progressive" 
    	set "V_ScanType=Progressive"
    )
    IF /I "!V_ScanType!" == "MBAFF" (
    	ECHO !DATE! !TIME! "V_ScanType blank, setting V_ScanType=Interlaced"
    	ECHO !DATE! !TIME! "V_ScanType blank, setting V_ScanType=Interlaced" 
    	set "V_ScanType=Interlaced"
    )
    Call :get_mediainfo_parameter "Video" "ScanOrder" "V_ScanOrder" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanOrder/String" "V_ScanOrder_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanOrder_Stored" "V_ScanOrder_Stored" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanOrder_Stored/String" "V_ScanOrder_Stored_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanOrder_StoredDisplayedInverted" "V_ScanOrder_StoredDisplayedInverted" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanOrder_Original" "V_ScanOrder_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "ScanOrder_Original/String" "V_ScanOrder_Original_String" "%~f1" 
    IF /I "!V_ScanOrder!" == "" (
    	ECHO !DATE! !TIME! "V_ScanOrder blank, setting V_ScanOrder=TFF"
    	ECHO !DATE! !TIME! "V_ScanOrder blank, setting V_ScanOrder=TFF" 
    	set "V_ScanOrder=TFF"
    )
    Call :get_mediainfo_parameter "Video" "HDR_Format" "V_HDR_Format" "%~f1" 
    Call :get_mediainfo_parameter "Video" "HDR_Format/String" "V_HDR_Format_String" "%~f1" 
    Call :get_mediainfo_parameter "Video" "HDR_Format_Commercial" "V_HDR_Format_Commercial" "%~f1" 
    Call :get_mediainfo_parameter "Video" "HDR_Format_Version" "V_HDR_Format_Version" "%~f1" 
    Call :get_mediainfo_parameter "Video" "HDR_Format_Profile" "V_HDR_Format_Profile" "%~f1" 
    Call :get_mediainfo_parameter "Video" "HDR_Format_Level" "V_HDR_Format_Level" "%~f1" 
    Call :get_mediainfo_parameter "Video" "HDR_Format_Settings" "V_HDR_Format_Settings" "%~f1" 
    Call :get_mediainfo_parameter "Video" "HDR_Format_Compatibility" "V_HDR_Format_Compatibility" "%~f1" 
    REM
    Call :get_mediainfo_parameter "Video" "colour_description_presence" "V_colour_description_presence" "%~f1" 
    Call :get_mediainfo_parameter "Video" "colour_range" "V_colour_range" "%~f1" 
    Call :get_mediainfo_parameter "Video" "colour_range_Source" "V_colour_range_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "colour_range_Original" "V_colour_range_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "colour_range_Original_Source" "V_colour_range_Original_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "colour_primaries" "V_colour_primaries" "%~f1" 
    Call :get_mediainfo_parameter "Video" "colour_primaries_Source" "V_colour_primaries_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "colour_primaries_Original" "V_colour_primaries_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "colour_primaries_Original_Source" "V_colour_primaries_Original_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "transfer_characteristics" "V_transfer_characteristics" "%~f1" 
    Call :get_mediainfo_parameter "Video" "transfer_characteristics_Source" "V_transfer_characteristics_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "matrix_coefficients" "V_matrix_coefficients" "%~f1" 
    Call :get_mediainfo_parameter "Video" "matrix_coefficients_Source" "V_matrix_coefficients_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MasteringDisplay_ColorPrimaries" "V_MasteringDisplay_ColorPrimaries" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MasteringDisplay_ColorPrimaries_Source" "V_MasteringDisplay_ColorPrimaries_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MasteringDisplay_Luminance" "V_MasteringDisplay_Luminance" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MasteringDisplay_Luminance_Source" "V_MasteringDisplay_Luminance_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MaxCLL" "V_MaxCLL" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MaxCLL_Source" "V_MaxCLL_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MaxCLL_Original" "V_MaxCLL_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MaxCLL_Original_Source" "V_MaxCLL_Original_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MaxFALL" "V_MaxFALL" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MaxFALL_Source" "V_MaxFALL_Source" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MaxFALL_Original" "V_MaxFALL_Original" "%~f1" 
    Call :get_mediainfo_parameter "Video" "MaxFALL_Original_Source" "V_MaxFALL_Original_Source" "%~f1" 
    REM
    Call :get_ffprobe_video_stream_parameter "codec_name" "V_CodecID_FF" "%~f1" 
    Call :get_ffprobe_video_stream_parameter "codec_tag_string" "V_CodecID_String_FF" "%~f1" 
    Call :get_ffprobe_video_stream_parameter "width" "V_Width_FF" "%~f1" 
    Call :get_ffprobe_video_stream_parameter "height" "V_Height_FF" "%~f1" 
    Call :get_ffprobe_video_stream_parameter "duration" "V_Duration_s_FF" "%~f1" 
    Call :get_ffprobe_video_stream_parameter "bit_rate" "V_BitRate_FF" "%~f1" 
    Call :get_ffprobe_video_stream_parameter "max_bit_rate" "V_BitRate_Maximum_FF" "%~f1"
    REM
    Call :get_mediainfo_parameter "Audio" "CodecID" "A_CodecID" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "CodecID/String" "A_CodecID_String" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Video_Delay" "A_Video_Delay_ms" "%~f1" 
    IF /I "!A_Video_Delay_ms!" == "" (
    	set /a A_Audio_Delay_ms=0
    ) ELSE (
    	set /a A_Audio_Delay_ms=0 - !A_Video_Delay_ms!
    )
    ECHO !DATE! !TIME! "A_Video_Delay_ms=!A_Video_Delay_ms!" 
    ECHO !DATE! !TIME! "A_Audio_Delay_ms=!A_Audio_Delay_ms!" Calculated 
    REM
    Call :get_mediainfo_parameter "Audio" "Video_Delay/String" "A_Video_Delay_String" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Video_Delay/String1" "A_Video_Delay_String1" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Video_Delay/String2" "A_Video_Delay_String2" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Video_Delay/String3" "A_Video_Delay_String3" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Video_Delay/String4" "A_Video_Delay_String4" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Video_Delay/String5" "A_Video_Delay_String5" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "InternetMediaType" "A_InternetMediaType" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format" "A_Format" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format/String" "A_Format_String" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format/Info" "A_Format_Info" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format_Commercial" "A_Format_Commercial" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format_Commercial_IfAny" "A_Format_Commercial_IfAny" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format_Version" "A_Format_Version" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format_Profile" "A_Format_Profile" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format_Level" "A_Format_Level" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Format_Compression" "A_Format_Compression" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Channel(s)" "A_Channels" "%~f1" 
    Call :get_mediainfo_parameter "Audio" "Channel(s)/String" "A_Channels_String" "%~f1"
    Quote Quote  
  4. Member hydra3333's Avatar
    Join Date
    Oct 2009
    Location
    Australia
    Search Comp PM
    Oh.
    The original post is dated yonks ago.
    Never mind, the info is there for posterity anyway.
    Quote Quote  
  5. Member metis's Avatar
    Join Date
    Jan 2021
    Location
    Spain
    Search Comp PM
    @ hydra3333

    The original post is dated yonks ago.
    This Subject/Question exists since there is 'FFmpeg'.
    At least, Bassquake (and maybe others) now got an Idea to get it solved.
    A Forum is a Repository, as well. Otherwise, any elder Thread could be deleted.
    Life could be so easy, if there weren't those f*** Details.
    Quote Quote  
  6. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    I find its easier to use MediaInfo:

    Code:
    ::@ echo off
    "MediaInfo.exe" --inform=Video;%%Width%% "C:\Users\bud\Desktop\xInstagram.mp4" > "C:\Users\bud\Desktop\test.txt"
    set /p width= < "C:\Users\bud\Desktop\test.txt" 
    "MediaInfo.exe" --inform=Video;%%Height%% "C:\Users\bud\Desktop\xInstagram.mp4" > "C:\Users\bud\Desktop\test.txt"
    set /p height= < "C:\Users\bud\Desktop\test.txt"
    echo resolution is: %width%x%height%
    "ffmpeg" -i "C:\Users\bud\Desktop\xInstagram.mp4" -vf scale=%width%:%height% outputtt.mp4
    Result:
    resolution is: 1152x648
    and file outputtt.mp4

    Media Info gets video attribute and pipes it to test.txt then imports to set each variable.
    Use the variable how you wish for ffmpeg. Here I have just used it to output another video with height and width specifications
    Use double %% for cmd file mediainfo part. Single % for ffmpeg cmd variables

    Be VERY careful with Capitalization and quotes. Height works, height doesn't. MediaInfo is fussy that way.
    Quote Quote  
  7. Member metis's Avatar
    Join Date
    Jan 2021
    Location
    Spain
    Search Comp PM
    And to do it (still) with FFProbe and -show_entries, see here:

    StackExchange: How to use ffprobe to obtain certain information about mp4/h.264 files

    and

    FFmpeg-Wiki: FFProbe-Tips
    -> GoTo "Width x Height (resolution)".
    Life could be so easy, if there weren't those f*** Details.
    Quote Quote  
  8. Here's how you can get the width and height into separate environment variables using ffprobe (similar to the MediaInfoCLI technique):

    Code:
    @echo off
    ffprobe.exe -v quiet -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p width= < %1.txt
    ffprobe.exe -v quiet -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p height= < %1.txt
    del %1.txt
    
    REM At this point the environment variables "width" and "height" are available to your ffmpeg command line.
    REM for example, to scale to half width and half height:
    ffmpeg -i %1 -vf scale=%width%/2:%height%/2 output.mkv
    Quote Quote  
  9. Member
    Join Date
    Jan 2009
    Location
    United Kingdom
    Search Comp PM
    Originally Posted by jagabo View Post
    Here's how you can get the width and height into separate environment variables using ffprobe (similar to the MediaInfoCLI technique):

    Code:
    @echo off
    ffprobe.exe -v quiet -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p width= < %1.txt
    ffprobe.exe -v quiet -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p height= < %1.txt
    del %1.txt
    
    REM At this point the environment variables "width" and "height" are available to your ffmpeg command line.
    REM for example, to scale to half width and half height:
    ffmpeg -i %1 -vf scale=%width%/2:%height%/2 output.mkv
    Thanks. I had a go.

    unfortunately it seems batch files only seems to support integers. I needed to divide the width and height to give decimal numbers for ffmpegs -aspect: tag. It will only give 1 rather than 1.277.

    Also doesnt work on avs scripts.

    Oh well, was worth a try.

    This was what I tried:

    Code:
    @echo off
    ffprobe.exe -v quiet -show_entries stream=width -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p width= < %1.txt
    ffprobe.exe -v quiet -show_entries stream=height -of default=noprint_wrappers=1:nokey=1 -select_streams v:0 %1 > %1.txt
    set /p height= < %1.txt
    set a=%width%
    set b=%height%
    set /a ratio=a/b
    
    REM At this point the environment variables "width" and "height" are available to your ffmpeg command line.
    REM for example, to scale to half width and half height:
    ffmpeg -i %1 -aspect: %ratio% output.mkv
    pause
    Quote Quote  
  10. ffmpeg's -aspect tag accepts two values separate by a colon.

    You can create an AVS script that uses the environment variables with a batch file.
    Last edited by jagabo; 10th Feb 2021 at 09:22.
    Quote Quote  
  11. Member
    Join Date
    Jan 2009
    Location
    United Kingdom
    Search Comp PM
    Originally Posted by jagabo View Post
    ffmpeg's -aspect tag accepts two values separate by a colon.
    Cool. That works:

    Code:
    ffmpeg -i %1 -aspect: %width%:%height% output.mkv
    I'm guessing it's impossible to have the ffprobe work on avisynth scripts (currently using AvSPMod)?
    Quote Quote  
  12. I added information to my last post about how you can pass environment variables to AVS script.
    Quote Quote  
  13. Member
    Join Date
    Jan 2009
    Location
    United Kingdom
    Search Comp PM
    Originally Posted by jagabo View Post
    I added information to my last post about how you can pass environment variables to AVS script.
    Cheers. Didnt see it till refeshed page.
    Quote Quote  



Similar Threads