Previous topicNext topic

mp4 audio bitrate

Questions, comments, feedback, etc.
Post Reply
dsp2b4u2
Posts: 3
Joined: Sun Feb 05, 2023 10:35 pm

mp4 audio bitrate

Post by dsp2b4u2 »

Hello,
Exporting to mp4 from Magic Studio seems to always use a low audio bitrate of 132kbps, even though the audio track used for the source is much higher.
How can I increase the audio bitrate?

Thanks in advance.
Wolf_T
Posts: 7
Joined: Thu Jan 19, 2023 5:47 pm

Re: mp4 audio bitrate

Post by Wolf_T »

For .movs, the audio will not be compressed in order to preserve maximum quality.
dsp2b4u2
Posts: 3
Joined: Sun Feb 05, 2023 10:35 pm

Re: mp4 audio bitrate

Post by dsp2b4u2 »

Wolf_T wrote:For .movs, the audio will not be compressed in order to preserve maximum quality.
Thanks. Indeed I noticed audio rate is around 1.4Mbps for .mov files, but the file size is huge (pro-res).
Any idea how to get higher audio rate in .mp4 files? Can Magic please make this a feature for next update please? This is after-all a "music" visualizer.
Thanks a lot.
Terry Payman
Posts: 710
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: mp4 audio bitrate

Post by Terry Payman »

I vaguely remember using ffmpeg to replace the audio in an mp4 file, which it could do without re-encoding the video. The process ran very quickly, even with a 40 minute video.

I think that you could get any bit rate with that approach.

I'll see if I can find my ffmpeg command string.
Terry Payman
Posts: 710
Joined: Sun Sep 14, 2014 8:15 am
Location: UK
Contact:

Re: mp4 audio bitrate

Post by Terry Payman »

Replacing an mp4 audio file can be done! Windows example follows.
Sorry, I don't have time at the moment to simplify the following into a simple command for one file. Hopefully the following will be useful, or at least inspiration for your own internet search (or ChatGPT query).

I found the ffmpeg string (in bold below), but clearly it was something that I'd found or adapted from an internet post - as I don't fully understand it! Furthermore it was within a Windows batch file, invoked from a second batch file which was designed to operate on a directory containing many mp4 files. I can't attach batch files, but following are the filenames and contents.

StartRemux.bat
  • for %%F in (*.mp4) do remux_settings_.bat "%%F"
remux_settings_.bat
  • ffmpeg.exe -i %~d1%~p1%~n1.mp4 -i %~d1%~p1%~n1.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 %~d1%~p1%~n1_n.mp4

Notes
  • The batch files must run in a directory with no spaces in the filepath, likewise filenames must have no spaces.
    The video and replacement audio files must be in the same directory as the batch files.
    The video and audio files must have the same base name.
    A copy of ffmpeg must be in the same directory (or on the Windows search path).
    To start the process, open a PowerShell Window (shift-rightclick on the directory), then type ".\startremux"
With no time to remember or figure out what all the ffmpeg switches do I asked ChatGPT!

What does the following ffmpeg command string do? "ffmpeg.exe -i %~d1%~p1%~n1.mp4 -i %~d1%~p1%~n1.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 %~d1%~p1%~n1_n.mp4"

This FFmpeg command performs the following tasks:
  • 1) Takes two inputs: an MP4 video file and a WAV audio file, both of which have the same base file name, directory and path as the batch script or command line argument that is running this FFmpeg command.

    2) Copies the video stream of the MP4 file (-c:v copy) and encodes the audio stream of the WAV file into Advanced Audio Coding (AAC) format (-c:a aac).

    3) Maps the first input file's video stream (0:v:0) and the second input file's audio stream (1:a:0) to the output file.

    4) Generates an output MP4 file with "_n" added to the end of its base file name, which is the same as the input files' directory and path.


This command is essentially remuxing the audio and video streams of the two input files into a single output MP4 file while converting the audio to AAC format.



How do I change the following ffmpeg command string if I want to spacify the audio bitrate? "ffmpeg.exe -i %~d1%~p1%~n1.mp4 -i %~d1%~p1%~n1.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 %~d1%~p1%~n1_n.mp4"

To specify the audio bitrate in the FFmpeg command, you can add the "-b:a" option followed by the desired bitrate value, in bits per second. Here is an example:
  • ffmpeg.exe -i %~d1%~p1%~n1.mp4 -i %~d1%~p1%~n1.wav -c:v copy -c:a aac -b:a 128k -map 0:v:0 -map 1:a:0 %~d1%~p1%~n1_n.mp4


In this example, the audio bitrate is set to 128 kilobits per second (128k). You can adjust this value to a different value as needed.
dsp2b4u2
Posts: 3
Joined: Sun Feb 05, 2023 10:35 pm

Re: mp4 audio bitrate

Post by dsp2b4u2 »

Many thanks Terry!
Terry Payman wrote:Replacing an mp4 audio file can be done! Windows example follows.
Sorry, I don't have time at the moment to simplify the following into a simple command for one file. Hopefully the following will be useful, or at least inspiration for your own internet search (or ChatGPT query).

I found the ffmpeg string (in bold below), but clearly it was something that I'd found or adapted from an internet post - as I don't fully understand it! Furthermore it was within a Windows batch file, invoked from a second batch file which was designed to operate on a directory containing many mp4 files. I can't attach batch files, but following are the filenames and contents.

StartRemux.bat
  • for %%F in (*.mp4) do remux_settings_.bat "%%F"
remux_settings_.bat
  • ffmpeg.exe -i %~d1%~p1%~n1.mp4 -i %~d1%~p1%~n1.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 %~d1%~p1%~n1_n.mp4

Notes
  • The batch files must run in a directory with no spaces in the filepath, likewise filenames must have no spaces.
    The video and replacement audio files must be in the same directory as the batch files.
    The video and audio files must have the same base name.
    A copy of ffmpeg must be in the same directory (or on the Windows search path).
    To start the process, open a PowerShell Window (shift-rightclick on the directory), then type ".\startremux"
With no time to remember or figure out what all the ffmpeg switches do I asked ChatGPT!

What does the following ffmpeg command string do? "ffmpeg.exe -i %~d1%~p1%~n1.mp4 -i %~d1%~p1%~n1.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 %~d1%~p1%~n1_n.mp4"

This FFmpeg command performs the following tasks:
  • 1) Takes two inputs: an MP4 video file and a WAV audio file, both of which have the same base file name, directory and path as the batch script or command line argument that is running this FFmpeg command.

    2) Copies the video stream of the MP4 file (-c:v copy) and encodes the audio stream of the WAV file into Advanced Audio Coding (AAC) format (-c:a aac).

    3) Maps the first input file's video stream (0:v:0) and the second input file's audio stream (1:a:0) to the output file.

    4) Generates an output MP4 file with "_n" added to the end of its base file name, which is the same as the input files' directory and path.


This command is essentially remuxing the audio and video streams of the two input files into a single output MP4 file while converting the audio to AAC format.



How do I change the following ffmpeg command string if I want to spacify the audio bitrate? "ffmpeg.exe -i %~d1%~p1%~n1.mp4 -i %~d1%~p1%~n1.wav -c:v copy -c:a aac -map 0:v:0 -map 1:a:0 %~d1%~p1%~n1_n.mp4"

To specify the audio bitrate in the FFmpeg command, you can add the "-b:a" option followed by the desired bitrate value, in bits per second. Here is an example:
  • ffmpeg.exe -i %~d1%~p1%~n1.mp4 -i %~d1%~p1%~n1.wav -c:v copy -c:a aac -b:a 128k -map 0:v:0 -map 1:a:0 %~d1%~p1%~n1_n.mp4


In this example, the audio bitrate is set to 128 kilobits per second (128k). You can adjust this value to a different value as needed.
Post Reply