Tuesday, April 30, 2024
 Popular · Latest · Hot · Upcoming
21
rated 0 times [  21] [ 0]  / answers: 1 / hits: 20655  / 3 Years ago, sat, june 26, 2021, 7:34:44

I have about 70 mp4 files, and I want to extract the audio files directly without transcoding further. All the mp4 files have aac audio files.



I understand I can use the following command to extract the audio file from one of the mp4 files:



avconv -i "INPUT FILE" -map 0:1 -c:a copy "OUTPUT FILE"


How do I extract all the audio files from all the 70 mp4 files, so I end up with 70 aac files?


More From » 12.04

 Answers
7

You can use a simple for loop:



for i in *.mp4; do
avconv -i "${i}" -map 0:1 -c:a copy "${i%.mp4}.aac"
done


or on one line:



for i in *.mp4; do avconv -i "${i}" -map 0:1 -c:a copy "${i%.mp4}.aac"; done


What is does is run avconv once for every file named like *.mp4 where the filename is stored in the ${i} variable.



${i%.mp4} means ${i} (ie. the filename) with .mp4 stripped off from the end.


[#33376] Sunday, June 27, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
berlorful

Total Points: 346
Total Questions: 90
Total Answers: 99

Location: Monaco
Member since Tue, Nov 30, 2021
2 Years ago
berlorful questions
Thu, Sep 2, 21, 10:12, 3 Years ago
Sun, May 9, 21, 20:55, 3 Years ago
Mon, Jan 16, 23, 23:19, 1 Year ago
Mon, Aug 29, 22, 05:43, 2 Years ago
;