Sunday, April 28, 2024
 Popular · Latest · Hot · Upcoming
2
rated 0 times [  2] [ 0]  / answers: 1 / hits: 2480  / 3 Years ago, fri, august 6, 2021, 5:00:04

I have written a little bash script to extract audio from video files in batch mode.



Sound is extracted from each mp4 file to flac format using avconv (and the flac codec).



#!/bin/sh
#
# Batch conversion of audio extraction from video

FOLDER_SRC="/home/Me/Music/TestBatchConv"

for myvid in $(find ${FOLDER_SRC} | grep mp4)
do
avconv -i $myvid -acodec flac "${myvid}.flac"
done

exit 0


It works fine, but I would like to improve it.



The script only detects mp4 format. Is it possible to recognize a video file with a command (instead of testing each video format) ?



Thank you for advices.


More From » bash

 Answers
4

You are looking for file



e.g.



 $ file -b 01--Frank_Sinatra--Close_to_You_And_More--Close_to_You.m4a 
Audio file with ID3 version 2.4.0, contains: ISO Media, MPEG v4 system, iTunes AAC-LC


It should cover all well-known media types.
If something is missing, you can add it yourself (see man magic).


[#32319] Saturday, August 7, 2021, 3 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
ularousand

Total Points: 380
Total Questions: 109
Total Answers: 101

Location: England
Member since Tue, Sep 8, 2020
4 Years ago
;