VideoHelp Forum




+ Reply to Thread
Results 1 to 13 of 13
  1. Hi all,

    Have a couple questions regarding ffmpeg order of operations.

    I have been using this command line to convert 1080p60 H.264 files to 1080i60 XDCAM EX files

    Code:
    ffmpeg.exe -i input.mp4  -pix_fmt yuv420p -vcodec mpeg2video -vf tinterlace=4 -flags +ildct+ilme -top 1 -dc 10 -qmin 1 -lmin "1*QP2LAMBDA" -vtag xdv3 -b:v 35000k -minrate 20000k -maxrate 35000k -bufsize 36408333 -g 15 -bf 2 -aspect 16:9  -r 29.97 -s 1920x1080 -async 2 -acodec pcm_s16le -ar 48000  -f mov -y "output.mp4"
    This works great, however I sometimes run into cases where I need to convert 720p60 files into 1080i60. Basically I want to scale up the video, convert to interlace while maintaining the temporal motion. The problem with that code is that it converts the video to interlace before scaling the video. This obviously causes a problem. Is there a way to reorder the operations so that it scales the video first and then interlaces the video?

    Also, to make matters more complicated, I occasionally get footage that is vertical, which I need to scale to 1920x1080 and pad the sides out to maintain the aspect ratio of the original video. I use this command line to do this.

    Code:
    ffmpeg.exe -i input.mp4-vf "scale=iw*sar:ih, pad=max(iw\,ih*(16/9)):ow/(16/9):(ow-iw)/2:(oh-ih)/2" -pix_fmt yuv420p -vcodec mpeg2video -flags +ildct+ilme -top 1 -dc 10 -qmin 1 -lmin "1*QP2LAMBDA" -vtag xdv3 -b:v 35000k -minrate 20000k -maxrate 35000k -bufsize 36408333 -g 15 -bf 2 -aspect 16:9 -r 29.97 -s 1920X1080 -async 2 -acodec pcm_s24le -ar 48000  -f mov -y "output.mp4"
    Now I would like to be able to take videos recorded at 720x1280p60 (vertical) and convert them to 1920x1080i60, again maintaining the temporal motion as well as padding out the sides.

    Is this possible at all?
    Quote Quote  
  2. Add a video scale before the interlace filter, "scale=w=1920:h=1080". And remove the later scale and frame rate arguments.
    Quote Quote  
  3. Any reason to get rid of the frame rate arguments? The scaling worked by the way, thanks!
    Quote Quote  
  4. Also, one last question...If I want to scale up 480i60 video to 1080i, is my only option to deinterlace and reinterlace?

    I know I could do it using an avisynth script, but I'd like to keep it all within an ffmpeg command line. I'm ok if the quality is not going to be as good as using avisynth. I'm basically looking for a quick and dirty way of upscaling 480i content.
    Quote Quote  
  5. Originally Posted by nesburf View Post
    Also, one last question...If I want to scale up 480i60 video to 1080i, is my only option to deinterlace and reinterlace?

    I know I could do it using an avisynth script, but I'd like to keep it all within an ffmpeg command line. I'm ok if the quality is not going to be as good as using avisynth. I'm basically looking for a quick and dirty way of upscaling 480i content.
    quick and dirty way is to use interlace aware scaling flag "interl=1" , and the in/out colormatrix from 601 to 709 for SD to HD color

    Code:
    -vf scale=w=1920:h=1080:interl=1:in_color_matrix=bt601:out_color_matrix=bt709
    https://ffmpeg.org/ffmpeg-filters.html#scale-1
    Quote Quote  
  6. I would avoid scaling like that with ffmpeg. It's basically the same as SeparateFields().Upscale(1920,540).Weave() -- a very poor way of upscaling interlaced video unless it's very fuzzy to start with. It will leave nasty artifacts on sharp horizontal edges. Here's an example, a still frame:

    480i:
    Image
    [Attachment 40417 - Click to enlarge]


    1080i:
    Image
    [Attachment 40418 - Click to enlarge]


    Be sure to view those images at full size. You're much better off with

    Code:
    QTGMC() # or Yadif(mode=1)
    Upscale(1920,1080)
    SeparateFields()
    SelectEvery(4,0,3)
    Weave()
    Quote Quote  
  7. Yes, that's terrible, nice illustration jagabo.



    Or you can use yadif double rate , resize, tinterlace (or interlace) , colormatrix in a linear filter chain with ffmpeg

    Code:
     -vf yadif=mode=1,scale=w=1920:h=1080:in_color_matrix=bt601:out_color_matrix=bt709,tinterlace=4
    and if it's too soft, you can use sws flags to change to lanczos instead of bicubic scaling algorithm , but it's sometimes not a good idea depending on content/noise and "sharper" is sometimes problematic for interlace

    Code:
     -vf yadif=mode=1,scale=w=1920:h=1080:in_color_matrix=bt601:out_color_matrix=bt709:sws_flags=lanczos,tinterlace=4
    -vf interlace applies lowpass filter by default, -vf tinterlace does not
    Last edited by poisondeathray; 29th Jan 2017 at 19:28.
    Quote Quote  
  8. thanks guys, I appreciate it. using interl=1 will be just fine for what I need it for. Normally yes, I always use avisynth, qtgmc etc for any project that needs the utmost quality. This is just for a batch encoding tool that may on the rare occasion see an interlaced file that needs to be upscaled....so I'm not too concerned with having the best quality.
    Quote Quote  
  9. Originally Posted by poisondeathray View Post
    Or you can use yadif double rate , resize, tinterlace (or interlace) , colormatrix in a linear filter chain with ffmpeg

    Code:
     -vf yadif=mode=1,scale=w=1920:h=1080:in_color_matrix=bt601:out_color_matrix=bt709,tinterlace=4
    Yes, that's much better:

    Image
    [Attachment 40419 - Click to enlarge]
    Quote Quote  
  10. Originally Posted by nesburf View Post
    Any reason to get rid of the frame rate arguments? The scaling worked by the way, thanks!

    You can use alternate resizer - 'zscale' - should provide better quality than native ffmpeg.
    You should avoid specifying incorrect frame rate - that's why you should rid frame rate argument 29.97 is wrong framerate, correct one is 30000/1001 (approx 29.97002997002997..002997..002997..)
    Quote Quote  
  11. so using -r 30000/1001 would be more accurate.
    Quote Quote  
  12. Originally Posted by nesburf View Post
    so using -r 30000/1001 would be more accurate.
    Correct and true.
    Quote Quote  
  13. Unless the source isn't 60000/1001 fps.
    Quote Quote  



Similar Threads

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