VideoHelp Forum
+ Reply to Thread
Results 1 to 21 of 21
Thread
  1. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Hello everyone! I recently had the need to convert an interlaced video in M2TS format (With MPEG2 codec) with FFMPEG, to X264, using libx264 -crf. At the end of the conversion, I payed the new video with the VLC, and the quality is practically the same as the original video. Despite the fact that I did not use CRF0.I used CRF15.
    *I had no problem playing the new viedo with the VLC.

    The problem occurred when I transferred the new video to a USB storage device, in order to play the new video on my old version of Sony Bravia TV. It turns out that playing the new video on my Sony Bravia, I realized that the new video has Scanlines and comb artifacts. Those Scanlines and comb artifacts make viewing the video awkward and unpleasant.
    ´
    Of course, The main reason of converting MPEG2 video to x264 is precisely to be able to play the video on my Sony TV, since my TV does not play videos with MPEG2 codec. The only way for my TV to play videos with MPEG2 codec, is to wrap it in a .M2TS container. But the problem is that my TV doesn't play secondary audios or subtitles when the video is in a M2TS container. Secondary audios and subtitles are always useful to me.

    If I wrap the original video with MPEG2 codec to an MKV container, then it becomes totally unplayable on my Sony TV. That is why I have, or had the need to convert MPEG2 video to x264.

    As I said before, the new video looks perfect playing it in VLC software, but not on my TV. I think this is because VLC autocorrect the Scanlines and comb artifacts.

    So what I need is, can someone tell me, how to get the same conversion quality as I got using the parameters (-c: v libx264 -crf), but without the Scanlines and comb artifacts?

    Which filter should I use? I think when you don't use an extra filter when you convert an interlaced video to any other video codec, FFMPEG automatically deinterlaces the video while converting.

    Maybe using a filter that keeps the video interlaced could be the solution, but what would be the filter to use? I need some filter that keeps the video interlaced while using libx264 -crf. Or maybe a filter that deinterlaces the video without losing quality or losing just the minimum quality.

    Sorry for all the misspelling, Im not a english native speaker.

    Anyone out there who can help me with this?
    Last edited by Rizoko; 15th May 2020 at 20:03.
    Quote Quote  
  2. Sony has the worst media players. The fact that VLC is playing your converted video without comb artifacts indicates it is encoded interlaced and properly flagged. It's your TV's media player that's at fault. Since you can't do anything about the TV you can deinterlace when you encode. Try the yadif or bwdif filter.

    http://ffmpeg.org/ffmpeg-filters.html#yadif-1
    http://ffmpeg.org/ffmpeg-filters.html#bwdif

    You may have to downscale to 720p if you use the double frame rate options.
    Quote Quote  
  3. You can encode it interlaced (really MBAFF if using libx264), and your TV will deinterlace it

    add these
    Code:
    -flags +ilme+ildct -x264opts tff=1
    Quote Quote  
  4. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by jagabo View Post
    Sony has the worst media players. The fact that VLC is playing your converted video without comb artifacts indicates it is encoded interlaced and properly flagged. It's your TV's media player that's at fault. Since you can't do anything about the TV you can deinterlace when you encode. Try the yadif or bwdif filter.

    http://ffmpeg.org/ffmpeg-filters.html#yadif-1
    http://ffmpeg.org/ffmpeg-filters.html#bwdif

    You may have to downscale to 720p if you use the double frame rate options.
    "The fact that VLC is playing your converted video without comb artifacts indicates it is encoded interlaced and properly flagged." That makes sense, but then why my TV plays the original interlaced MPEG2 video (In a M2TS container) with no scanlines and comb artifacts? Of course I believe in your explanation, just dont understand why the original video doesnt show any issues on my TV.

    But definitely I dont wanna to downscale the video to 720p.
    TV. I will give those filters a try! Thanks!
    Quote Quote  
  5. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by poisondeathray View Post
    You can encode it interlaced (really MBAFF if using libx264), and your TV will deinterlace it

    add these
    Code:
    -flags +ilme+ildct -x264opts tff=1
    Thank you! I will give it a try!
    Quote Quote  
  6. Originally Posted by Rizoko View Post
    why my TV plays the original interlaced MPEG2 video (In a M2TS container) with no scanlines and comb artifacts?
    Because MPEG2 isn't h.264. And m2ts isn't mp4. It's not unusual for TVs to support different features for different codecs and containers. But there's one other possibility. Since you indicated VLC played the video properly I assumed you had already done what poisondeathray suggested. But... Did you force VLC to deinterlace or did it automatically detect the video was interlacded? If the former then poisondeathray's suggestion may work.

    Originally Posted by Rizoko View Post
    But definitely I dont wanna to downscale the video to 720p.
    You may have no choice if your TV can't play 1080p60, and pdr's options don't play, and you want smooth motion.

    Another possibility if this is a movie or TV show: it should be inverse telecined to 23.976 fps and encoded progressive, or, if PAL field matched and encoded progressive at 25 fps.
    Last edited by jagabo; 15th May 2020 at 20:06.
    Quote Quote  
  7. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by jagabo View Post
    Originally Posted by Rizoko View Post
    why my TV plays the original interlaced MPEG2 video (In a M2TS container) with no scanlines and comb artifacts?
    Because MPEG2 isn't h.264. And m2ts isn't mp4. It's not unusual for TVs to support different features for different codecs and containers. But there's one other possibility. Since you indicated VLC played the video properly I assumed you had already done what poisondeathray suggested. But... Did you force VLC to deinterlace or did it automatically detect the video was interlacded? If the former then poisondeathray's suggestion may work.

    Originally Posted by Rizoko View Post
    But definitely I dont wanna to downscale the video to 720p.
    You may have no choice if your TV can't play 1080p60, and pdr's options don't play, and you want smooth motion.

    Another possibility if this is a movie or TV show: it should be inverse telecined to 23.976 fps and encoded progressive, or, if PAL field matched and encoded progressive at 25 fps.
    Tbh. I downloaded a portable version of VLC the other day, and I didnt change any settings. My TVs guide indicates that it supports 1080p60. But dont know what PDR is.

    I will upload a sample of my video tomorrow!
    Quote Quote  
  8. Originally Posted by Rizoko View Post
    I downloaded a portable version of VLC the other day, and I didnt change any settings.
    The default for deinterlacing is "auto". The program only deinterlaces if the video as flagged asinterlaced.

    Originally Posted by Rizoko View Post
    My TVs guide indicates that it supports 1080p60.
    Does it specifically say it support playing 1080p60, h.264 video, in an mp4 container? All 1080p TV's support 60p display. But they don't necessarily support playing 1080p60 video.

    Originally Posted by Rizoko View Post
    But dont know what PDR is.
    pdr = poisondeathray

    Originally Posted by Rizoko View Post
    I will upload a sample of my video tomorrow!
    Check your encoded video with MediaInfo. It will tell you if it is encoded interlaced.
    Quote Quote  
  9. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by jagabo View Post
    Originally Posted by Rizoko View Post
    I downloaded a portable version of VLC the other day, and I didnt change any settings.
    The default for deinterlacing is "auto". The program only deinterlaces if the video as flagged asinterlaced.

    Originally Posted by Rizoko View Post
    My TVs guide indicates that it supports 1080p60.
    Does it specifically say it support playing 1080p60, h.264 video, in an mp4 container? All 1080p TV's support 60p display. But they don't necessarily support playing 1080p60 video.

    Originally Posted by Rizoko View Post
    But dont know what PDR is.
    pdr = poisondeathray

    Originally Posted by Rizoko View Post
    I will upload a sample of my video tomorrow!
    Check your encoded video with MediaInfo. It will tell you if it is encoded interlaced.
    Yes! Im sure my TV supports 1080p 60 fps, I have played BD Remuxes 1080p x264 at 60fps of my Media Backups with no problems. I forgot to mention that when I used libx264 -crf in FFMPEG , I also used -level:v 4.0 Is that related to the problem? I didnt try with Level 3.1 or something like that.

    Here are some screenshots of my TVs codecs Guide:
    Code:
    https://mega.nz/file/fE0m0Saa#kGeFJ-PlUoAogZIU77i9kJuEy5aEaGNUUoGwtB6k-V8
    
    https://mega.nz/file/HEkG0CjY#xaktL8FHlz0Butv-Xai4c65fFXQEmwBdVqcmwTl1uKo
    
    https://mega.nz/file/3F0CnQyL#bFDfXM6sgEa9Qo0RdRis5ABcMDTgjxK5to3hvc9wT0Y
    Give them a look!

    Here is the Info of the Original Interlaced video with MPEG2 codec which is playable on my TV but without Subtitles and secondary audio options.
    Code:
    General
    ID                          : 1 (0x1)
    Complete name               : King.m2ts
    Format                      : BDAV
    Format/Info                 : Blu-ray Video
    File size                   : 18.4 GiB
    Duration                    : 3 h 7 min
    Overall bit rate mode       : Variable
    Overall bit rate            : 14.0 Mb/s
    Maximum Overall bit rate    : 35.5 Mb/s
    Movie name                  : KING 
    Law rating                  : PG-13
    
    Video
    ID                          : 4113 (0x1011)
    Menu ID                     : 1 (0x1)
    Format                      : MPEG Video
    Format version              : Version 2
    Format profile              : Main@High
    Format settings             : CustomMatrix / BVOP
    Format settings, BVOP       : Yes
    Format settings, Matrix     : Custom
    Format settings, GOP        : M=2, N=14
    Codec ID                    : 2
    Duration                    : 3 h 7 min
    Bit rate mode               : Variable
    Bit rate                    : 12.4 Mb/s
    Maximum bit rate            : 14.0 Mb/s
    Width                       : 1 920 pixels
    Height                      : 1 080 pixels
    Display aspect ratio        : 16:9
    Frame rate                  : 29.970 (30000/1001) FPS
    Standard                    : Component
    Color space                 : YUV
    Chroma subsampling          : 4:2:0
    Bit depth                   : 8 bits
    Compression mode            : Lossy
    Bits/(Pixel*Frame)          : 0.200
    Stream size                 : 16.3 GiB (89%)
    Color primaries             : BT.709
    Transfer characteristics    : BT.709
    Matrix coefficients         : BT.709
    An here is the Info of the video I got after converting it to x264 with FFmpeg using libx264 -crf Level 4.0:
    Code:
    General
    Unique ID                   : 224301376682332179925768733955278093026 (0xA8BEDFB0D4C2EE55B68BCF32F555BAE2)
    Complete name               : K:\King.mkv
    Format                      : Matroska
    Format version              : Version 4
    File size                   : 14.8 GiB
    Duration                    : 2 h 24 min
    Overall bit rate            : 14.7 Mb/s
    Encoded date                : UTC 2020-05-14 01:59:29
    Writing application         : mkvmerge v6.1.0 ('Old Devil') built on Mar  2 2013 14:32:37
    Writing library             : libebml v1.3.0 + libmatroska v1.4.0
    
    Video
    ID                          : 1
    Format                      : AVC
    Format/Info                 : Advanced Video Codec
    Format profile              : High@L4
    Format settings             : CABAC / 4 Ref Frames
    Format settings, CABAC      : Yes
    Format settings, Reference  : 4 frames
    Codec ID                    : V_MPEG4/ISO/AVC
    Bit rate                    : 14.0 Mb/s
    Width                       : 1 920 pixels
    Height                      : 1 080 pixels
    Display aspect ratio        : 16:9
    Frame rate mode             : Variable
    Color space                 : YUV
    Chroma subsampling          : 4:2:0
    Bit depth                   : 8 bits
    Scan type                   : Progressive
    Writing library             : x264 core 157 r2935 545de2f
    Encoding settings           : cabac=1 / ref=4 / deblock=1:0:0 / analyse=0x3:0x133 / me=umh / subme=10 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=24 / chroma_me=1 / trellis=2 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=6 / lookahead_threads=1 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=8 / b_pyramid=2 / b_adapt=2 / b_bias=0 / direct=3 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=60 / rc=crf / mbtree=1 / crf=18.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.40 / aq=1:1.00
    Default                     : Yes
    Forced                      : No
    About the original video I wonder where can we see if it is a Progressive or Interlaced video? Im completely sure its Interlaced because I can see the Scanlines and comb artifacts. I can see the Scanlines and comb artifacts even in the VLC using the "Frame by Frame" option. Can you see what o where is the problem/issue just by seeing the Info of both videos? As you can see the original video is at 29.00 Fps. But trust me I just realized that the video I got from FFmpeg doesnt show a especific Frame Rate. Could the Frame Rate be the issue in the converted o re-encoded video I got from FFmpeg?
    Last edited by Rizoko; 15th May 2020 at 21:25.
    Quote Quote  
  10. MediaInfo will usually show:

    Code:
    Scan type                                : Interlaced
    Scan order                               : Top Field First (or Bottom Field First)
    if the video is encoded interlaced. It doesn't know if the frames contain interlaced or progressive video. It possible to encode progressive frames in interlaced mode, or to encode interlaced frames in progressive mode. Both mess up the video to some extent.

    So your source video is encoded progressive even though it contains interlaced frames. MediaInfo is showing your x264 encoding is variable frame rate and is also progressive (presumably keeping the interlaced frames). You can use the options PDR mentioned to force x264 to encode the frames interlaced. If your TV supports that you will no longer see comb artifacts when playing it. But there will be blended chroma artifacts from the progressive MPEG 2 encoding -- visible when colored objects are moving.
    Quote Quote  
  11. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by jagabo View Post
    MediaInfo will usually show:

    Code:
    Scan type                                : Interlaced
    Scan order                               : Top Field First (or Bottom Field First)
    if the video is encoded interlaced. It doesn't know if the frames contain interlaced or progressive video. It possible to encode progressive frames in interlaced mode, or to encode interlaced frames in progressive mode. Both mess up the video to some extent.

    So your source video is encoded progressive even though it contains interlaced frames. MediaInfo is showing your x264 encoding is variable frame rate and is also progressive (presumably keeping the interlaced frames). You can use the options PDR mentioned to force x264 to encode the frames interlaced. If your TV supports that you will no longer see comb artifacts when playing it. But there will be blended chroma artifacts from the progressive MPEG 2 encoding -- visible when colored objects are moving.
    Thank you or all that useful information! Ill try MBAFF asap! Have a great weekend!
    Quote Quote  
  12. I recommend you upload a short (10 sec?) sample of your source with moderate motion -- not reencoded.
    Quote Quote  
  13. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by jagabo View Post
    I recommend you upload a short (10 sec?) sample of your source with moderate motion -- not re-encoded.
    Ive tried what poisondeathray suggested! And it works! It gives me the impression it lost or it loses a a little bit of quality compared to the result I got when I used only (-c: v libx264 -crf) without "-flags +ilme+ildct -x264opts tff=1" which the quality was exactly than original. However using "-flags +ilme+ildct -x264opts tff=1" the quality is totally acceptable.

    But, as I said before, maybe it's just my impression, about the quality of both.
    Maybe there is no difference about quality using only (-c: v libx264 -crf) without "-flags + ilme + ildct -x264opts tff = 1" and using both together.
    I am having some headaches lately, which prevent me from seeing clearly the differences between both videos. Lol.

    I know you are a master about video encoding or about video codecs, edition, etc. But I think my original MPEG2 video is Interlaced. Because when I load it in TSmuxer, Tsmuxer shows me the info confirming its Interlaced. The video name appears as (i) which means Interlaced, not as (p) which means Progressive.
    Here is an screenshot:
    Image
    [Attachment 53343 - Click to enlarge]


    But its on the pending upload a 10 secs fragment of the original video.

    Thanks for all the help! I really appreciate it!
    Last edited by Rizoko; 16th May 2020 at 17:09.
    Quote Quote  
  14. Is it a "movie"? Where is it from originally ? It says "(pulldown") , which could indicate 23.976p with telecine (progressive content encoded as interlaced fields)
    Quote Quote  
  15. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by poisondeathray View Post
    Is it a "movie"? Where is it from originally ? It says "(pulldown") , which could indicate 23.976p with telecine (progressive content encoded as interlaced fields)
    Yes! It is, Its a movie. I asked one of my friends to recording one of my fav movies from TV. Dont know exatcly whats the method he used to recording the full movie and saved it as a MPEG2 (.TS) video file, then I had to remux it from .TS to M2TS since my TV doesnt accept .TS containers.
    Quote Quote  
  16. Most "movies" are not interlaced in terms of content. They are progressive and only telecined for TV (pulldown added). The proper treatment would be to inverse telecine, or reverse the process to get back the original frames at 23.976p

    Post the sample video . You can split a section with tsmuxer
    Quote Quote  
  17. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    @poisondeathray @jagabo Hey guys! I finally uploaded a fragment of the original MPEG2 video file! Maybe you guys are not gonna believe me, but split a certain fragment of the original video was not easy at all. it took me all long day. I wanted to upload a part of the video where Scanlines are visible, thats why I didn't want to upload the part or section of the beginning of the movie since there was not Scanlines in the first 40 secs, and there was no software able to split a specific section of the video. Not even TSmuxer was able to do that. When I selected a specific section to be splitted in TSmuxer I just got audio wrapped in a M2TS container, I tried like 10 different softwares, and I didn't get a solution. All the other softwares gave me the same results. Believe or not the original MPEG2 video file is such a mysterious video file. It's not a manoeuvrable video file. The only way I got to be able to split a spicific time or part of the video, was changing the M2TS container to a MKV container, and then load it to Avidemux. Avidemux did the Splitting job with/to the MKV container.

    You guys can check/test the original video fragment yourselves, and try to pass/change the video fragment that I uploaded, to M2TS using TSmuxer or any video software tool of your choice, and you will see that it cannot be done.

    But please guys, give me your opinion after you play the fragment of the original video on your media players.

    Please test it or check it in VLC, MPHC, and even transfer the fragment of the video to your USB device storage and plug-n-play on your TV.

    Here is the link to download the fragment of the original MPEG2 video file:
    Code:
    https://mega.nz/file/GA0yQKJR#B43grq-NMbxJf1zbug8R4u5T2dR0NDjq1ZAv2CoGj8Y
    Hopefully after you guys play the video clip on your media players. You will be able to tell me if there is a better conversion method in FFMPEG when converting to x264.
    Last edited by Rizoko; 16th May 2020 at 22:18.
    Quote Quote  
  18. It's 23.976p content. You should IVTC. In ffmpeg it would be

    Code:
    -vf "fps=30000/1001,fieldmatch,yadif=deint=interlaced,decimate"
    But ffmpeg IVTC tends to keep/drop the wrong frames, and sometimes leaves combing. If you check the file, you can see this is true - jerky in sections with dropped frames, pauses with duplicate frames

    It's not as reliable as avisynth or vapoursynth for IVTC - that's what I would use

    or If your TV can detect the cadence an IVTC on the fly, it's probably better, leave it as fields with the telecine. But if it only deinterlaces, it's not as good the quality will be worse
    Quote Quote  
  19. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by poisondeathray View Post
    It's 23.976p content. You should IVTC. In ffmpeg it would be

    Code:
    -vf "fps=30000/1001,fieldmatch,yadif=deint=interlaced,decimate"
    But ffmpeg IVTC tends to keep/drop the wrong frames, and sometimes leaves combing. If you check the file, you can see this is true - jerky in sections with dropped frames, pauses with duplicate frames

    It's not as reliable as avisynth or vapoursynth for IVTC - that's what I would use

    or If your TV can detect the cadence an IVTC on the fly, it's probably better, leave it as fields with the telecine. But if it only deinterlaces, it's not as good the quality will be worse
    Now my question is which ones is better between using "flags +ilme+ildct -x264opts tff=1" and -vf "fps=30000/1001,fieldmatch,yadif=deint=interlaced,decimate"? Or I have to use both options together in FFMPEG command? Do you mean that Avisynth or Vapoursynth are better than FFMPEG when it comes to working with IVTC? Ive never used Avisynth or Vapoursynth before. Are Avisynth or Vapoursynth easy to use?
    Quote Quote  
  20. Originally Posted by Rizoko View Post


    Now my question is which ones is better between using "flags +ilme+ildct -x264opts tff=1" and -vf "fps=30000/1001,fieldmatch,yadif=deint=interlaced,decimate"?
    The 2nd doesn't work well, because of FFmpeg . It drops the wrong frames (jerky), keeps the wrong frames (duplicates), missing combing


    Or I have to use both options together in FFMPEG command?
    No, it's either/or ; not both

    If your TV can IVTC on the fly (3:2 cadence detection, most should be able to) , the 1st option is better. Unless you want to learn avisynth


    Do you mean that Avisynth or Vapoursynth are better than FFMPEG when it comes to working with IVTC?
    Yes, and your sample shows those problems I mentioned above with FFMpeg IVTC ; and if you compare avisynth's is clean and does not have those problems

    Ive never used Avisynth or Vapoursynth before. Are Avisynth or Vapoursynth easy to use?
    Not easy to use at first - A bit of a learning curve unfortunately, it takes a while to get started ,but once you're up and running it's not too bad
    Quote Quote  
  21. Member
    Join Date
    Nov 2019
    Location
    Massachusettts
    Search PM
    Originally Posted by poisondeathray View Post
    Originally Posted by Rizoko View Post


    Now my question is which ones is better between using "flags +ilme+ildct -x264opts tff=1" and -vf "fps=30000/1001,fieldmatch,yadif=deint=interlaced,decimate"?
    The 2nd doesn't work well, because of FFmpeg . It drops the wrong frames (jerky), keeps the wrong frames (duplicates), missing combing


    Or I have to use both options together in FFMPEG command?
    No, it's either/or ; not both

    If your TV can IVTC on the fly (3:2 cadence detection, most should be able to) , the 1st option is better. Unless you want to learn avisynth


    Do you mean that Avisynth or Vapoursynth are better than FFMPEG when it comes to working with IVTC?
    Yes, and your sample shows those problems I mentioned above with FFMpeg IVTC ; and if you compare avisynth's is clean and does not have those problems

    Ive never used Avisynth or Vapoursynth before. Are Avisynth or Vapoursynth easy to use?
    Not easy to use at first - A bit of a learning curve unfortunately, it takes a while to get started ,but once you're up and running it's not too bad
    Thanks for the explanation bro!
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!