[Solved] Panasonic Viera profile w/ AVI/DivX/Xvid, 3GP, MOV

EDIT: the audio problem with 3GP files with AMR-NB audio should be fixed in 0.6.2
EDIT: added fix for MP4 files with mpeg4 codec
I got a new profile and hacks working for my Panasonic ST30 (specifically TC-P60ST30). These solutions may also work for you if you have a Panasonic GT30, S30, X30, etc.
They fix transcoding for Panasonics that have the following problems:
I'm running Serviio 0.6.1 on Windows 7 64-bit.
First, let's get all the AVIs transcoded and let's get the sound working for MOV and MP4 files with AAC audio. I modified the existing Panasonic Viera profile and created a new profile as follows:
Now, for me, this wasn't enough for AVIs with Xvid/DivX. The video and audio were out of sync, and we need a Step 2 for this transcoding solution. It took me a long time to figure this out, but I had to hack a wrapper for the ffmpeg transcoder, written in Perl, in order to change one argument "-r 25" to "-r 30000/1001" (i.e. 29.97 fps). I don't know why Serviio is invoking ffmpeg with an output framerate of 25 instead of 29.97 -- I'm a North American!
(bug?)
This Perl script also contains a hack for forcing ffmpeg to transcode the AMR-NB (AMR Narrowband) audio in 3GP files; for some reason, Serviio completely disables the audio for such files (another bug?).
Here are the steps to create and invoke this Perl script:
Now, restart your Serviio service (by running services.msc) and you should be good to go.
If someone could shine some light on why the hacks for video-audio syncing and 3GP w/ AMR-NB are needed for Serviio 6.1, that would be great. I'm hoping these are just Serviio bugs that will be fixed, thus deprecating this Perl script.
Now, I wonder if I can solve the subtitles problem. Right now, MKVs with embedded subtitles are not supported by Serviio, and SRT files served alongside MKVs are ignored by the Panasonic TV. Any tips?
EDIT: added fix for MP4 files with mpeg4 codec
I got a new profile and hacks working for my Panasonic ST30 (specifically TC-P60ST30). These solutions may also work for you if you have a Panasonic GT30, S30, X30, etc.
They fix transcoding for Panasonics that have the following problems:
- - this Panasonic doesn't natively handle AVI / DivX / Xvid
- when transcoding AVIs with Xvid/DivX, there are video-audio sync problems.
- this Panasonic doesn't natively handle MP4 files with mpeg4 video codec.
- there's no sound for MOV/MP4 files with AAC audio, despite the claims from the Panasonic manual that AAC is supported.
- there's no sound for 3GP files with AMR-NB audio.
I'm running Serviio 0.6.1 on Windows 7 64-bit.
First, let's get all the AVIs transcoded and let's get the sound working for MOV and MP4 files with AAC audio. I modified the existing Panasonic Viera profile and created a new profile as follows:
- Code:
<Profile id="112" name="Panasonic Viera w/ AVI, MOV, MP4, 3GP (by huyz)" extendsProfileId="1">
<ContentDirectoryMessageBuilder>org.serviio.upnp.service.contentdirectory.PacketVideoDLNAMessageBuilder</ContentDirectoryMessageBuilder>
<SubtitlesMimeType>text/srt</SubtitlesMimeType>
<Transcoding>
<!-- remux DTS/FLAC/LPCM in MKV/MP4 to AC3 -->
<Video targetContainer="mpegts" targetACodec="ac3">
<Matches container="matroska" vCodec="h264" aCodec="dca" />
<Matches container="matroska" vCodec="h264" aCodec="flac" />
<Matches container="matroska" vCodec="h264" aCodec="vorbis" />
<Matches container="matroska" vCodec="h264" aCodec="truehd" />
<Matches container="mp4" vCodec="h264" aCodec="lpcm"/>
<!-- huyz: ST30 manual says AAC should work (and it does for MKV) but transcoding is needed for our .mp4 (and the equivalent .mov) files -->
<Matches container="mp4" vCodec="h264" aCodec="aac"/>
<Matches container="3gp" vCodec="h264" />
</Video>
<!-- Remux all h264 video to MPEG-TS stream -->
<Video targetContainer="mpegts">
<Matches container="avi" vCodec="h264" />
<Matches container="mp4" vCodec="h264" />
<Matches container="matroska" vCodec="h264" />
<Matches container="matroska" vCodec="mpeg2video"/>
</Video>
<!-- unsupported codecs will be transcoded into mpeg-ts, mpeg2 video and ac3 audio -->
<Video targetContainer="mpegts" targetVCodec="mpeg2video" targetACodec="ac3">
<!-- huyz: do all AVIs, including mpeg4 (Xvid) and msmpeg4 video codecs
<Matches container="avi" vCodec="mjpeg" />
<Matches container="avi" vCodec="dvvideo" />
-->
<Matches container="avi"/>
<Matches container="mp4" vCodec="mjpeg" />
<Matches container="mp4" vCodec="mpeg4" /> <!-- huyz: this Panasonic doesn't support mpeg4 -->
<Matches container="asf" />
<Matches container="flv" />
<Matches container="ogg" />
<Matches container="3gp" />
</Video>
<Audio targetContainer="mp3">
<Matches container="mp4" />
<Matches container="flac" />
<Matches container="ogg" />
<Matches container="asf" />
<Matches container="adts" />
</Audio>
</Transcoding>
</Profile>
Now, for me, this wasn't enough for AVIs with Xvid/DivX. The video and audio were out of sync, and we need a Step 2 for this transcoding solution. It took me a long time to figure this out, but I had to hack a wrapper for the ffmpeg transcoder, written in Perl, in order to change one argument "-r 25" to "-r 30000/1001" (i.e. 29.97 fps). I don't know why Serviio is invoking ffmpeg with an output framerate of 25 instead of 29.97 -- I'm a North American!

This Perl script also contains a hack for forcing ffmpeg to transcode the AMR-NB (AMR Narrowband) audio in 3GP files; for some reason, Serviio completely disables the audio for such files (another bug?).
Here are the steps to create and invoke this Perl script:
- Install Perl
- As per http://www.serviio.org/component/content/article/21#q3, go into the C:\Program Files\Serviio\bin directory and edit ServiioService.exe.vmoptions. On a new line, add the following (change perl64 to perl if you're running a 32-bit version of Perl):
- In the C:\Program Files\Serviio directory, create a file called serviio-ffmpeg.pl (customized from viewtopic.php?f=7&t=4711) that says:
- Code:
#!perl
# See http://forum.serviio.org/viewtopic.php?f=7&t=4711
# and http://forum.serviio.org/viewtopic.php?f=11&t=2956&start=30
use strict;
my $args = '';
foreach my $arg (@ARGV) {
$args .= "\"$arg\" ";
}
# Don't know why the frame rate is wrong when transcoding AVIs
$args =~ s/"-r"\s+"25"\s/"-r" "30000\/1001" /g;
# This looks like a Serviio 0.6.1 bug for 3GP files; the aCodec is not recognized
if ($args =~ /"-i"\s+"[^"]+\.3GP"\s.*\s"-an"/i) {
$args =~ s/"-an"\s/"-acodec" "ac3" "-ar" "48000" "-map" "0:a" /ig;
}
my $cmd = "\"C:\\Program Files\\Serviio\\lib\\ffmpeg.exe\" $args";
open(LOGFILE, ">>C:\\Program Files\\Serviio\\ffmpeg-wrapper.log");
print LOGFILE scalar localtime . " Starting: " . $cmd . "\n";
if (system($cmd) != 0) {
print LOGFILE scalar localtime . " Failed: " . $cmd . " with $?\n";
close (LOGFILE);
die "Failed\n";
} else {
print LOGFILE scalar localtime . " Succeeded: " . $cmd . "\n";
close (LOGFILE);
}
Now, restart your Serviio service (by running services.msc) and you should be good to go.
If someone could shine some light on why the hacks for video-audio syncing and 3GP w/ AMR-NB are needed for Serviio 6.1, that would be great. I'm hoping these are just Serviio bugs that will be fixed, thus deprecating this Perl script.
Now, I wonder if I can solve the subtitles problem. Right now, MKVs with embedded subtitles are not supported by Serviio, and SRT files served alongside MKVs are ignored by the Panasonic TV. Any tips?