Friday, January 23, 2015

Use Thunar custom actions to extract audio from video (without transcoding)

sudo apt-get install libav-tools
sudo apt-get install parallel  
Add the following command to Thunar custom actions:

xfce4-terminal -e "parallel avconv -i '{}' -map 0:1 -c:a copy '{}.m4a' ::: %F"
and the following conditions: *.mp4; *.flv,  video files.
That will extract to m4a container the acc audio from mp4 and flv selected files.
Or, also using `avconv`, but without the need to install `parallel`,   make an executable script, like

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

Make it executable and save it.
In Thunar custom actions add a new entry with the command  

bash /path/to/the/script %F

and the following conditions: *.mp4, video files.

This needs separate custom actions for each file type (because it is limited to mp4 to m4a: make changes accordingly for flv to m4a, webm to ogg, avi to mp3 etc) but has the advantage that the output keeps the exact input name (file.mp4 becomes file.m4a), while with the first command does not (file.mp4 becomes file.mp4.m4a).

No comments:

Post a Comment