How to convert all my audios into mp4 at once
I'm using Qnap NAS and recently I came to want to play all the media in living room at home. What is the best appliance?
Actually, there is a long story.
Apple TV? No it plays media only in my iPhone. And Wi-fi at home isn't good when a microwave is working.
Chromecast? was not a good idea for similar reasons.
Purchase a new network media player? No. It doesn't play ALAC, in which most of my audio files are encoded. Ones play ALAC cost 1,000 - 2,000 dollars. And those expensive ones do not look playing videos.
Finally I chose Sony PlayStation 3, which I bought several years ago. And since it doesn't play ALAC/FLAC, I need to convert thousands of my files.
Is there good solution in Linux? I couldn't find it. 'SoundConverter' looked nice, but it didn't understand ALAC. And only writes MP3 not MP4 (PS3 plays both, but I liked the latter).
Anyway I wrote a command line below to perform conversion from my audios to mp4 format.
export destroot="/mnt/livius/Qmultimedia/PS3/Music" && \ export srcroot="/mnt/livius/Qmultimedia/iTunes/iTunes Media/Music" && \ find "$srcroot" \ -type f \ -exec \ sh -c '\ export fname="${1#/*Music/}" && \ export destdir="$destroot/$(dirname "${fname}")" && \ mkdir -p "$destdir" && \ /usr/bin/avconv -y -i \ "$srcroot/$fname" \ -vn -acodec libvo_aacenc -b:a 320k -ac 2 -ar 48000 -b:a 320k \ "$destroot/${fname%.*}.mp4" \ ' \ "Convert all my music into MP4" {} \;
Writing S-expression inside Java codes
I recently created a library that evaluates java.lang.Objects as S-expressions (my summer homework;)). In other words, you can embed a LISP program inside Java code, but unlike fun4j you don't need to write your LISP code as a String. You can write it as a real Java program. That is,
Basic.eval(
progn(
assign($("i"), 0),
loop(
lt($("i"), 10),
print(format("@@@@@@@@ %s @@@@@@@@\n", $("i"))),
assign($("i"), add($("i"), 1))
)
)
);
where progn, assign, loop, lt, print, and so on are names of Java methods that return evaluatable objects (java.lang.Object[]'s) and Basic.eval is a function that does the 'evaluate' on given java.lang.Object.
This program produces the output below
@@@@@@@@ 0 @@@@@@@@
@@@@@@@@ 1 @@@@@@@@
@@@@@@@@ 2 @@@@@@@@
@@@@@@@@ 3 @@@@@@@@
@@@@@@@@ 4 @@@@@@@@
@@@@@@@@ 5 @@@@@@@@
@@@@@@@@ 6 @@@@@@@@
@@@@@@@@ 7 @@@@@@@@
@@@@@@@@ 8 @@@@@@@@
@@@@@@@@ 9 @@@@@@@@
It's not yet published in Maven's Central Repository, but will become available soon.
The source code is found here: https://github.com/dakusui/petronia/