I have FFmpeg installed on my Manjaro xfce system and I would like to know how to adjust the volume of multiple video files at once to make them louder, similar to the Add To Queue button in Handbrake. Please bear with me, I’m quite a newbie. At most I can adjust the volume of a single file.
#!/bin/bash for file in *.mp4; do ffmpeg -i "$file" -af "volume=3dB" "output_$file" done
Can I use the Manjaro terminal for a bash script or do I need to use another text editor? I had assumed I open the Manjaro terminal, change to the directory housing my video files and enter the command. I can’t seem to succeed that way, I think a big gap in my understanding of how to do this.
In the command itself, do I replace $file with ${my filename} and output_$f with {myoutputname}_$f
Just run it from a terminal within the directory. Make sure you leave the #!/bin/bash off at the start though if running from the command line, as the # will make it look like a comment to be ignored.
An alternative might be to use aacgain, which is in the AUR. It can adjust the volume of files in a process which is reversible at any time, and all files can be set to the same volume. aacgain is a modification to mp3gain which can be used on mp4 files. Make sure you read the mp3gain instructions link below before using aacgain though:
It should, since the ffmpeg command doesn’t specify an audio codec.
Maybe you should copy a few of your mkv files across to a test directory and run the command in the test directory to see if it works. If it doesn’t, ffmpeg should show in the terminal what the problem is.
There is also MKVToolNix which is handy for Matroska (.mkv) files; which allows to separate and export the audio track, and remux it later.
It’s not an elegant or easy solution, however, it is a powerful application for manipulating Matroska files. A brief look at MKVToolNix capabilities will reveal just how useful it can be:
I also suggest trying the loudnorm filter that can give more consistent results (EBU R128 broadcast standard) and the ffmpeg-normalize python script for ffmpeg
It works when I copy the command directly but I can’t seem to get it right when I type out the command myself. This could be just my inexperience and making typo or spacing errors etc, but is there maybe something extra embedded in the command you posted that a plain text command can’t do (excuse my ignorance, the different colours on $file, etc)?
Using ffmpeg this way seems to shrink the file size of the video slightly. I actually thought only the audio would be re-encoded. What is ffmpeg actually doing?
I don’t have an answer as I don’t know what you are manually typing in the terminal, but there is definitely nothing extra embedded in the command (which was originally provided by you, not me. I just added a missing semicolon to fix it).
Maybe it is re-encoding - I don’t use ffmpeg to adjust volume. I use mp3gain to adjust the volume on mp3s, and aacgain (apparently) does the same thing for mp4s. mp3gain doesn’t re-encode, it just adds a tag to the file metadata telling compatible players to increase or lower the volume of the file (and thus also makes the changes reversible). aacgain does the same thing.
That is why I recommended that you try aacgain (although I’ve never used it myself - I just scroll the mouse wheel on the volume icon in my system tray if a video is too loud or quiet).
aacgain should be very simple & very fast, but you will have to do some reading at the links I provided in post 2 of this thread. I just don’t have the time to coach you through the process. The mp3gain instructions (especially the command line section) are required reading because the author of aacgain says it uses the same commands (except with aacgain instead of mp3gain at the start).