JNH81 0 Posted November 8, 2018 Posted November 8, 2018 I have a script to convert a folder of MP3 audio files to M4A; my MP3 files's bitrates vary, some are 192k and some are 128k. I'm noticing that the bitrate of the M4A files are all getting bumped down to 128k. I'd like to retain their existing bitrate. What am I doing wrong? I put the files in a folder and run this command from shell: FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata 0 -c:v copy -c:a aac "%~nG.m4a"
Jdiesel 1286 Posted November 8, 2018 Posted November 8, 2018 (edited) I'm not an expert by any means but are you even able to do a stream copy when going from mp3 to aac? I thought stream copy only worked for changing containers not codecs. Sounds like the audio may be getting converted and the default bitrate when not specified is 128kbs. Edited November 8, 2018 by Jdiesel
speechles 2005 Posted November 8, 2018 Posted November 8, 2018 (edited) FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata 0 -c:a aac -b:a 192k "%~nG.m4a" Also, if this is music, as in extension .mp3 why do you even use -c:v copy? Audio files wont have video to copy anyways. Edited November 8, 2018 by speechles
JNH81 0 Posted November 8, 2018 Author Posted November 8, 2018 I'm not an expert by any means but are you even able to do a stream copy when going from mp3 to aac? I thought stream copy only worked for changing containers not codecs. Sounds like the audio may be getting converted and the default bitrate when not specified is 128kbs. Nor am I an expert... I'm not sure what you mean by stream? I can verify that the audio files once converted play just fine; just with a lower bitrate. FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata 0 -c:a aac -b:a 192k "%~nG.m4a" Also, if this is music, as in extension .mp3 why do you even use -c:v copy? Audio files wont have video to copy anyways. Good question, it was a mistake on my part. I will remove it but am still wondering about the bitrate portion. -c:a copy gives this error: [aac @ 000001ee03180c80] [Eval @ 00000069ea5fe170] Undefined constant or missing '(' in 'copy' [aac @ 000001ee03180c80] Unable to parse option value "copy" [aac @ 000001ee03180c80] Error setting option b to value copy. Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed!
Jdiesel 1286 Posted November 8, 2018 Posted November 8, 2018 Nor am I an expert... I'm not sure what you mean by stream? I can verify that the audio files once converted play just fine; just with a lower bitrate. My bad, I read your ffmpeg argument as attempting to do an audio stream copy. As for the bitrate when converting, it appears that when excluded from the argument ffmpeg will default to 128kbs for aac. https://superuser.com/questions/859220/does-ffmpegs-aac-encoder-need-a-audio-bitrate So as @@speechles suggested you will want to include -b:a 192k to specify the output bitrate. The downside is the 128kbps mp3s will be converted to 192kbps aac but it really is a non-issue as storage space likely isn't a concern.
JNH81 0 Posted November 8, 2018 Author Posted November 8, 2018 My folder contains different bitrates though, some 128, some 192, etc. I'd like to have the script just leave as is but I haven't been able to figure that one out yet.
mastrmind11 722 Posted November 8, 2018 Posted November 8, 2018 My folder contains different bitrates though, some 128, some 192, etc. I'd like to have the script just leave as is but I haven't been able to figure that one out yet. Why can't you just remux them to .m4a using the -c:a copy flag?
JNH81 0 Posted November 8, 2018 Author Posted November 8, 2018 Why can't you just remux them to .m4a using the -c:a copy flag? Hi, see my post above, it has the error in the output.
mastrmind11 722 Posted November 8, 2018 Posted November 8, 2018 Hi, see my post above, it has the error in the output. That looks like a parsing error. What's the full command that throws that error?
Happy2Play 9390 Posted November 8, 2018 Posted November 8, 2018 (edited) Have you seen this? https://stackoverflow.com/questions/16374028/unable-to-convert-mp3-to-m4a-using-ffmpeg linked in topic https://superuser.com/questions/370625/ffmpeg-command-to-convert-mp3-to-aac Edited November 8, 2018 by Happy2Play 1
JNH81 0 Posted November 9, 2018 Author Posted November 9, 2018 That looks like a parsing error. What's the full command that throws that error? FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata 0 -c:a aac -b:a copy "%~nG.m4a" [mp3 @ 000001a1e9e99c80] Estimating duration from bitrate, this may be inaccurate [ipod @ 000001a1e9f24fc0] Frame rate very high for a muxer not efficiently supporting it. Please consider specifying a lower framerate, a different muxer or -vsync 2 [libx264 @ 000001a1e9ed4ac0] using SAR=1/1 [libx264 @ 000001a1e9ed4ac0] MB rate (368640000) > level limit (16711680) [libx264 @ 000001a1e9ed4ac0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 [libx264 @ 000001a1e9ed4ac0] profile High 4:4:4 Predictive, level 6.2, 4:4:4, 8-bit [libx264 @ 000001a1e9ed4ac0] 264 - core 157 r2935 545de2f - H.264/MPEG-4 AVC codec - Copyleft 2003-2018 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x1:0x111 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=4 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 [aac @ 000001a1e9e9ca40] [Eval @ 00000001001fdd90] Undefined constant or missing '(' in 'copy' [aac @ 000001a1e9e9ca40] Unable to parse option value "copy" [aac @ 000001a1e9e9ca40] Error setting option b to value copy. Error initializing output stream 0:1 -- Error while opening encoder for output stream #0:1 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed!
Happy2Play 9390 Posted November 9, 2018 Posted November 9, 2018 (edited) I have a script to convert a folder of MP3 audio files to M4A; my MP3 files's bitrates vary, some are 192k and some are 128k. I'm noticing that the bitrate of the M4A files are all getting bumped down to 128k. I'd like to retain their existing bitrate. What am I doing wrong?[/size] I put the files in a folder and run this command from shell:[/size] FOR /F "tokens=*" %G IN ('dir /b *.mp3') DO ffmpeg -i "%G" -map_metadata 0 -c:v copy -c:a aac "%~nG.m4a" Looks like it is the default behavior for aac. https://superuser.com/questions/859220/does-ffmpegs-aac-encoder-need-a-audio-bitrate and using -vn "to prevent it from trying to convert the artwork/video" (so you don't need "-c:v copy") Edited November 9, 2018 by Happy2Play
JNH81 0 Posted November 9, 2018 Author Posted November 9, 2018 Are you saying then that there's no way to have it retain it's original bitrate? I suppose I could create folders with the bitrates the same and run the command to specify the bitrate.
mastrmind11 722 Posted November 9, 2018 Posted November 9, 2018 Are you saying then that there's no way to have it retain it's original bitrate? I suppose I could create folders with the bitrates the same and run the command to specify the bitrate. You could also incorporate ffprobe in your script to figure out the bitrate before sending the command to trancode.
JNH81 0 Posted November 9, 2018 Author Posted November 9, 2018 You could also incorporate ffprobe in your script to figure out the bitrate before sending the command to trancode. Nice, that is beyond my scripting. I'll play though.
Happy2Play 9390 Posted November 9, 2018 Posted November 9, 2018 Are you saying then that there's no way to have it retain it's original bitrate? I suppose I could create folders with the bitrates the same and run the command to specify the bitrate. You could also incorporate ffprobe in your script to figure out the bitrate before sending the command to trancode. Looks like a similar route was taken here, to do the opposite, but not Windows. https://kdecherf.com/blog/2012/01/14/ffmpeg-converting-m4a-files-to-mp3-with-the-same-bitrate/
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now