// }
@Transactional(propagation=Propagation.REQUIRED)
private void update() {
try {
final FileDomain fd = this.fsDao.getFile(this.fileId);
final String filtered_text = this.out.toString().replace('\r', '\n');
final String[] lines = filtered_text.split("\n");
final Map<String,String> parsedValues = new HashMap<String,String>();
/**
ID_VIDEO_ID=0
ID_AUDIO_ID=1
ID_CLIP_INFO_NAME0=Software
ID_CLIP_INFO_VALUE0=VirtualDubMod 1.5.10.2 (build 2540/release)
ID_CLIP_INFO_N=1
ID_FILENAME=
ID_DEMUXER=avi
ID_VIDEO_FORMAT=XVID
ID_VIDEO_BITRATE=930680
ID_VIDEO_WIDTH=640
ID_VIDEO_HEIGHT=272
ID_VIDEO_FPS=23.976
ID_VIDEO_ASPECT=0.0000
ID_LENGTH=5502.62
ID_SEEKABLE=1
ID_CHAPTERS=0
ID_VIDEO_CODEC=ffodivx
ID_VIDEO_ASPECT=2.3529
ID_AUDIO_CODEC=ffmp3
ID_DEMUXER=audio
ID_AUDIO_FORMAT=85
ID_AUDIO_BITRATE=192000
ID_AUDIO_RATE=44100
ID_AUDIO_NCH=0
ID_LENGTH=80.00
ID_SEEKABLE=1
ID_CHAPTERS=0
ID_CLIP_INFO_NAME0=Title
ID_CLIP_INFO_VALUE0=b-vert�re
ID_CLIP_INFO_NAME1=Artist
ID_CLIP_INFO_VALUE1=Bela B.
ID_CLIP_INFO_NAME2=Album
ID_CLIP_INFO_VALUE2=Bingo
ID_CLIP_INFO_NAME3=Year
ID_CLIP_INFO_VALUE3=2006
ID_CLIP_INFO_NAME4=Comment
ID_CLIP_INFO_VALUE4=-] MST [-
ID_CLIP_INFO_NAME5=Track
ID_CLIP_INFO_VALUE5=1
ID_CLIP_INFO_NAME6=Genre
ID_CLIP_INFO_VALUE6=Punk Rock
ID_CLIP_INFO_N=7
* */
for (final String line : lines) {
if (line.startsWith("ID")) {
final String[] split = line.split("=");
if (split.length ==2) {
parsedValues.put(split[0].substring(3).toLowerCase(), split[1]);
}
}
}
// optimize
final String infoNr = parsedValues.remove("clip_info_n");
if (infoNr != null) {
final int idx = Integer.parseInt(infoNr);
for (int i = 0; i < idx; ++i) {
final String name = parsedValues.remove("clip_info_name" + i);
final String value = parsedValues.remove("clip_info_value" + i);
parsedValues.put(name.toLowerCase(), value);
}
}
// duration="01:56:36.780" resolution="620x256" bitrate="107520" nrAudioChannels="2" sampleFrequency="48000"
final DidlDomain dd = fd.getDidl();
// if (dd.getUrl().toLowerCase().endsWith("mp3")) {
// System.out.println("mp3");
// }
dd.setAlbum(parsedValues.get("album"));
dd.setBitrate(getBitrate(parsedValues.get("video_bitrate"), parsedValues.get("audio_bitrate")));
dd.setArtist(parsedValues.get("artist"));
dd.setAudioCodec(parsedValues.get("audio_codec"));
dd.setTrack(getInteger(parsedValues.get("track")));
dd.setVideoCodec(parsedValues.get("video_codec"));
dd.setYear(getInteger(parsedValues.get("year")));
// String title = parsedValues.get("title");
// if (title != null) {
// dd.setTitle(title);
// }
// dd.setBitsPerSample(bitsPerSample);
// dd.setColorDepth(colorDepth);
dd.setDuration(getDuration(parsedValues.get("length")));
dd.setGenre(parsedValues.get("genre"));
// dd.setLanguage(language);
dd.setNrAudioChannels(getInteger(parsedValues.get("audio_nch")));
dd.setResolution(getResoulution(parsedValues.get("video_width"), parsedValues.get("video_height")));
dd.setSampleFrequency(getInteger(parsedValues.get("audio_rate")));
// if (preview != null && preview.exists()) {
// service.
// }
// dd.setThumbnail(thumbnail)
final boolean notReadable = filtered_text.toLowerCase().contains("file not found") || filtered_text.toLowerCase().contains("failed to open");
dd.setPassedMPlayer(! notReadable);
dd.increaseUpdateId();
logger.info("update meta-infos [" + fd.getId() + "]");
this.fsDao.store(fd);
} finally {
try {
this.err.close();
this.out.close();