Jump to content

Transcode - Detect interlaced content and transcode properly


Recommended Posts

Posted (edited)

PAL 50hz 25fps or NTSC 59.94hz 29.97 fps content (interlaced content like TV Shows) should be de-interlaced correctly to Progressive PAL 50 (double frame rate) / NTSC 59.94 (double frame rate).

Even without using a high quality de-interlace line filter, it should still look better than conversion to same frame rate Progressive that Emby does today.

I do not mind if this is a tick option for "Double frame rate de-interlace when necessary" option in Admin options or you do an automatic detection to see if hardware can do it.

Some older non Full HD TVs can't support 50/59.94 frames either, hence the option available.

At the moment, we have a mess of transcoding and de-interlacing content at original frame rate and Progressive encoding and its a juddery blurry mess.

Direct Play is not an issue, as the Television will do the deinterlacing to double frame rate.

Edited by unisoft
Posted

Hi, we already do this. If you're having an issue, please see:

 

Thanks.

Posted (edited)
36 minutes ago, Luke said:

Hi, we already do this. If you're having an issue, please see:

 

Thanks.

On Synology DS2415+ transcoding, this doesn't seem to happen. I also thought Synology DS2415+ had hardware to encode/decode too but Emby says it doesn't.

For example, MPEG2 interlaced PAL content is transcoded to Progressive 25fps not 50fps.

To me, from the log, it looks like Emby does a simple deinterlace using YADIF keeping 25 frames (and not properly de-interlaced).

It does this for Live TV too if it needs to transcode on slower WAN link or playback of Recorded TV (all TV interlaced content).

FFMPEG log looks normal except for this "IsInterlaced":false" as the source is interlaced. IsAnamorphic was correct and so was sound at AC3.

 

{"Protocol":"File","Id":"13b1ceb4a2460b0e88491423331c3cd7","Path":"/volume1/Multimedia/TV Archive/Comedy/Absolutely Fabulous/Season 1/s01e01 Absolutely Fabulous - Fashion.ts","Type":"Default","Container":"mpegts","Size":1006899988,"Name":"s01e01 Absolutely Fabulous - Fashion","IsRemote":false,"RunTimeTicks":17640400000,"SupportsTranscoding":true,"SupportsDirectStream":true,"SupportsDirectPlay":true,"IsInfiniteStream":false,"RequiresOpening":false,"RequiresClosing":false,"RequiresLooping":false,"SupportsProbing":false,"MediaStreams":[{"Codec":"mpeg2video","TimeBase":"1/90000","CodecTimeBase":"1/25","VideoRange":"SDR","DisplayTitle":"576i MPEG2VIDEO","IsInterlaced":true,"BitRate":4566336,"BitDepth":8,"RefFrames":1,"IsDefault":false,"IsForced":false,"Height":576,"Width":720,"AverageFrameRate":25,"RealFrameRate":25,"Profile":"Main","Type":"Video","AspectRatio":"16:9","Index":0,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File","PixelFormat":"yuv420p","Level":8,"IsAnamorphic":true},{"Codec":"ac3","Language":"eng","TimeBase":"1/90000","CodecTimeBase":"1/48000","DisplayTitle":"English AC3 stereo","DisplayLanguage":"English","IsInterlaced":false,"ChannelLayout":"stereo","BitRate":192000,"Channels":2,"SampleRate":48000,"IsDefault":false,"IsForced":false,"Type":"Audio","Index":1,"IsExternal":false,"IsTextSubtitleStream":false,"SupportsExternalStream":false,"Protocol":"File"}],"Formats":[],"Bitrate":4566336,"RequiredHttpHeaders":{},"ReadAtNativeFramerate":false}

 

>>>>>>  User policy for CURRENT_USER
        EnablePlaybackRemuxing: True
        EnableVideoPlaybackTranscoding: True
        EnableAudioPlaybackTranscoding: True

>>>>>>  Affected codecs
Encoder libx264 Software Encoder
        Profiles: Baseline Profile (Level 6.2), Main Profile (Level 6.2), High Profile (Level 6.2), High 10 Profile (Level 6.2), High 4:2:2 Profile (Level 6.2), High 4:4:4 Predictive Profile (Level 6.2)


>>>>>>  FindVideoEncoder - Media: h264, UseHardwareCodecs: True, Mode: Automatic
Info    Checking: 'libx264 Software Encoder'
Info    Check successful - selecting 'libx264 Software Encoder'

>>>>>>  FindVideoDecoder - MediaType: mpeg2video, Mode: Automatic
Info    Checking: 'Automatic software decoder'
Info    Check successful - selecting 'Automatic software decoder'

>>>>>>  Processing Plan
Info    Name                                        CanDoInHardware      WillDoInHardware     Reason                                  
Info    Automatic software decoder               >> False                False                Software Codec                           
Info    VideoInput                               >> False                False                Not a hardware decoder                   
Info    Deinterlace                              >> False                False                                                         
Info    VideoOutput                              >> False                False                Not a hardware encoder                   
Info    libx264 Software Encoder                 >> False                False                Software Codec                           

>>>>>>  Projected Processing Formats
Info    Previous                HW-Context   Format       SW-Format           Size   Next
Info    mpeg2video           >> -            yuv420p      yuv420p          720x576 >> yadif
Info    yadif                >> -            yuv420p      yuv420p          720x576 >> 

>>>>>  Non-Default Encoder Parameters
Warning EncoderParametersH264LibX.Preset: Original: veryfast Actual: superfast

/var/packages/EmbyServer/target/bin/ffmpeg -loglevel +timing -y -print_graphs_file "/var/packages/EmbyServer/var/logs/ffmpeg-transcode-c7a1b356-b73d-402b-a7d1-4617aefccebb_1graph.txt" -copyts -start_at_zero -f mpegts -ss 00:11:06.000 -c:v:0 mpeg2video -i "/volume1/Multimedia/TV Archive/Comedy/Absolutely Fabulous/Season 1/s01e01 Absolutely Fabulous - Fashion.ts" -filter_complex "[0:0]yadif@f1=mode=send_frame:parity=auto:deint=all[f1_out0]" -map [f1_out0] -map 0:1 -sn -c:v:0 libx264 -g:v:0 75 -maxrate:v:0 4566336 -bufsize:v:0 9132672 -sc_threshold:v:0 0 -keyint_min:v:0 75 -pix_fmt:v:0 yuv420p -preset:v:0 superfast -profile:v:0 high -level:v:0 3.0 -x264opts:v:0 "subme=0:me_range=4:rc_lookahead=10:partitions=none" -crf:v:0 23 -c:a:0 copy -metadata:s:a:0 language=eng -disposition:a:0 default -max_delay 5000000 -avoid_negative_ts disabled -f segment -map_metadata -1 -map_chapters -1 -segment_format mpegts -segment_list "/volume1/Emby/Transcode/transcoding-temp/BBB2B9.m3u8" -segment_list_type m3u8 -segment_time 3 -segment_start_number 222 -individual_header_trailer 0 -write_header_trailer 0 -segment_write_temp 1 "/volume1/Emby/Transcode/transcoding-temp/BBB2B9_%d.ts"

12:39:32.658 ffmpeg version 4.3.0-emby_2021_02_27 Copyright (c) 2000-2021 the FFmpeg developers and softworkz for Emby LLC
12:39:32.658   built with gcc 8.3.0 (crosstool-NG 1.24.0)
12:39:32.658 Execution Date: 2021-08-18 12:39:32
12:39:32.797 Input #0, mpegts, from '/volume1/Multimedia/TV Archive/Comedy/Absolutely Fabulous/Season 1/s01e01 Absolutely Fabulous - Fashion.ts':
12:39:32.797   Duration: 00:29:24.04, start: 0.200000, bitrate: 4566 kb/s
12:39:32.797   Program 1 
12:39:32.797     Stream #0:0[0xe0]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p(tv, top first), 720x576 [SAR 64:45 DAR 16:9], Level 8, 25 fps, 25 tbr, 90k tbn, 50 tbc, Start-Time 0.240s
12:39:32.798     Stream #0:1[0x1001](eng): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 192 kb/s, Start-Time 0.200s
12:39:32.799 Stream mapping:
12:39:32.799   Stream #0:0 (mpeg2video) -> yadif
12:39:32.799   yadif -> Stream #0:0 (libx264)
12:39:32.799   Stream #0:1 -> #0:1 (copy)
12:39:32.799 Press [q] to stop, [?] for help
12:39:32.826 [libx264 @ 0x8abdc0] using SAR=64/45
12:39:32.827 [libx264 @ 0x8abdc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2
12:39:32.829 [libx264 @ 0x8abdc0] profile High, level 3.0, 4:2:0, 8-bit
12:39:32.829 [libx264 @ 0x8abdc0] 264 - core 161 r3039 544c61f - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=4 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=75 keyint_min=38 scenecut=0 intra_refresh=0 rc_lookahead=10 rc=crf mbtree=0 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 vbv_maxrate=4566 vbv_bufsize=9132 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 pb_ratio=1.30 aq=1:1.00
12:39:32.830 Output #0, segment, to '/volume1/Emby/Transcode/transcoding-temp/BBB2B9_%d.ts':
12:39:32.830   Metadata:
12:39:32.830     encoder         : Lavf58.35.100
12:39:32.830     Stream #0:0: Video: h264 (libx264), yuv420p, 720x576 [SAR 64:45 DAR 16:9], q=-1--1, 25 fps, 90k tbn, 25 tbc
12:39:32.830     Metadata:
12:39:32.830       encoder         : Lavc58.62.100 libx264
12:39:32.830     Side data:
12:39:32.830       cpb: bitrate max/min/avg: 4566000/0/0 buffer size: 9132000 vbv_delay: N/A
12:39:32.830     Stream #0:1(eng): Audio: ac3 ([6][0][0][0] / 0x0006), 48000 Hz, stereo, fltp, 192 kb/s (default)


[q] command received. Exiting.

 

Edited by unisoft
Posted

Hi there, please attach complete log file examples. thanks.

Posted

Hi Luke, 

Can you see anything as to why it transcodes to same frame rate using YADIF?

thanks

Posted

This is using ""[0:0]yadif@f1=mode=send_frame" so it will not double the frame rate. With send_frame it's only going to output one frame for both fields.
If this was "send_field" it would "double" the frame rate by creating one frame for each field.

If memory serves me correctly this used to be an option but there was too many devices that couldn't handle the double frame rate.  Again if memory serves me correctly this was back in the day when the Roku 3 ruled the day.  With today's devices this should work a lot better.

I do agree watching anything with motion like sporting events that don't "double" the fields loses half the temporal motion.

Posted
On 18/08/2021 at 13:03, Luke said:

Hi there, please attach complete log file examples. thanks.

Hi Luke,

So as per original request, please could we have something like the "Double frame rate de-interlace when necessary" option in user side or admin side settings for transcoding?

You could do auto-detect, but to refrain from a lot of work, the setting option is the easiest with default of unticked possibly?

This is the single biggest picture quality boost you can give to anyone who has interlaced content (typically television content, whether live or DVD or (interlaced) Blu ray rips).

It will then keep the temporal motion properly and "live look" of any studio recorded programmes and smooth ticker tapes or credit scrolling.

The BBC moved to double frame rate (50fps) for their catch up player (iPlayer) when serving 720p (effectively their 1080i content downscaled as they don't offer 1080p50 on catch up yet)

Thanks...

Posted

If you like Bob Weaver.  I usually prefer Yadif for sports as it looks cleaner to me.

Posted
43 minutes ago, cayars said:

If you like Bob Weaver.  I usually prefer Yadif for sports as it looks cleaner to me.

Did you read what it was? Go read it's description. It's basically yadif with added stuff for motion compensation.

Posted

Thanks for pointing that out again. :)

I'll have to play a bit over the weekend with a few conversions of some sports using both Yadif and this and do a comparison.
It certainly sounds like it could be a winner.

Posted
13 hours ago, generiq said:

Did you read what it was? Go read it's description. It's basically yadif with added stuff for motion compensation.

This isn't de-interlacing properly no matter what you think.

The only way to do it properly, is double frame rate when going to progressive format.

bwdif was used (to highlight an example) on Apple TV Emby App - it still looks awful.

It's OK to use this as a default for most compatibility with old tat, but there should be an option for double frame rate.

Double Frame rate is what your LCD/OLED does when it de-interlaces an interlaced TV Signal. In Broadcast conversion terms, you should also use a high quality line filter too, but even without one, the picture would still be far better than today.

 

Posted
11 hours ago, unisoft said:

This isn't de-interlacing properly no matter what you think.

Oh my... *face-palm*

11 hours ago, unisoft said:

bwdif was used (to highlight an example) on Apple TV Emby App - it still looks awful.

Hasn't anyone told you that everything apple is bad?

11 hours ago, unisoft said:

The only way to do it properly, is double frame rate when going to progressive format.

As @cayars stated

On 8/19/2021 at 1:08 PM, cayars said:

This is using ""[0:0]yadif@f1=mode=send_frame" so it will not double the frame rate. With send_frame it's only going to output one frame for both fields.
If this was "send_field" it would "double" the frame rate by creating one frame for each field.

This is what bwdif does by default. 

1448217716_Screenshot2021-08-21161829.thumb.jpg.ddef4eeded6e4768b4eb2a3eb6b8d3a1.jpg

But most often, interpolation is also required because a great many people will have their displays set to 60Hz. So when playing an interlaced 25fps video, it should be doubled to 50Hz, and then it has to be interpolated from 50Hz to 60Hz. Which is what bwdif does very well.

I suppose there is the possibility that when they implemented this into the apple app they forced `send_frame`, which they really shouldn't do. But I use bwdif in mpv, and it's fantastic!

For your edification, here's a little more info on bwdif.

https://github.com/HomeOfVapourSynthEvolution/VapourSynth-Bwdif

 

Posted (edited)

So, I am still correct in what I stated in terms of double frame rate.

Bwdif is just the filter you use to achieve it. I can only assume the Emby Apple TV implementation is incorrect then in requesting one frame as it looks just plain wrong. If send field actually doubles then  it should achieve desired result and the Apple TV app needs correcting too.

For PAL (UK anyway!) it looks like the value is 3 for bwdif to use double frame rate, TOP line. All content here is TOP field - (SD or HD).

Edited by unisoft
Posted

Ok, so I have a number of samples I test with. Here's what happens when I play an interlaced 25fps PAL video. 

Notice the doubling of the frame rate from 25 to 50, while my display is 59.94Hz

1557535066_Screenshot2021-08-21171045.jpg.77cfe7327d5c4c1f275c7b1f8b163e12.jpg

Posted (edited)
9 hours ago, generiq said:

Ok, so I have a number of samples I test with. Here's what happens when I play an interlaced 25fps PAL video. 

Notice the doubling of the frame rate from 25 to 50, while my display is 59.94Hz

1557535066_Screenshot2021-08-21171045.jpg.77cfe7327d5c4c1f275c7b1f8b163e12.jpg

Yep, in PAL 50hz countries, that would then play back fine as TVs intended for use in that territory would be 50hz. 25 frames is doubled to 50, a clean multiple. Colour space is generally accepted in broadcast circles as bt709 for SD now instead of legacy bt470bg (601) before HD days.

This should steal a march on quality over Plex as they didn't do proper de-interlace last time I used their app.

Edited by unisoft
  • Like 1
Posted

The one thing to consider when doubling the frame rate, is that it's also doubling the bandwidth. So when the server is transcoding for a remote user, that will be a big factor, as most people don't have a lot of upstream bandwidth. But for the client, I would definitely recommend it.

Posted
3 hours ago, generiq said:

The one thing to consider when doubling the frame rate, is that it's also doubling the bandwidth. So when the server is transcoding for a remote user, that will be a big factor, as most people don't have a lot of upstream bandwidth. But for the client, I would definitely recommend it.

Isn't this covered under maximum bit rate though? You can set the Internet mbps on the client and a maximum on the server side (admin). Probably if bandwidth rate is less than 6mbps you'd default to non-double frame rate(?)

HD double frame rate at 11mbps can still look Broadcast quality easily as long at the source was average of 5 mbps or greater (when 25fps) originally.

Posted
46 minutes ago, unisoft said:

Isn't this covered under maximum bit rate though? You can set the Internet mbps on the client and a maximum on the server side (admin). Probably if bandwidth rate is less than 6mbps you'd default to non-double frame rate(?)

HD double frame rate at 11mbps can still look Broadcast quality easily as long at the source was average of 5 mbps or greater (when 25fps) originally.

Yes, but it'll be a trade off. Higher frame rate, lower bitrate to maintain the overall bandwidth. All my Live TV streams that are 59.94Hz are 720p or lower. If you have the upload bandwidth, it won't matter, as most people these days have broadband download. But if you stream to a mobile device, that could be problematic. 

Posted

It would be nice to have the option.  To me watching sports not interlaced properly makes me feel half sick after a bit.

Posted

I do think that all apps should use bwdif (with send_field), if they can. Options are always desirable. If there were a server side option for how to deinterlace, that would be welcome.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...