Solved Mkv with ac3 to mp4 with aac

Status
Not open for further replies.

burro08

Junior Member
Original poster
Local time
11:40 AM
Nov 13, 2018
11
2
With ffmpeg how do i batch convert my mkvs with ac3 to mp4 with aac?

Ive tried

ffmpeg -i in *.mkv; do ffmpeg -i "$i" -c:a libfdk_aac -b:a 384k -c:v copy "${i%.mkv}.mp4"; done
i get bash: syntax error near unexpected token do'

Any advice would be great

Thanks
 

Admin9705

Administrator
Project Manager
Local time
6:40 AM
Jan 17, 2018
4,759
1,807
With ffmpeg how do i batch convert my mkvs with ac3 to mp4 with aac?

Ive tried

ffmpeg -i in *.mkv; do ffmpeg -i "$i" -c:a libfdk_aac -b:a 384k -c:v copy "${i%.mkv}.mp4"; done
i get bash: syntax error near unexpected token do'

Any advice would be great

Thanks
sound like an error with a while loop?
 

burro08

Junior Member
Original poster
Local time
11:40 AM
Nov 13, 2018
11
2
Yeah thought that. Thought someone smarter than might know what I'm doing wrong. I'm running out of patients trying to get it to run lol
 
  • Like
Reactions: Admin9705

Admin9705

Administrator
Project Manager
Local time
6:40 AM
Jan 17, 2018
4,759
1,807
Yeah thought that. Thought someone smarter than might know what I'm doing wrong. I'm running out of patients trying to get it to run lol
after all these rewrites, i'll focus on the conversion piece
 

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
I'll see if I can find my old conversion bash for you. But, remove that ; done maybe?
 

burro08

Junior Member
Original poster
Local time
11:40 AM
Nov 13, 2018
11
2
I'll see if I can find my old conversion bash for you. But, remove that ; done maybe?
i removed it and i get

$ ffmpeg -i in *.mkv; do ffmpeg -i "$i" -c:a libfdk_aac -b:a 384k -c:v copy "${i%.mkv}.mp4"

bash: syntax error near unexpected token `do'
 

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
i removed it and i get

$ ffmpeg -i in *.mkv; do ffmpeg -i "$i" -c:a libfdk_aac -b:a 384k -c:v copy "${i%.mkv}.mp4"

bash: syntax error near unexpected token `do'
Try it like this:
for file in *.mkv; do ffmpeg -i "$file" -c:a libfdk_aac -b:a 384k -c:v copy "${file%.mkv}.mp4"; done
 
  • Like
Reactions: pb1051 and burro08

denzel

Full Member
Donor
Local time
12:40 PM
Nov 5, 2018
42
5
for file in *.mkv; do ffmpeg -i "$file" -c:a libfdk_aac -b:a 384k -c:v copy "${file%.mkv}.mp4"; done
I get the error message Unknown encoder 'libfdk_aac'. How can I install the encoder? I didn't really understand what I have to do when I googled it :-(
 

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
I haven't tested it but you can try to make a bash file and have it installed.

create a file install_aac.sh and paste in the following code

Code:
#!/bin/bash

apt-get update
apt-get -y install autoconf automake build-essential git-core libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev libmp3lame-dev nasm gcc yasm && true
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean
cd ~/ffmpeg_sources
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make
make install
make distclean
cd ~/ffmpeg_sources
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="$HOME/ffmpeg_build" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac \
  --enable-libmp3lame --enable-nonfree
make
make install
cp ffmpeg /usr/bin/
make distclean
hash -r
ffmpeg 2>&1 | head -n1
Make it executable.
Code:
chmod u+x install_aac.sh
then run it.

I don't know if it will work since I didn't have time to test it but it seems legit.
 
Last edited:
  • Like
Reactions: MrDoob

denzel

Full Member
Donor
Local time
12:40 PM
Nov 5, 2018
42
5
I haven't tested it but you can try to make a bash file and have it installed.

create a file install_aac.sh and paste in the following code

Code:
#!/bin/bash

apt-get update
apt-get -y install autoconf automake build-essential git-core libass-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev libmp3lame-dev nasm gcc yasm && true
mkdir ~/ffmpeg_sources
cd ~/ffmpeg_sources
git clone --depth 1 git://github.com/mstorsjo/fdk-aac.git
cd fdk-aac
autoreconf -fiv
./configure --prefix="$HOME/ffmpeg_build" --disable-shared
make
make install
make distclean
cd ~/ffmpeg_sources
wget http://downloads.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz
tar xzvf lame-3.99.5.tar.gz
cd lame-3.99.5
./configure --prefix="$HOME/ffmpeg_build" --enable-nasm --disable-shared
make
make install
make distclean
cd ~/ffmpeg_sources
git clone --depth 1 git://source.ffmpeg.org/ffmpeg
cd ffmpeg
PKG_CONFIG_PATH="$HOME/ffmpeg_build/lib/pkgconfig"
export PKG_CONFIG_PATH
./configure --prefix="$HOME/ffmpeg_build" \
  --extra-cflags="-I$HOME/ffmpeg_build/include" --extra-ldflags="-L$HOME/ffmpeg_build/lib" \
  --bindir="$HOME/bin" --extra-libs="-ldl" --enable-gpl --enable-libass --enable-libfdk-aac \
  --enable-libmp3lame --enable-nonfree
make
make install
cp ffmpeg /usr/bin/
make distclean
hash -r
ffmpeg 2>&1 | head -n1
Make it executable.
Code:
chmod u+x install_aac.sh
then run it.

I don't know if it will work since I didn't have time to test it but it seems legit.
Wow, you are awesome, that worked like a charm! :love:
Thank you so much, I would have never figured out that solution!
 
  • Like
Reactions: SirTranceALoT

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
Oh awesome! Glad it worked :)
 

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
aparently it does. I'm just as shocked as you are lol
 

denzel

Full Member
Donor
Local time
12:40 PM
Nov 5, 2018
42
5
Actually it works pretty well!
So far I was transcoding with Don Melton's video transcoding, what is using mainly HandbrakeCLI. The ffmpeg script is a lot faster. But I didn't compare the result in detail yet.

@SirTranceALoT: you are transcoding with this script right and did a lot of research for the best result to make the files stream ready?

I think it would make sense to integrate it directly in PlexGuide :)
 
  • Like
Reactions: pb1051

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
what I would really love to accomplish is to have the AAC part be encoded with coreaudio and LLC profile (Apple's Core Audio AAC encoder). I use that on windows in combination with QAAC as the wrapper for that. There have been tests and a q92 quality setting is transparant with the source. q82 is near transparancy. Audio quality is superb with the most reasonable filesize. I have to look into making that work on ubuntu.

Although Don Marton has quite a nice selection of tools.

Now, libfdk_aac is the frauhnhoffen encoder. It does HE-AAC wich is very usefull at low bitrates. However, the native AAC encoder in ffmpeg provides better quality it seems and uses LLC. You can also specify a variable bitrate quality setting. The commandline for this would be:
Code:
for file in *.mkv; do ffmpeg -i "$file" -c:a aac -q:a 2 -c:v copy "${file%.mkv}.mp4"; done
 
Last edited:

Admin9705

Administrator
Project Manager
Local time
6:40 AM
Jan 17, 2018
4,759
1,807
ok on the to do list :D
 

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
Don't implement it quite yet. I'll see if I can built this out a little and do some testing. Will report back with a final thing.
 
  • Like
Reactions: MrDoob

Xployt

Administrator
Staff
Donor
Local time
11:40 AM
Sep 26, 2018
163
75
@SirTranceALoT Great script!

Was just wondering if it checks for outputs that already have the aac and mp4 formats or is this already a feature with ffmpeg?

I did have a read through but couldn't see anything. Please correct me if I'm wrong?
 

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
No it doesn't check. Good you mentioned it.
 

SirTranceALoT

Legendary Member
Staff
Local time
12:40 PM
Jun 14, 2018
319
138
Did some more tinkering. The native encoder for ffmpeg actually works best so no nneed to use or compile it with libfdq_aac. Ignore the above script if you wish to save yourself some hastle. Just install ffmpeg either from repo or source and you're fine. The commandline used to mass convert your audiotracks would then be

Code:
for file in *.mkv; do ffmpeg -i "$file" -c:a aac -q:a 2 -c:v copy "${file%.mkv}.mp4"; done
 
  • Like
Reactions: denzel

burro08

Junior Member
Original poster
Local time
11:40 AM
Nov 13, 2018
11
2
What's the command so ffmpeg looks in all folders within a folder. Ie

American horror story
Season 1
Season 2
Season 3 etc

I want to convert all mkvs to aac mp4
 
Status
Not open for further replies.

Similar threads


Maintenance Donations

Recommend NewsGroups

      Up To a 58% Discount!

Trending