Created new transcoding for mp4 and use it for videos

Signed-off-by: Andrew DeMaria <lostonamountain@gmail.com>
master
Andrew DeMaria 8 years ago
parent b1e019f574
commit 453e948213
No known key found for this signature in database
GPG Key ID: 0A3F5E91F8364EDF
  1. 2
      libresonic-main/src/main/java/org/libresonic/player/controller/VideoPlayerController.java
  2. 17
      libresonic-main/src/main/java/org/libresonic/player/service/TranscodingService.java
  3. 6
      libresonic-main/src/main/resources/liquibase/6.3/changelog.xml
  4. 18
      libresonic-main/src/main/resources/liquibase/6.3/mediaelement.xml
  5. 1
      libresonic-main/src/main/resources/liquibase/db-changelog.xml
  6. 76
      libresonic-main/src/main/resources/liquibase/legacy/schema43.xml
  7. 6
      libresonic-main/src/main/resources/liquibase/legacy/schema46.xml

@ -68,7 +68,7 @@ public class VideoPlayerController {
Integer duration = file.getDurationSeconds(); Integer duration = file.getDurationSeconds();
String playerId = playerService.getPlayer(request, response).getId(); String playerId = playerService.getPlayer(request, response).getId();
String url = NetworkService.getBaseUrl(request); String url = NetworkService.getBaseUrl(request);
String streamUrl = url + "/stream?id=" + file.getId() + "&player=" + playerId; String streamUrl = url + "/stream?id=" + file.getId() + "&player=" + playerId + "&format=mp4";
String coverArtUrl = url + "/coverArt.view?id=" + file.getId(); String coverArtUrl = url + "/coverArt.view?id=" + file.getId();
map.put("video", file); map.put("video", file);

@ -22,7 +22,7 @@ package org.libresonic.player.service;
import org.apache.commons.io.FileUtils; import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils; import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.filefilter.PrefixFileFilter; import org.apache.commons.io.filefilter.PrefixFileFilter;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.libresonic.player.controller.VideoPlayerController; import org.libresonic.player.controller.VideoPlayerController;
import org.libresonic.player.dao.TranscodingDao; import org.libresonic.player.dao.TranscodingDao;
import org.libresonic.player.domain.*; import org.libresonic.player.domain.*;
@ -393,7 +393,20 @@ public class TranscodingService {
List<Transcoding> applicableTranscodings = new LinkedList<Transcoding>(); List<Transcoding> applicableTranscodings = new LinkedList<Transcoding>();
String suffix = mediaFile.getFormat(); String suffix = mediaFile.getFormat();
for (Transcoding transcoding : getTranscodingsForPlayer(player)) { // This is what I'd like todo, but this will most likely break video transcoding as video transcoding is
// never expected to be null
// if(StringUtils.equalsIgnoreCase(preferredTargetFormat, suffix)) {
// LOG.debug("Target formats are the same, returning no transcoding");
// return null;
// }
List<Transcoding> transcodingsForPlayer = getTranscodingsForPlayer(player);
for (Transcoding transcoding : transcodingsForPlayer) {
// special case for now as video must have a transcoding
if(mediaFile.isVideo() && StringUtils.equalsIgnoreCase(preferredTargetFormat, transcoding.getTargetFormat())) {
LOG.debug("Detected source to target format match for video");
return transcoding;
}
for (String sourceFormat : transcoding.getSourceFormatsAsArray()) { for (String sourceFormat : transcoding.getSourceFormatsAsArray()) {
if (sourceFormat.equalsIgnoreCase(suffix)) { if (sourceFormat.equalsIgnoreCase(suffix)) {
if (isTranscodingInstalled(transcoding)) { if (isTranscodingInstalled(transcoding)) {

@ -0,0 +1,6 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<include file="mediaelement.xml" relativeToChangelogFile="true"/>
</databaseChangeLog>

@ -0,0 +1,18 @@
<databaseChangeLog
xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">
<changeSet id="mediaelement_001" author="muff1nman">
<insert tableName="transcoding2">
<column name="name" value="mp4/h264 video" />
<column name="source_formats" value="avi flv mpg mpeg m4v mkv mov wmv ogv divx m2ts" />
<column name="target_format" value="mp4" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -"/>
</insert>
<rollback>
<delete tableName="transcoding2" >
<where>name = 'mp4/h264 video'</where>
</delete>
</rollback>
</changeSet>
</databaseChangeLog>

@ -9,4 +9,5 @@
<property name="varchar_type" value="varchar" /> <property name="varchar_type" value="varchar" />
<include file="legacy/legacy-changelog.xml" relativeToChangelogFile="true"/> <include file="legacy/legacy-changelog.xml" relativeToChangelogFile="true"/>
<include file="6.2/changelog.xml" relativeToChangelogFile="true"/> <include file="6.2/changelog.xml" relativeToChangelogFile="true"/>
<include file="6.3/changelog.xml" relativeToChangelogFile="true"/>
</databaseChangeLog> </databaseChangeLog>

@ -23,97 +23,97 @@
<column name="version" valueNumeric="17" /> <column name="version" valueNumeric="17" />
</insert> </insert>
<delete tableName="transcoding"> <delete tableName="transcoding">
<where>target_format = 'mp4' and source_format in ('avi', 'mpg', 'mpeg', 'mp4', 'm4v', 'mkv', 'mov', 'wmv', 'ogv')</where> <where>target_format = 'flv' and source_format in ('avi', 'mpg', 'mpeg', 'mp4', 'm4v', 'mkv', 'mov', 'wmv', 'ogv')</where>
</delete> </delete>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="avi > mp4"/> <column name="name" value="avi > flv"/>
<column name="source_format" value="avi" /> <column name="source_format" value="avi" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'avi > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'avi > flv'
</sql> </sql>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="mpg > mp4"/> <column name="name" value="mpg > flv"/>
<column name="source_format" value="mpg" /> <column name="source_format" value="mpg" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mpg > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mpg > flv'
</sql> </sql>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="mpeg > mp4"/> <column name="name" value="mpeg > flv"/>
<column name="source_format" value="mpeg" /> <column name="source_format" value="mpeg" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mpeg > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mpeg > flv'
</sql> </sql>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="flv > mp4"/> <column name="name" value="mp4 > flv"/>
<column name="source_format" value="flv" /> <column name="source_format" value="mp4" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'flv > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mp4 > flv'
</sql> </sql>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="m4v > mp4"/> <column name="name" value="m4v > flv"/>
<column name="source_format" value="m4v" /> <column name="source_format" value="m4v" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'm4v > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'm4v > flv'
</sql> </sql>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="mkv > mp4"/> <column name="name" value="mkv > flv"/>
<column name="source_format" value="mkv" /> <column name="source_format" value="mkv" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mkv > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mkv > flv'
</sql> </sql>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="mov > mp4"/> <column name="name" value="mov > flv"/>
<column name="source_format" value="mov" /> <column name="source_format" value="mov" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mov > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'mov > flv'
</sql> </sql>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="wmv > mp4"/> <column name="name" value="wmv > flv"/>
<column name="source_format" value="wmv" /> <column name="source_format" value="wmv" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'wmv > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'wmv > flv'
</sql> </sql>
<insert tableName="transcoding"> <insert tableName="transcoding">
<column name="name" value="ogv > mp4"/> <column name="name" value="ogv > flv"/>
<column name="source_format" value="ogv" /> <column name="source_format" value="ogv" />
<column name="target_format" value="mp4" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -" /> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -" />
<column name="enabled" valueBoolean="true" /> <column name="enabled" valueBoolean="true" />
</insert> </insert>
<sql> <sql>
insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'ogv > mp4' insert into player_transcoding(player_id, transcoding_id) select p.id as player_id, t.id as transaction_id from player p, transcoding t where t.name = 'ogv > flv'
</sql> </sql>
<rollback/> <rollback/>
</changeSet> </changeSet>

@ -47,10 +47,10 @@
<column name="step1" value="ffmpeg -i %s -ab %bk -v 0 -f mp3 -"/> <column name="step1" value="ffmpeg -i %s -ab %bk -v 0 -f mp3 -"/>
</insert> </insert>
<insert tableName="transcoding2"> <insert tableName="transcoding2">
<column name="name" value="mp4/h264 video" /> <column name="name" value="flv/h264 video" />
<column name="source_formats" value="avi flv mpg mpeg m4v mkv mov wmv ogv divx m2ts" /> <column name="source_formats" value="avi mpg mpeg mp4 m4v mkv mov wmv ogv divx m2ts" />
<column name="target_format" value="flv" /> <column name="target_format" value="flv" />
<column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f mp4 -vcodec libx264 -preset superfast -threads 0 -movflags frag_keyframe+empty_moov -"/> <column name="step1" value="ffmpeg -ss %o -i %s -async 1 -b %bk -s %wx%h -ar 44100 -ac 2 -v 0 -f flv -vcodec libx264 -preset superfast -threads 0 -"/>
</insert> </insert>
<rollback> <rollback>
<dropTable tableName="transcoding2" /> <dropTable tableName="transcoding2" />

Loading…
Cancel
Save