Skip to content
The Chat Archive
o1-preview-2024-09-12· OpenAI WildChat-4.8M (AI2)

write me a .bat file that I can drag n drop video or audio files, and it'll use ffmpeg…

  1. User

    write me a .bat file that I can drag n drop video or audio files, and it'll use ffmpeg to convert the audio's sampling rate into 32000 hz without affecting video quality

  2. Assistant

    Sure! Below is a Windows batch script (.bat file) that you can use. Save this code into a file with a .bat extension (e.g., convert_audio_sample_rate.bat). You can then drag and drop video or audio files onto this script, and it will use ffmpeg to convert their audio sampling rate to 32000 Hz without affecting the video quality.

    @echo off
    setlocal enabledelayedexpansion
    echo Processing files...
    for %%a in (%*) do (
      rem Set variables
      set "input=%%~a"
      set "filename=%%~na"
      set "extension=%%~xa"
      set "output=!filename!_converted!extension!"
    
      echo Processing "!input!" to "!output!"
    
      ffmpeg -i "!input!" -c:v copy -ar 32000 "!output!"
    )
    endlocal
    

    Explanation:

    • for %%a in (%*) do (...): Loops over all files dropped onto the script.
    • set "input=%%~a": Sets the input variable to the full path of the current file.
    • set "filename=%%~na": Extracts the filename without extension.
    • set "extension=%%~xa": Gets the file extension.
    • set "output=!filename!_converted!extension!": Creates the output filename by appending _converted before the extension.
    • ffmpeg -i "!input!" -c:v copy -ar 32000 "!output!": Runs ffmpeg to process the file, copying the video stream and changing the audio sampling rate to 32000 Hz.

    Usage:

    1. Ensure ffmpeg is installed and added to your system's PATH.
    2. Save the script above as convert_audio_sample_rate.bat.
    3. Drag and drop your video or audio files onto the .bat file.
    4. The script will process each file and output a new file with _converted added to the filename.

    Notes:

    • This script preserves the original video quality by copying the video stream (-c:v copy).
    • It changes the audio sampling rate to 32000 Hz (-ar 32000).
    • The output files are saved in the same directory as the input files with _converted in their filenames.
    • Make sure your filenames don't have special characters that might interfere with the command line.

    Let me know if you need any more assistance!