VideoHelp Forum
+ Reply to Thread
Results 1 to 15 of 15
Thread
  1. Member
    Join Date
    Apr 2016
    Location
    Spain
    Search PM
    Hi, I'm trying to convert videos to PAL mpg2, 720x576, 16:9, mp2 audio.

    No problem when the source are another MPG2, the result is correct, interlace is mantained.

    But I'm trying to convert HD videos with interlace and the result MPG2 is progressive.

    This is the command:

    ffmpeg.exe -i TESTFILE.MP4 -vcodec mpeg2video -b:v 6000k -s 720x576 -r 50 -target pal-dvd -sws_flags full_chroma_int+full_chroma_inp -sws_dither none -threads 0 -flags +ilme+ildct -top 0 -bf 2 -trellis 2 -g 45 -acodec mp2 -acodec mp2 -ac 2 -ab 224k -ar 48000 -async 1 -y -f vob TESTFILE.mpg

    I have tested with different -sws_flags, and without -sws_dither, -async, -f vob, -trellis, -bf, etc... and never retain the interlace.

    This is the FFMPEG output:

    ffmpeg version N-66917-g0e406ab Copyright (c) 2000-2014 the FFmpeg developers
    built on Oct 16 2014 01:40:02 with gcc 4.9.1 (GCC)
    configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
    isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
    le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
    enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
    modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
    b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
    r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en
    able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
    --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
    libx265 --enable-libxavs --enable-libxvid --enable-zlib
    libavutil 54. 10.100 / 54. 10.100
    libavcodec 56. 8.100 / 56. 8.100
    libavformat 56. 9.100 / 56. 9.100
    libavdevice 56. 1.100 / 56. 1.100
    libavfilter 5. 1.106 / 5. 1.106
    libswscale 3. 1.101 / 3. 1.101
    libswresample 1. 1.100 / 1. 1.100
    libpostproc 53. 3.100 / 53. 3.100
    Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\test.MP4':
    Metadata:
    major_brand : mp42
    minor_version : 0
    compatible_brands: mp42mp41
    creation_time : 2016-04-19 11:37:29
    Duration: 00:01:43.81, start: 0.000000, bitrate: 29785 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv), 1920x
    1080 [SAR 1:1 DAR 16:9], 29599 kb/s, 25 fps, 25 tbr, 25k tbn, 50 tbc (default)
    Metadata:
    creation_time : 2016-04-19 11:37:29
    handler_name : ?Mainconcept Video Media Handler
    encoder : AVC Coding
    Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 18
    9 kb/s (default)
    Metadata:
    creation_time : 2016-04-19 11:37:29
    handler_name : #Mainconcept MP4 Sound Media Handler
    -async is forwarded to lavfi similarly to -af aresample=async=1:min_hard_comp=0.
    100000:first_pts=0.
    Output #0, vob, to 'A:\test.mpg':
    Metadata:
    major_brand : mp42
    minor_version : 0
    compatible_brands: mp42mp41
    encoder : Lavf56.9.100
    Stream #0:0(eng): Video: mpeg2video, yuv420p, 720x576 [SAR 64:45 DAR 16:9],
    q=2-31, 6000 kb/s, 25 fps, 90k tbn, 25 tbc (default)
    Metadata:
    creation_time : 2016-04-19 11:37:29
    handler_name : ?Mainconcept Video Media Handler
    encoder : Lavc56.8.100 mpeg2video
    Stream #0:1(eng): Audio: mp2, 48000 Hz, stereo, s16, 224 kb/s (default)
    Metadata:
    creation_time : 2016-04-19 11:37:29
    handler_name : #Mainconcept MP4 Sound Media Handler
    encoder : Lavc56.8.100 mp2
    Stream mapping:
    Stream #0:0 -> #0:0 (h264 (native) -> mpeg2video (native))
    Stream #0:1 -> #0:1 (aac (native) -> mp2 (native))
    Press [q] to stop, [?] for help
    frame= 20 fps=0.0 q=0.0 size= 248kB time=00:00:00.78 bitrate=2598.0kbits/s



    The source shows 50 tbc and the output is 25 tbc, but the same when the source are a PAL mpg2 and in that case the result is interlaced.

    Any solution?
    Quote Quote  
  2. If you meant actual interlaced content (not just encoding interlaced), you need to start with a 50p file, not 25p. 25 fps interlaced means 50 fields per second. 50 moments in time are represented per second. You are only starting with 25. If you had 50p to start with you can create interlace with -vf interlace or -vf tinterlace
    Quote Quote  
  3. Member
    Join Date
    Apr 2016
    Location
    Spain
    Search PM
    Yes, the source is 50i, with interlaced noticeable in VideoLan (deactivaing deinterlacing).

    The mpg2 result is 50i too (strict PAL), but VideoLan don't show the interlacing, like the source was progressive.

    With -vf interlace (or tinterlace):

    ffmpeg.exe -i S:\test.MP4 -vcodec mpeg2video -vf interlace -b:v 6000k -s 720x576 -r 25 -target pal-dvd -sws_flags full_chroma_int+full_chroma_inp -sws_dither none -threads 0 -flags +ilme+ildct -bf 2 -trellis 2 -g 50 -acodec mp2 -acodec mp2 -ac 2 -ab 224k -ar 48000 -async 1 -y -f vob "A:\test.mpg"

    and then the result is like 12 fps instead 25, and without interlace.
    Quote Quote  
  4. If source is "50i" , then you need to do an interlaced resize to SD . Typically you would bob deinterlace to 50p progressive, resize to SD 50p, then re-interlace. You cannot resize interlaced HD normally with progressive algorithm, otherwise you get nasty artifacts. From a 50p SD source, then either -vf interlace or tinterlace should work. Typically you would lowpass the results as well (otherwise you get line twittering), one of the ffmpeg filters has lowpass options , I forget which one right now, or you can do a vertical blur. It's listed in the documentation
    Quote Quote  
  5. For any interlace source perform bellow steps:

    - deinterlace (with doubled framerate i.e. video will have fieldrate)
    - resize
    - reinterlace

    then encode.

    Originally Posted by poisondeathray View Post
    then either -vf interlace or tinterlace should work. Typically you would lowpass the results as well (otherwise you get line twittering), one of the ffmpeg filters has lowpass options , I forget which one right now, or you can do a vertical blur. It's listed in the documentation
    Or some antialiasing processing can be performed then quality loss will be less severe.
    Last edited by pandy; 19th Apr 2016 at 12:50.
    Quote Quote  
  6. I'll give you a generic template of a generic double rate deinterlace using yadif, progressive scale, SD color adjustment (you need to use colormatrix for Rec601 coming from an HD 709 source). The GOP size for PAL dvd is usually 12 BTW (50 is illegal), and alternate scan is usually used for interlaced encoding. Feel free to change the options or use -tinterlace instead or add the lowpass. This is reinterlaced as TFF .

    This assumes your INPUT file is HD interlaced 50 fields/sec
    Code:
    ffmpeg -i input.ext -vf yadif=1:tff,scale=720:576,colormatrix=bt709:bt601,interlace -pix_fmt yuv420p -vcodec mpeg2video -flags +ildct+ilme -alternate_scan 1 -trellis 2 -top 1 -dc 10 -g 12 -bf 2 -qmin 1 -qmax 31 -b:v 6000k -minrate 1000000 -maxrate 9000000 -bufsize 1835008 -packetsize 2048 -muxrate 10080000 -acodec mp2 -ac 2 -ab 224 -aspect 16:9 -f vob output.mpg
    Quote Quote  
  7. Member
    Join Date
    Apr 2016
    Location
    Spain
    Search PM
    Too much steps, usually we use Edius to convert to mpg2, the purposse to use FFMPEG is to go faster and with less steps, because we need to do with several videos every day. But thanks anyway.
    Quote Quote  
  8. Originally Posted by ffml View Post
    Too much steps, usually we use Edius to convert to mpg2, the purposse to use FFMPEG is to go faster and with less steps, because we need to do with several videos every day. But thanks anyway.
    It's one step. ffmpeg can do it in a linear chain of filters. We're just breaking it down so you understand what is going on sequentially. See post above. Or -filter_complex if you have multiple branches or chains . You can set a batch file if you have multiple videos with the same target settings

    But IMO, the ffmpeg MPEG2 encoder sucks, quality wise. Very poor. Some people have tweaked the settings, using custom matrices...but still not very good
    Quote Quote  
  9. Originally Posted by ffml View Post
    Too much steps, usually we use Edius to convert to mpg2, the purposse to use FFMPEG is to go faster and with less steps, because we need to do with several videos every day. But thanks anyway.
    How this is too much steps if all processing is performed in one step? You can't ignore nature of interlace... if you dealing with interlace source and final results need to keep high quality motion then do things properly...
    Quote Quote  
  10. Member
    Join Date
    Apr 2016
    Location
    Spain
    Search PM
    poisondeathray, now works fine with the HD source, but... with the mpg2 PAL source the result has the fields inverted.

    But I'm going to try changing parameters, thanks a lot.
    Quote Quote  
  11. Code:
    -vf yadif=mode=1:parity=-1:deint=0,scale=720:576:sws_flags=lanczos+accurate_rnd+full_chroma_int+full_chroma_inp:sws_dither=a_dither,tinterlace=mode=interleave_top
    Last edited by pandy; 19th Apr 2016 at 13:26.
    Quote Quote  
  12. Originally Posted by ffml View Post
    poisondeathray, now works fine with the HD source, but... with the mpg2 PAL source the result has the fields inverted.

    But I'm going to try changing parameters, thanks a lot.

    What do you mean "fields inverted" ? Did you mean field order ? TFF vs BFF ?

    If you want BFF (bottom field first, not "Best Friends Forever" ), change these : interlace=scan=bff and -top 0
    Quote Quote  
  13. Member
    Join Date
    Apr 2016
    Location
    Spain
    Search PM
    Hi, with BFF works fine with mpg2 sources, but not with HD. I have removed the ":tff" in the -vf and now works fine with both sources.

    Thanks to all.
    Quote Quote  
  14. ahh I see, you meant wrong field order when deinterlacing the SOURCE. That will give jerky forward/back/foward/back playback. By convention, HD is TFF (99.9% of HD interlaced is TFF) . But be careful, because SD can be EITHER TFF or BFF. I "hardcoded" the TFF value in the example, because you initially inquired about HD interlaced.
    Quote Quote  
  15. Member
    Join Date
    Apr 2016
    Location
    Spain
    Search PM
    Yes, we need to convert from HD sources mainly. Thanks again.
    Quote Quote  



Similar Threads

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