Jump to content


Photo

FFMPEG converting from MP3 to M4A - bitrate

ffmpeg

  • Please log in to reply
15 replies to this topic

#1 JNH81 OFFLINE  

JNH81

    Newbie

  • Members
  • 7 posts
  • Local time: 05:46 PM

Posted 08 November 2018 - 10:04 AM

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"


#2 Jdiesel OFFLINE  

Jdiesel

    Advanced Member

  • Members
  • 2584 posts
  • Local time: 04:46 PM
  • LocationRegina, SK

Posted 08 November 2018 - 10:42 AM

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 by Jdiesel, 08 November 2018 - 10:43 AM.


#3 speechles OFFLINE  

speechles

    Advanced Member

  • App Developer
  • 3966 posts
  • Local time: 03:46 PM

Posted 08 November 2018 - 12:57 PM

 
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 by speechles, 08 November 2018 - 12:58 PM.


#4 JNH81 OFFLINE  

JNH81

    Newbie

  • Members
  • 7 posts
  • Local time: 05:46 PM

Posted 08 November 2018 - 01:08 PM

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!


#5 Jdiesel OFFLINE  

Jdiesel

    Advanced Member

  • Members
  • 2584 posts
  • Local time: 04:46 PM
  • LocationRegina, SK

Posted 08 November 2018 - 01:24 PM

 

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.co...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.



#6 JNH81 OFFLINE  

JNH81

    Newbie

  • Members
  • 7 posts
  • Local time: 05:46 PM

Posted 08 November 2018 - 02:16 PM

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.



#7 mastrmind11 OFFLINE  

mastrmind11

    Advanced Member

  • Members
  • 2607 posts
  • Local time: 06:46 PM
  • LocationLong Island, NY

Posted 08 November 2018 - 02:59 PM

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?



#8 JNH81 OFFLINE  

JNH81

    Newbie

  • Members
  • 7 posts
  • Local time: 05:46 PM

Posted 08 November 2018 - 05:41 PM

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.



#9 mastrmind11 OFFLINE  

mastrmind11

    Advanced Member

  • Members
  • 2607 posts
  • Local time: 06:46 PM
  • LocationLong Island, NY

Posted 08 November 2018 - 05:52 PM

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?



#10 Happy2Play OFFLINE  

Happy2Play

    Trial and Error

  • Moderators
  • 13828 posts
  • Local time: 03:46 PM
  • LocationWashington State

Posted 08 November 2018 - 05:54 PM

Have you seen this?

 

https://stackoverflo...4a-using-ffmpeg

 

linked in topic 

 

https://superuser.co...vert-mp3-to-aac


Edited by Happy2Play, 08 November 2018 - 05:58 PM.

  • mastrmind11 likes this

#11 JNH81 OFFLINE  

JNH81

    Newbie

  • Members
  • 7 posts
  • Local time: 05:46 PM

Posted 08 November 2018 - 09:24 PM

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!


#12 Happy2Play OFFLINE  

Happy2Play

    Trial and Error

  • Moderators
  • 13828 posts
  • Local time: 03:46 PM
  • LocationWashington State

Posted 09 November 2018 - 04:29 AM

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.co...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 by Happy2Play, 09 November 2018 - 04:34 AM.


#13 JNH81 OFFLINE  

JNH81

    Newbie

  • Members
  • 7 posts
  • Local time: 05:46 PM

Posted 09 November 2018 - 09:36 AM

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. 



#14 mastrmind11 OFFLINE  

mastrmind11

    Advanced Member

  • Members
  • 2607 posts
  • Local time: 06:46 PM
  • LocationLong Island, NY

Posted 09 November 2018 - 10:27 AM

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.



#15 JNH81 OFFLINE  

JNH81

    Newbie

  • Members
  • 7 posts
  • Local time: 05:46 PM

Posted 09 November 2018 - 04:03 PM

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.



#16 Happy2Play OFFLINE  

Happy2Play

    Trial and Error

  • Moderators
  • 13828 posts
  • Local time: 03:46 PM
  • LocationWashington State

Posted 09 November 2018 - 04:24 PM

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...e-same-bitrate/







Also tagged with one or more of these keywords: ffmpeg

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users