Page 1 of 1

Transcoding HD .wtv files

PostPosted: Sun Nov 03, 2013 9:37 am
by Xenu
I have been able to set up that WTV files play on my device with this entry:

  Code:
      <Transcoding>
         <Video targetContainer="mpegts" targetACodec="ac3" forceVTranscoding="true">
            <Matches container="wtv"/>
         </Video>
      </Transcoding>


This works nicely for SD files, but not for HD files. There is stuttering. I am on a fixed line (not wifi) but my PC is already a few years old. I am wondering if I should transcode the files in advance. I tried to look at what serviio/ffmpeg has done with the file:

ffmpeg -i wtv hd file: (size 5GB)

Duration: 00:49:57.80, start: 2.548022, bitrate: 13863 kb/s
Stream #0:0[0x4f](deu): Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 256 kb/s
Stream #0:1[0x50]: Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 10000k tbn, 100 tbc
Stream #0:2[0x51](deu): Subtitle: dvb_teletext
Stream #0:3[0x52](mul): Audio: mp2 (P[0][0][0] / 0x0050), 48000 Hz, stereo, s16p, 256 kb/s
Stream #0:4[0x0]: Video: mjpeg, yuvj420p, 200x113 [SAR 96:96 DAR 200:113], 90k tbr, 90k tbn, 90k tbc


ffmpeg -i .stf file from serviio: (15 GB ?!)

Duration: 00:49:58.76, start: 1.400000, bitrate: 39953 kb/s
Program 1
Metadata:
service_name : PHOENIX HD
service_provider: PHOENIX HD
Stream #0:0[0x100]: Video: h264 (Constrained Baseline) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 50 fps, 50 tbr, 90k tbn, 100 tbc
Stream #0:1[0x101](deu): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, stereo, fltp, 192 kb/s

The command that ffmpeg has used (I set up debug):

ffmpeg.exe -threads auto -i XXXXX\HD.wtv -y -threads auto -c:v libx264 -profile:v baseline -level 3 -preset veryfast -crf 10 -r 50 -g 15 -bsf:v h264_mp4toannexb -flags -global_header -c:a ac3 -b:a 192k -ac 2 -map 0:1 -map 0:0 -sn -f mpegts XXXXXX\AppData\Local\Temp\Serviio\transcoding-temp-1592-9-ORIGINAL.stf

My questions:
1) why is the resulting file so huge?
2) what setting should I try so that it is less huge but in the same quality?
What I'd like to get is something that is about the size as the original file, but in a format that Sam Sung, or Teufel (user agent: "IPI/1.0 UPnP/1.0 DLNADOC/1.50") can handle.
Direct transcoding-while-streaming into such a format would be nice, but I'd already be happy with some offline conversion parameters. Most of my recordings are not watched immediately, but in a few days.
3) What does the extension ".stf" stand for?

Re: Transcoding HD .wtv files

PostPosted: Mon Nov 04, 2013 12:04 am
by atc98092
For the .STF file format, I'll take a wild guess but it's probably "Serviio Transcoded File" :)

I have both SD and HD WTV files that play perfectly on all my devices. My network is wired gigabit, and my server has four cores and 8 gig of ram.

What are you play them on (what's your viewing device)? TV? Blu Ray player? Media Player? They all potentially have different transcoding configurations.

Re: Transcoding HD .wtv files

PostPosted: Mon Nov 04, 2013 5:16 am
by Xenu
atc98092 wrote:For the .STF file format, I'll take a wild guess but it's probably "Serviio Transcoded File" :)

I have both SD and HD WTV files that play perfectly on all my devices. My network is wired gigabit, and my server has four cores and 8 gig of ram.

What are you play them on (what's your viewing device)? TV? Blu Ray player? Media Player? They all potentially have different transcoding configurations.


My devices are a Samsung F series TV and a Teufel blu ray player (user agent: "IPI/1.0 UPnP/1.0 DLNADOC/1.50"). My network is also wired gigabit, and my server has four cores and 8 gig of ram. But my question is more about converting the HD file to a format that has about the same size and that I could then play immediately i.e. without transcoding. Both of my devices can play ".mp4" files immediately.

Re: Transcoding HD .wtv files

PostPosted: Mon Nov 04, 2013 12:49 pm
by zip
that's a question for the ffmpeg mailing list. But you could use -f mov (instead of mpegts) and name your file with .mov extension (or .mp4). The other parameters look fine.

Re: Transcoding HD .wtv files

PostPosted: Tue Nov 05, 2013 1:59 am
by atc98092
Xenu wrote:
atc98092 wrote:For the .STF file format, I'll take a wild guess but it's probably "Serviio Transcoded File" :)

I have both SD and HD WTV files that play perfectly on all my devices. My network is wired gigabit, and my server has four cores and 8 gig of ram.

What are you play them on (what's your viewing device)? TV? Blu Ray player? Media Player? They all potentially have different transcoding configurations.


My devices are a Samsung F series TV and a Teufel blu ray player (user agent: "IPI/1.0 UPnP/1.0 DLNADOC/1.50"). My network is also wired gigabit, and my server has four cores and 8 gig of ram. But my question is more about converting the HD file to a format that has about the same size and that I could then play immediately i.e. without transcoding. Both of my devices can play ".mp4" files immediately.


OK, I see no hardware issues there. I know that .wtv files are transcoded for all my devices, but I honestly don't see a noticable delay starting one. I just tried three different videos using my BDP-S3100: a DVD ripped to MKV (plays natively), an SD and an HD .wtv file. The .wtv files are transcoded to M2TS, and actually start playing faster than the native MKV file. Any of them begin playback within 6-10 seconds. My Panasonic TV takes a little longer, but then it's older. And none of them stutter. I'm perplexed. :?

Re: Transcoding HD .wtv files

PostPosted: Tue Nov 05, 2013 9:22 pm
by Xenu
But why is the converted file much bigger, although it is also h264, but in a different container? I tried to watch the converted file on the Teufel device (btw the .mov file is also much bigger than the wtv file) and do also get stuttering. So this suggests that it is too much for the network, sadly. Or are there two different h264 formats, one for WTV files and one for transcoding for DLNA?

Re: Transcoding HD .wtv files

PostPosted: Wed Nov 06, 2013 12:23 am
by atc98092
Xenu wrote:But why is the converted file much bigger, although it is also h264, but in a different container? I tried to watch the converted file on the Teufel device (btw the .mov file is also much bigger than the wtv file) and do also get stuttering. So this suggests that it is too much for the network, sadly. Or are there two different h264 formats, one for WTV files and one for transcoding for DLNA?


We are now out of my league. Transcoding is something I still haven't learned much about. I've been fortunate that it just works for my devices. I'll have to leave further troubleshooting to Zip and others.

Re: Transcoding HD .wtv files

PostPosted: Wed Nov 06, 2013 12:55 am
by DenyAll
The ffmpeg command being invoked by Serviio appears to be transcoding the video (the bit that reads -c:v libx264 -profile:v baseline -level 3). This will be the cause of the file size increase.

Not sure why this is happening though. Given your profile, I would have thought it should simply remux the video stream. Maybe remuxing isn't viable in this case and Serviio is recognising that and invoking a re-encode - zip again I'm afraid ;) . While awaiting his response you could see if remuxing works for this file - ffmpeg -i sourcefile.wtv -map 0 -c:v copy -c:a ac3 -b:a 192k -f mpegts destfile.mpeg substituting file names and ffmpeg location as appropriate.

Re: Transcoding HD .wtv files

PostPosted: Wed Nov 06, 2013 6:30 am
by Xenu
DenyAll wrote:The ffmpeg command being invoked by Serviio appears to be transcoding the video (the bit that reads -c:v libx264 -profile:v baseline -level 3). This will be the cause of the file size increase.

Not sure why this is happening though. Given your profile, I would have thought it should simply remux the video stream. Maybe remuxing isn't viable in this case and Serviio is recognising that and invoking a re-encode - zip again I'm afraid ;) . While awaiting his response you could see if remuxing works for this file - ffmpeg -i sourcefile.wtv -map 0 -c:v copy -c:a ac3 -b:a 192k -f mpegts destfile.mpeg substituting file names and ffmpeg location as appropriate.


Thanks!!

The resulting file is slightly smaller, and I was able to watch it on both devices and without stuttering. (I had to make a slight change, replaced "-map 0" with "-map 0:1 -map 0:0" because of the error msg "Encoder (codec none) not found for output stream #0:2", but then it worked quickly.

So thanks again, I do now have a solution for converting HD files, even if my next question isn't answered (I think its similar to what you wrote):

Is there a serviio transcoding setting (xml) that would make this on the fly and result in a similar ffmpeg command?

Re: Transcoding HD .wtv files

PostPosted: Wed Nov 06, 2013 12:09 pm
by DenyAll
You know sometimes you look at things multiple times and still not see it..... the transcoding profile you included in the OP includes the command forceVTranscoding="true". Not sure why you included this but this is what is triggering re-encoding rather than simply remuxing the video. If you remove it I'm pretty sure you'll be right.

ps. you may also want to set an audio bitrate to give you better audio (default is 192k from memory):
eg. use <Video targetContainer="mpegts" targetACodec="ac3" aBitrate="384"> to remux your video and transcode your audio to AC-3 with a 384k bit rate.

Re: Transcoding HD .wtv files

PostPosted: Wed Nov 06, 2013 4:52 pm
by Xenu
DenyAll wrote:You know sometimes you look at things multiple times and still not see it..... the transcoding profile you included in the OP includes the command forceVTranscoding="true". Not sure why you included this but this is what is triggering re-encoding rather than simply remuxing the video. If you remove it I'm pretty sure you'll be right.

ps. you may also want to set an audio bitrate to give you better audio (default is 192k from memory):
eg. use <Video targetContainer="mpegts" targetACodec="ac3" aBitrate="384"> to remux your video and transcode your audio to AC-3 with a 384k bit rate.


I got the forceVTranscoding="true" from here (note also who responded :-) ):
viewtopic.php?p=15300#p15300

I will test your suggestions later this week, thanks.

Re: Transcoding HD .wtv files

PostPosted: Wed Nov 06, 2013 9:40 pm
by DenyAll
That post seemed to be dealing with a limitation at the time in ffmpeg, which is now resolved. If I read it correctly, it was also re-encoding the video stream only where the source had a mpeg2 video stream (the matches command included the specific video type), and not h264 as yours does.

It was correct at the time to overcome an issue with transcoding WTV files with an mpeg2 video stream..... not so much now and not really applicable to your case.

Re: Transcoding HD .wtv files

PostPosted: Sun Nov 10, 2013 2:12 pm
by Xenu
Xenu wrote:I will test your suggestions later this week, thanks.


Seems to work nicely, thanks. Although the Teufel device is much more capable than the Samsung TV.

Re: Transcoding HD .wtv files

PostPosted: Mon Nov 11, 2013 5:26 am
by Randy12
Hi!
I would really like to know what YOU consider the best Transcoding HD. wtv filesl. Please let me know what you think. I will test suggest it is nice. thanksĀ