Closed (fixed)
Project:
Video
Version:
7.x-2.x-dev
Component:
General
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
9 Apr 2013 at 09:25 UTC
Updated:
17 Apr 2017 at 20:39 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
Jorrit commentedIt seems that the aspect mode setting isn't passed to FFmpeg so that setting doesn't change the video at all. I will look into a fix, but it seems it will not be easy to add it.
Comment #2
Digitalier commentedI could really do with getting this working. Is there anything I can do to help?
Comment #3
Jorrit commentedPlease try the next 7.x-2.x-dev release.
Comment #4
Jorrit commentedThe changes are also in the 7.x-2.10 release that I just made.
Comment #5
Digitalier commentedNot quite right - I converted a 720x576 (4:3) video to 854x480 (16:9) using a preset with "Pad" for the aspect mode and the resulting video has some left/right padding added to it but not enough and picture seem slightly stretched horizontally - it comes out at 854x525 which is not 16:9.
I've attached copies of my TranscoderAbstractionFactoryFfmpeg.inc and phpvideotoolkit.php5.php which I believe add the padding correctly based on the calculation methods below. The files are from a previous dev version of the module but I hope this helps.
OW = Width of original uploaded video (must be integer)
OH = Height of original uploaded video (must be integer)
SAR = Source Aspect Ratio = OW/OH (floating number)
DW = Width of destination (Preset) Output video (must be integer)
DH = Height of destination (Preset) Output video (must be integer)
DAR = Destination Aspect Ratio = DW/DH (floating number)
STEP 1: Calculate SAR & DAR
SAR = OW / OH
DAR = DW / DH
STEP 2: SAR and DAR are the same
If SAR = DAR (i.e. source and output video have the same aspect ratio)
Then NO –vf parameter is required and using the existing –s parameter generated by the module.
STEP 3: SAR is smaller than DAR
IF SAR < DAR ( i.e. going from SD to HD, therefore left and right pad is required)
Then
First we scale the original video – height is the determining factor
Syntax for scale is WIDTHxHEIGHT and WIDTH and HEIGTH must both be whole integers.
SCALE = round(DH*SAR) .’x’. DH
Then we add padding
Syntax for pad is A:B:C:D where A,B,C and D must all be whole integers.
PAD = DW .’:’. DH .’:’. floor[ (DW-OW) / 2 ] .’:’. floor[ (DH-OH)/2 ]
Construct the –vf parameter:
-vf “scale=SCALE,pad=PAD,setdar=DAR”
Note that setdar accepts a floating point string.
Finally, stop –s parameter from being added
suppress the module from adding the –s paratmeter.
STEP 3: SAR is larger than DAR
IF SAR > DAR ( i.e. going from HD to Cinematic, therefore top and bottom pad is required)
Then
First we scale the original video – width is the determining factor
Syntax for scale is WIDTHxHEIGHT and WIDTH and HEIGTH must both be whole integers.
SCALE = DW .’x’. round(DW / SAR)
Then we add padding
Syntax for pad is A:B:C:D where A,B,C and D must all be whole integers.
PAD = DW .’:’. DH .’:’. floor[ (DW-OW) / 2 ] .’:’. floor[ (DH-OH)/2 ]
Construct the –vf parameter:
-vf “scale=SCALE,pad=PAD,setdar=DAR”
Note that setdar accepts a floating point string.
Finally, stop –s parameter from being added
suppress the module from adding the –s paratmeter.
Comment #6
Digitalier commentedI am still having issues with converting a 720x576 video to 640x360 (16:9) format using the "Pad" aspect mode. I compared the output with videos converted using Adobe Media Encoder and it seems some stretching is creeping in.
Here's my modified code for TranscoderAbstractionFactoryFfmpeg.inc - It solves the the issue going from SD to Widescreen but haven't had a chance to test the other way around. Also fixed the order of the filters so the video is scaled and then padded and also added parameter to set DAR.
Comment #7
Digitalier commentedThere was a slight issue with -ve padding when Source Aspect Ratio was greater than Target Aspect Ratio. Here's the patch to fix the stretching issue and set the correct DAR when using the "Pad" aspect mode setting. Would be good to get feedback.
Comment #8
Digitalier commentedJust to confirm the issue:
When I convert a 720x576 video to 640x360 (16:9) widescreen video using the "Pad" aspectmode setting:
vf part of the command line generated by the stock dev version is:
-vf 'pad=810:576:45:0,scale=640:360'
First off, it is trying to pad the video to 16:9 and then scale it to the required 640x360 dimensions, but it should be the other way around - scale it (keeping source aspect ratio) and then pad it to required target aspect ratio.
Next, the calculated padding of (810:576:45:0) is not correct (not 16:9)
So the patch fixes two things:
1. Correct order of scale and then pad
2. Correct calculation of padding
3. Setting the DAR (aspect ratio) to keep things clean
Comment #9
Jorrit commentedThanks for the patch and my apologies that I did not respond earlier.
You have many lines of commented code in your patch. Can you clean that up?
Comment #10
Jorrit commentedComment #11
Digitalier commentedYep. Patch for "7.x-2.10+6-dev" version attached.
Comment #12
Digitalier commentedForgot to update Issue status. Patch for "7.x-2.10+6-dev" version attached.
Let me know if it works for you.
Comment #13
hypertext200