Friday, May 10, 2013

Extract audio from video file without change

The audio file contained should be the same format as the output. For flv and mp4 it is usually aac. But raw aac files can't contain metadata; to keep metadata from the original files better use m4a (which is just another name for mp4, but is fairly widely recognised by audio players) instead of aac as a file extension.


the general formula is:
 avconv -i "INPUT FILE" -map 0:1 -c:a copy "OUTPUT FILE" 
For all files of the same type in a folder:

for mp4:

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

For flv:

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

Avi videos usually contain mp3:

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


The disadvantage is that they cannot be added in Thunar custom actions as such. To add it, you should put it in a script, and run that from Thunar actions. A command that can be added as such and also works for all selected files (but should be limited to videos that contain `aac` files or to `aac` files as such) is:

gnome-terminal -e "parallel avconv -i '{}' -map 0:1 -c:a copy '{}.m4a' ::: %F"

To limit Thunar custom actions applications to `aac` and video containing this us Appearance conditions: make these settings (see here).

Replace accordingly for other input/output. 


bash -c 'avconv -i "$0" -map 0:1 -c:a copy "${0%%.*}".m4a' %f

To see audio of the input video, use exiftools, avprobe or MediaInfo. More here.

No comments:

Post a Comment