Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I don't know much about .bat files or ffmpeg and spent the last hour on the internet searching how I can solve my problem, but didn't find anything. I want to make .bat file which removes the audio of a video and replaces it with the no-audio version. I already made a folder with my .bat file and ffmpeg and added an option to the context menu to open my .bat file.

That's my .bat file currently:

ffmpeg -i %1 -an -vcodec copy %1

But ffmpeg can't overwrite the file it's currently reading. It would be great if somebody helps me how to create a temporary file without the audio, and then replace the input file with the temporary one.

Thanks a lot in advance!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
471 views
Welcome To Ask or Share your Answers For Others

1 Answer

A simple way to mute a video in FFmpeg is

ffmpeg -i input.mp4 -filter:a "volume=0.0" output.mp4

volume = 0.0 inciated making audio to 0

I recommend using Python to code as u need to take all files from a folder and mute them all.I will share a sample code

here is a .bat file which u can wite and which will run python file when u click it

#!/bin/bash
function edit_2x()
{
    python file_name.py
    TIMEOUT 10
}

file_name.py

import os
Folder_Path = r'K:\to_mute\'
Output_Folder_Path = r'K:\muted_videos\'

fileNames = os.listdir(Folder_Path)

for fileName in fileNames:
    if 'Done' not in fileName:
        print("File Name :"+fileName ) 
        os.system("ffmpeg -i "+fileName+" -filter:a 'volume=0.0' "+fileName);
        os.rename(Video_Path+fileNamee,Video_Path+"Done "+fileNamee)

A simple explanation to code is it takes all file names and stores them in a list and u will take one file and mute them and store them in another folder and updating the original file name with Done so there will be no further confusion. Hope its clear


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...