LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-20-2021, 08:26 AM   #1
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Question ffmpeg re-scaling results in a ripple effect


I'm re-encoding and resizing a few videos from .mpg to .mp4 using ffmpeg, from 704x576 to 640x524
Code:
-vf "scale=640:-1"
this results in a rippling effect on any rapid movement in that part of the video.


Removing the -vf scale switch and the mp4 re-encoded file is fine.
Anyone have a few pointers as to what I should look for, ddg hasn't uncovered any clues.
 
Old 02-21-2021, 01:19 AM   #2
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
I have difficulty understanding "ripple effect", a sample video would be nice.
Transcoding is never without pitfalls and requires careful adjustment for each type of video (codec, compression/bitrate, resolution).
I can imagine all sorts of artifacts popping up, esp. with relatively small (704 => 640) changes.

Meanwhile:
https://trac.ffmpeg.org/wiki/Scaling
 
Old 02-21-2021, 07:08 AM   #3
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Quote:
Originally Posted by ondoho View Post
I have difficulty understanding "ripple effect", a sample video would be nice.
Transcoding is never without pitfalls and requires careful adjustment for each type of video (codec, compression/bitrate, resolution).
I can imagine all sorts of artifacts popping up, esp. with relatively small (704 => 640) changes.

Meanwhile:
https://trac.ffmpeg.org/wiki/Scaling
Cheers,
I'll put together a n example but imagine as the camera pans down say, and a diagonal line will appear as a wavy line as the camera pans, if I don't scale, but simply re-encode at a lower video bitrate (to reduce the size of the video) it's straight line as the camera pans
 
Old 02-21-2021, 07:56 AM   #4
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
I think I found the culprit - I was using a filter to deinterlace the video, I tried a few and they all exhibit this affect
Code:
-vf "scale=640:-1,bwdif"
I also tried
Code:
w3fdif, kerndeint and yadif
They all just produce a different rippling affect. Leaving out the deinterlace filter it's fine but you can see the interlacing.

Or don't scale the video, but use the filter
Code:
-vf bwdif
which works fine

Last edited by GPGAgent; 02-21-2021 at 07:58 AM.
 
Old 02-21-2021, 08:18 AM   #5
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Final bit of this puzzle, the original video has a size of 704x576 - it's a dvd

Now somewhere I think 16 comes into this so I divided 704 by 16 which gives 44

So to halve the size of the video 44 times 8 equals 352, and
Code:
-vf "scale=352:-1,bwdif"
works fine, and so does various other factors of 44, but not all.
 
Old 02-21-2021, 08:42 AM   #6
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
You have not shown what you are doing. What video codec are you using inside of that mp4 container? Both of those ratios are about 1.22:1. Why that ratio, and why 640x524?

Quote:
I'm re-encoding and resizing a few videos from .mpg to .mp4
What kind of video, what kind of audio, how many fps in/out, at what bitrate?

How about:
Code:
ffmpeg -i Input.mpg -c:a aac -b:a 192k -af volume=1.5 -c:v libx264 -crf 18 -preset slow -maxrate 3000k -bufsize 1M -r 24 -s 640x524 Output.mp4
That's aac audio at 192k, volume made a little louder, x264 video using a -crf preset, maxrate of 3000k, a 1MB buffer that allows changing 30 fps to 24, resized to 640x524.
 
Old 02-21-2021, 09:20 AM   #7
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
This is what I use
Code:
ffmpeg -ss 1:29:56 -to 1:34:30 -i VideoIn.mpg  -c:v libx264  -preset veryfast -vf "bwdif"  VideoOut.mp4
The DVD I'm re-encoding is 704x576. it's one of the many official sizes for DVDs or broadcast media and I try to standardise my rips to a width of 640 - no reason why, the height of 524 is calculated by ffmpeg when you use scale=640:-1 - simples
 
  


Reply

Tags
ffmpeg scale rippling



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
The Ripple Ecosystem Evolves Danielisawesome Linux - News 0 03-09-2011 01:41 PM
Ripple efect in fedora bob3dan Fedora 2 03-01-2007 09:04 PM
LXer: Fedora's metrics have ripple effect LXer Syndicated Linux News 0 01-30-2007 06:21 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:35 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration