Page 1 of 1

DTS file support (in .dts and .wav files)

PostPosted: Thu May 31, 2012 12:43 pm
by jlcooke
I have a Samsung UN55ES6100 and some file.dts and file.wav (containing DTS data from a CD) I would like to play.

How can I modify profiles.xml to transcode this to LPCM ... or ideally play it as a DTS stream ... fallback being encoding as AC3 with a loss in fidelity due to transcoding to lossy format.

Re: DTS file support (in .dts and .wav files)

PostPosted: Thu May 31, 2012 4:01 pm
by zip
You could comment on this ticket and even add a sample or link to it

https://bitbucket.org/xnejp03/serviio/i ... e-lossless

Re: DTS file support (in .dts and .wav files)

PostPosted: Fri Jun 01, 2012 12:12 pm
by jlcooke
OK, so i've explored a bit and come to the conclusion that multi-channel audio is not possible with DLNA.

The closest one can do, is convert multichannel audio into a video stream with a basic video stream and the mch audio stream.

ZIP - Before I submit a feature request - could I ask what you think of this idea? I'll send you a link to a sample mch audio file converted to video in an PM.

From what I can tell - it would be a kludge to work this into Serviio:
1) If while Serviio is scanning an folder marked as an audio source directory it comes across:
a) FLAC with more than 2 channels,
b) a /.dts$/i file
c) a /.wav$/i file which ffmpeg says contains a DTS stream
d) a /.ac3$/i file
==> Then add an entry in the library under video where the data stream is produced using:
  Code:
ffmpeg -loop_input -i "$dir/folder.jpg" -b 10 -r 1 -i "$dir/$audiofile" $AUDIOCODEC $VIDEOCODEC -shortest $OUTPUT

Where:
- $dir is the dir containing the $audiofile
- If $dir/folder.jpg does not exists, use the Serviio Logo
- $AUDIOCODEC could be something like "-acodec ac3 -ab 640k" or "-acodec dca -ab 1509k -strict experimental" ... depending on the player profile
- $VIDEOCODEC could be something like "-vcodec libx264 -b 100k -r 1" or "-vcodec xvid -b 100k -r 1" ... depending on the player profile

Script to convert MultiChannel Audio into a MultiChannel video stream that works on my Samsung TV served up by Serviio
  Code:
#!/usr/bin/perl

use strict;

if ($#ARGV <= 3) {
   print "Usage: $0 <destdir> <container> <videoCodec> <audioCodec> <file_or_dir_1> [<file_or_dir_2> ...]\n";
   print "Usage: $0 . mp4 h264-100k dts-1509k \"../FLAC/Pink Floyd/The Dark Side Of The Moon [Original 4.0 Mix 1973] (BD-4.0-24b-48k)\"\n";
   exit;
}

my %AUDIOS;
$AUDIOS{'ac3-448k'} = "-acodec ac3 -ab 448k";
$AUDIOS{'ac3-640k'} = "-acodec ac3 -ab 640k";
$AUDIOS{'dts-1509k'} = "-acodec dca -ab 1509k -strict experimental";
$AUDIOS{'dts-1500k'} = "-acodec dca -ab 1500k -strict experimental";
$AUDIOS{'dts-1536k'} = "-acodec dca -ab 1536k -strict experimental";
my %VIDEOS;
$VIDEOS{'h264-100k'} = "-vcodec libx264 -b 100k -r 1";

my $DEST = $ARGV[0];
my $CONTAINER = $ARGV[1];
my $VCODEC = $ARGV[2];
my $ACODEC = $ARGV[3];

if ($VIDEOS{$VCODEC} eq '') {
   print "Error: Unsupported audioCodec '$VCODEC', valid options are:\n";
   foreach my $c (sort keys %VIDEOS) {
      print "\t$c\n";
   }
   exit;
}

if ($AUDIOS{$ACODEC} eq '') {
   print "Error: Unsupported audioCodec '$ACODEC', valid options are:\n";
   foreach my $c (sort keys %AUDIOS) {
      print "\t$c\n";
   }
   exit;
}

for (my $i=4; $i<=$#ARGV; $i++) {
   convertThis($ARGV[$i]);
}

exit;

sub convertThis {
   my ($path) = @_;


   if (-d $path) {
      opendir(DIR, $path);
      my @files = readdir(DIR);
      closedir(DIR);
      @files = sort(@files);
      shift @files;
      shift @files;

      foreach my $file (@files) {
         if (-d "$path/$file") {
            convertThis("$path/$file");
         }
         elsif ($file =~ /\.flac$/  and  $path =~ /\((LPCM|SACD|DVDA|BD|DTS|R2R|USB|UNK)/) {
            convertThis("$path/$file");
         }
      }
      return;
   }

   my $newdir = $path;
   $newdir =~ s/.*FLAC\//FLAC\//;
   my @t = split(/\//, $newdir);
   my $fname = pop @t;
   $newdir = $DEST ."/". join("/", @t);
   `mkdir -p "$newdir"`;

   $fname =~ s/\.(flac)$//;

   my $out1 = "$newdir/$fname.$CONTAINER";
print "$out1\n";
   my $cmd1 = "ffmpeg -loop_input -i 001.jpg -b 10 -r 1 -i \"$path\" $AUDIOS{$ACODEC} $VIDEOS{$VCODEC} -shortest \"$out1\" > /dev/null";
   if (!-f $out1) {
      print "$cmd1\n";
      system($cmd1);
#open(FILE, ">$out1"); close(FILE);
   }
}

Re: DTS file support (in .dts and .wav files)

PostPosted: Sat Jun 02, 2012 9:45 am
by zip
Multichannel audio should be possible, at least for some renderers (they have DTS/AAC profiles I think). I will see first if that can be developed and if not then I'd be looking at hacks. Hold on with the request.