FAQ  •  Register  •  Login

HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

<<

bkeith4web

Streaming enthusiast

Posts: 32

Joined: Sat Feb 02, 2013 11:48 pm

Post Wed Dec 22, 2021 12:40 am

HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

Resolved: poorly configured user-profiles.xml was allowing unsupported video codec (h265) to be passed to a DLNA client by only transcoding the unsupported audio (eac3) before any video codec compatibility checks. Proper configuration was to place the audio-only transcode statement as the last check to be made so that the h265 video codec would trigger a full audio/video transcode while allowing supported video codecs such as h264 to fall through the profile until hitting the eac3 audio check.
Thanks to Dan for guidance and advice.
---------------

This is a weird one (aren't they all). I have a pretty current Windows 10 PC which can play the source video with VLC, MPC etc. My DNLA client (a Sony BDP S5100 Blu-ray) is older and does not support HEVC natively, so I have to transcode for HEVC.
The audio stream is e-ac3, container is matroska and with that combo I normally transcode even with the older H264 "AVC" codec.
Transcoding "seems" to run fine, I'll post a bit of the debug log below but the Sony reports that the stream is corrupt and won't play it. I'm pretty sure the audio stream is not the problem because I have another version of the source video with H264/AVC and e-ac3 audio and matroska and with transcoding running, it works just fine.
I'm using the bdp2013 profile plus an extension in user_profiles.xml to force transcoding for the matroska/eac3 combo along with setting a target output (mpegts, ac3 bitrate 320, maxwidth 1920, maxheight 1080) that the Sony and the Panasonic TV hooked to it have always been happy with.

So my mystery is, the transcoding log looks the same for AVC and HEVC, but AVC will play and HEVC won't. They both have the same target output, so what's going on? Could it be something else like the weird display aspect ratio below? Here's a couple factoids:
ffmpeg-i on the HEVC shows this (along with other stuff):
Stream #0:0: Video: hevc (Main 10), yuv420p10le(tv), 1920x1038, SAR 1:1 DAR 320:173, 23.98 fps, 23.98 tbr, 1k tbn, 23.98 tbc (default)
ffmpeg-i on the AVC version shows this:
Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
both HEVC and AVC show this for the audio stream:
Stream #0:1(eng): Audio: eac3, 48000 Hz, 5.1(side), fltp, 256 kb/s (default)

Both files in the log when they start delivering the file say this:
...using transcoding (profile: custombdps5100 > quality: ORIGINAL > Transcoding > [MPEG2TS/AC3] > matcher: 1)

So that seems to be saying that they both should be transcoded the same way. I'm puzzled on what to try with this. I'm on the latest Serviio and ffmpeg is version 3.4.4. Thanks for any suggestions!
Last edited by bkeith4web on Thu Dec 23, 2021 12:04 am, edited 2 times in total.
<<

atc98092

User avatar

DLNA master

Posts: 5213

Joined: Fri Aug 17, 2012 10:22 pm

Location: Washington (the state)

Post Wed Dec 22, 2021 2:11 am

Re: HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

You shouldn't need to transcode AVC/H.264, so if you have a matches line for that I'd remove it. I can understand needing to transcode the EAC-3, as that BD player probably doesn't support it. But transcoding audio only doesn't take much effort by the computer.

I'd like to see the user profile you've created to see what it's trying to do.
Dan

LG NANO85 4K TV, Samsung JU7100 4K TV, Sony BDP-S3500, Sharp 4K Roku TV, Insignia Roku TV, Roku Ultra, Premiere and Stick, Nvidia Shield, Yamaha RX-V583 AVR.
Primary server: Intel i5-6400, 16 gig ram, Windows 10 Pro, 22 TB hard drive space | Test server Windows 10 Pro, AMD Phenom II X4 965, 8 gig ram

HOWTO: Enable debug logging HOWTO: Identify media file contents
<<

bkeith4web

Streaming enthusiast

Posts: 32

Joined: Sat Feb 02, 2013 11:48 pm

Post Wed Dec 22, 2021 3:33 am

Re: HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

Thanks for checking in on this, I really appreciate it.
Below is the user-profiles.xml Re: only needing to transcode the eac3 audio and passing through the h264 video (edited this bit because I forgot that I looked into this a few years ago) that "should" be what I'm doing "if" I understand correctly which is a big "if" by specifying the mpegts container but not a video target codec. I see where the stock bdp2013 transcodes several h264 profiles.

Second edit - duh, if I'm only transcoding the audio then I'm not transcoding the video and it's trying to send hevc h265 in a mpeg-ts container to my older than dirt Sony and poof, unsupported stream. Did I already say "duh"?

Originally this user-profiles it didn't have the DAR, maxVBitrate or forceStereo in there; I added them just to try and set more parameters that the Sony handles but they didn't make a difference.

<?xml version="1.0" encoding="UTF-8"?>
<Profiles version="1.0">
<Profile id="custombdps5100" name="custom Sony BDP S5100" extendsProfileId="bdp2013">
<Transcoding>
<Video targetContainer="mpegts" targetACodec="ac3" aBitrate="320" forceInheritance="true" maxVBitrate="8192" forceStereo="true" DAR="16:9" maxWidth="1920" maxHeight="1080">
<!-- custom - add eac3 codec lines to force transcode -->
<Matches container="*" aCodec="eac3" />
</Video>
</Transcoding>
</Profile>
<<

bkeith4web

Streaming enthusiast

Posts: 32

Joined: Sat Feb 02, 2013 11:48 pm

Post Wed Dec 22, 2021 4:05 am

Re: HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

Followup question now that I understand that I caused my own problem.

I tried putting in a 'matches' line with vCodec=HEVC and that caused Serviio to fail to start because HEVC isn't in the enumeration list (of video codecs presumably). This is if I recall correctly.
So should I use vCodec=H265 even though ffmpeg -i reports it as HEVC?

Because it seems that I need to add another transcoding section to trigger full video/audio transcode for h265/eac3 but I still want my audio-only section for h264/eac3. Both were in matroska containers so I have to match on video codec.
Thanks for your help!
Brian
<<

atc98092

User avatar

DLNA master

Posts: 5213

Joined: Fri Aug 17, 2012 10:22 pm

Location: Washington (the state)

Post Wed Dec 22, 2021 4:13 am

Re: HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

OK, I don't think that profile will work right. You don't have a target video codec, but you're specifying a video bitrate. Can't do that without transcoding the video. I think the first line needs to be

<Video targetContainer="mpegts" targetVcodec="h264" targetACodec="ac3" aBitrate="320" forceInheritance="true" maxVBitrate="8192" forceStereo="true" DAR="16:9" maxWidth="1920" maxHeight="1080">

And then for matching you need:

<Matches container="*" vCodec="h265" />

That takes care of your HEVC videos. It will transcode any audio codec, supported or not, but that simplifies your profile. Although I honestly don't think you need the max video bitrate. Your BD player should certainly support a higher bitrate than that. The much older Roku players had a limit of around 12000, and starting around 2016 their players don't need a bitrate restriction at all. Looking at the 2013 Sony BD player profile, it has a limit of 17000, but again I doubt it needs it. I doubt you need to force stereo either, as virtually any reasonably modern device will accept 5.1 AC3 and output it regardless of the number of speakers it actually has.

So, I suggest a second transcoding section for your H.264 video with unsupported audio. It would go below your previous one, as Serviio uses the first matching statement, and you want any HEVC files video transcoded. It would look like this:

  Code:
<Video targetContainer="mpegts" targetACodec="ac3" aBitrate="320" forceInheritance="true">
        <Matches container="*" aCodec="eac3" />
</Video>

I see no need for any of the video statements, so the max width and height shouldn't be an issue. If you actually have any H.264 videos with horizontal or vertical sizes larger than 1920x1080, you'd need to do video transcoding anyway.
Dan

LG NANO85 4K TV, Samsung JU7100 4K TV, Sony BDP-S3500, Sharp 4K Roku TV, Insignia Roku TV, Roku Ultra, Premiere and Stick, Nvidia Shield, Yamaha RX-V583 AVR.
Primary server: Intel i5-6400, 16 gig ram, Windows 10 Pro, 22 TB hard drive space | Test server Windows 10 Pro, AMD Phenom II X4 965, 8 gig ram

HOWTO: Enable debug logging HOWTO: Identify media file contents
<<

bkeith4web

Streaming enthusiast

Posts: 32

Joined: Sat Feb 02, 2013 11:48 pm

Post Wed Dec 22, 2021 1:31 pm

Re: HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

Thanks very much for the suggestions, I'll give that a try when I get a chance and post the result to close out the thread.

Editing this response multiple times as I'm looking hard at the bdp2013 profile...it looks like the stock bdp2013 would actually work in this situation i.e. full a/v transcode triggered by video codec h265 and down in the audiotrackremux section, remuxing audio always for h264 video codec. That would work in this case where I had a h264 (level 3.1)/eac3 combination, it would do the minimum work of remuxing the audio. It might be remuxing audio when it doesn't need to, like if the video is h264(3.1)/mp3 but not a big deal as far as computer workload. Do I have that right?

However, if a different video codec came along with eac3 audio that DIDN'T match the list under bdp2013 audiotrackremux, then it doesn't trigger the remux and my Sony chokes on it. So it seems the simplest solution is to add one line to the bdp2013 profile under audiotrack remux, <Matches container="*" aCodec="eac3" /> But, I can't put that in user-profiles.xml because it would match, remux, stop looking for other matches and pass along the unsupported video codec.

So, if I'm understanding correctly, my options are to either edit profiles.xml or recreate the whole profiles config for the bdp2013 within user-profiles and add this one line under AudioTrackRemux. In either case, after an upgrade, I'd have to re-do it which is not a big deal but annoying.

Re: the video bitrate, I originally put in a video bitrate limit years ago when I was doing full transcoding and getting some stuttering over my wireless network (the one I have now is a lot better, no need for a limit) so that was my bottleneck at the time.

When I switched to audio-only transoding, I didn't have video bitrate, DAR or forcestereo in my user-profiles, I just threw those on last night from an old version of user-profiles while I was doing some testing trying to figure out why the stream was "corrupt" and hadn't yet remembered that it was audio-transcoding only.
Brian
<<

atc98092

User avatar

DLNA master

Posts: 5213

Joined: Fri Aug 17, 2012 10:22 pm

Location: Washington (the state)

Post Wed Dec 22, 2021 5:22 pm

Re: HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

In either case, after an upgrade, I'd have to re-do it which is not a big deal but annoying.


Not correct. If you edit the Profiles.xml file, yes it is overwritten at the next update. But the user profile file is never altered, so anything you put there remains intact.

I'll look more closely at the rest of your post in a bit. The wife is calling. :P
Dan

LG NANO85 4K TV, Samsung JU7100 4K TV, Sony BDP-S3500, Sharp 4K Roku TV, Insignia Roku TV, Roku Ultra, Premiere and Stick, Nvidia Shield, Yamaha RX-V583 AVR.
Primary server: Intel i5-6400, 16 gig ram, Windows 10 Pro, 22 TB hard drive space | Test server Windows 10 Pro, AMD Phenom II X4 965, 8 gig ram

HOWTO: Enable debug logging HOWTO: Identify media file contents
<<

bkeith4web

Streaming enthusiast

Posts: 32

Joined: Sat Feb 02, 2013 11:48 pm

Post Wed Dec 22, 2021 6:22 pm

Re: HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

Sorry I wasn't clear, my comment about needing to re-do the user-profiles.xml after an upgrade was assuming that I copied the entirety of the bdp2013 profile in to user-profiles and then added the "last resort eac3 audio transcode" at the very end. That way my eac3 transcode is always the last match to be checked, which is what I want since all the earlier matches on unsupported video/audio codecs should happen first to trigger a full transcode if needed.

Therefore I'd need to re-copy the upgraded bdp2013 profile as a starting point after every upgrade and re-add my eac3 transcode. If all that my user-orofiles contains is that eac3 transcode, then it jumps in front of the h265 video codec check and my Sony can't handle h265. Same thing would happen with any other unsupported video codec, I just happen to be fooling with h264/265 right now.

If there was a way to say "check the user-profiles.xml AFTER the profiles.xml" then I'd be OK and could just put the eac3 audio transcode into user-profiles.

I did some testing and putting the eac3 transcode in as the very last transcoding check in profiles.xml worked great, the h265/eac3 gets a full transcode from higher up in the config and the h264 Level 3-or-4/eac3 passes through the earlier checks and gets just an audio transcode as desired.

Now my only problem is that the newer Sony S6700 that I bought is less capable than the old S5100, so it's even more finicky about codecs over DLNA and I can't get it to handle an online stream that the S5100 takes with no problem. That's contrary to the user guide but that's a Sony DLNA problem, not a Serviio problem. Sigh. And not that it matters but I went ahead and bought a pro license, I should have done it years ago but better late than never, I've gotten a lot of use out of Serviio and you guys have always offered good support even to us freeloading users.
<<

atc98092

User avatar

DLNA master

Posts: 5213

Joined: Fri Aug 17, 2012 10:22 pm

Location: Washington (the state)

Post Wed Dec 22, 2021 7:22 pm

Re: HEVC Transcode to MPEG2TS/AC3 works but corrupt stream

In that case, the simplest way to keep everything organized is to copy the entire existing profile into your user profile and then make your necessary changes. Just copy the entire 2013 profile, give it a different name, and away you go!
Dan

LG NANO85 4K TV, Samsung JU7100 4K TV, Sony BDP-S3500, Sharp 4K Roku TV, Insignia Roku TV, Roku Ultra, Premiere and Stick, Nvidia Shield, Yamaha RX-V583 AVR.
Primary server: Intel i5-6400, 16 gig ram, Windows 10 Pro, 22 TB hard drive space | Test server Windows 10 Pro, AMD Phenom II X4 965, 8 gig ram

HOWTO: Enable debug logging HOWTO: Identify media file contents

Return to Transcoding

Who is online

Users browsing this forum: No registered users and 13 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.