Page 1 of 2

DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Thu Apr 25, 2013 2:30 pm
by JezzaT
I created a profile to test this
  Code:
      <Profile id="mpeg2DAR" name="mpeg2video 16:9" extendsProfileId="1">
      <Transcoding>
         <Video targetContainer="mpegts" targetVCodec="mpeg2video" targetACodec="ac3" DAR="16:9">
            <Matches container="*" />
         </Video>
      </Transcoding>
      <OnlineTranscoding>
         <Video targetContainer="mpegts" targetVCodec="mpeg2video" targetACodec="ac3">
            <Matches container="*" />
         </Video>
      </OnlineTranscoding>
   </Profile>
And it seems transcoding of some 16:9 videos correctly(I assume) doesn't pad i.e. add something like -vf pad=1280:720:0:96:black,setdar=4:3

These files get padded and end up displaying incorrectly in 4:3(including playing the stf file in VLC)
http://www.demo-world.eu/trailers/redir ... sprite_mix).rar 720x480 (16:9)
http://www.demo-world.eu/trailers/redir ... rience.rar 720x480 (16:9)
http://www.demo-world.eu/trailers/redir ... g_life.rar 720x576 (16:9)
e.g. ffmpeg -y -c:v mpeg2video -qscale:v 1 -vf pad=1024:576:152:0:black,setdar=4:3 -r 25 -g 15 -c:a copy -map 0:0 -map 0:1 -sn -f mpegts C:\Windows\TEMP\Serviio\transcoding-temp-197-mpeg2DAR-ORIGINAL.stf

These file don't get padded and display correctly:
http://tomtom2k5.free.fr/mkv/720p/calif ... le-hdq.mkv 1280x720 (16:9)
http://videos.hd-trailers.net/riddick-f ... r-720p.mp4 1280x720 (16:9)
http://videos.hd-trailers.net/riddick-f ... p-HDTN.mov 640x360 (16:9)
eg ffmpeg -y -c:v mpeg2video -qscale:v 1 -r 24000/1001 -g 15 -c:a copy -map 0:0 -map 0:1 -sn -f mpegts C:\Windows\TEMP\Serviio\transcoding-temp-63-mpeg2DAR-ORIGINAL.stf

It seems me that all 16:9 and lower DAR e.g.14:9 and 4:3 should not be padded but this doesn't seem to be the case. Why is that?

This might be related to this topic: viewtopic.php?f=11&t=2956

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Thu Apr 25, 2013 2:47 pm
by Illico
What is your renderer model ? Sony Bravia ?

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Thu Apr 25, 2013 11:01 pm
by zip
Ok, looks like I've not been taking into account SAR (in this case anamorphic pixels of the DVD content) when comparing DAR. Should be finex in 1.3, hopefully it won't break other stuff. Will need proper testing (Illico ;-) )

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Fri Apr 26, 2013 7:31 am
by Illico
zip wrote:Ok, looks like I've not been taking into account SAR...

Is it a regression ? I thought it was implemented.
I will retry with http://www.demo-world.eu/trailers samples with current version and wait for the next 1.3 version

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Fri Apr 26, 2013 9:13 am
by zip
Not regression. But there was hardly anyone forcing 16:9 on VOB files. The check for if DAR has changed now takes SAR into account.

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Fri Apr 26, 2013 10:16 am
by JezzaT
Another scenario to consider is where the SAR 1:1 and DAR 80:43. which displays with the correct aspect ratio natively on Viera and remuxed on Bravia so also(I think) no need for padding.
http://tomtom2k5.free.fr/mkv/720p/spide ... inners.mkv
  Code:
C:\Program Files (x86)\WinFF\ffmpeg.exe" -threads 4  -y -i "E:\Video\T
est\Trailer\spiderman.2002.720p.bluray.x264.sample-sinners.mkv" 
ffmpeg version N-49757-g969039e Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb  9 2013 20:28:03 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzli
b --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-li
bcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-l
ibopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --e
nable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enabl
e-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxv
id --enable-zlib
  libavutil      52. 17.101 / 52. 17.101
  libavcodec     54. 91.102 / 54. 91.102
  libavformat    54. 62.100 / 54. 62.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 37.101 /  3. 37.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, matroska,webm, from 'E:\Video\Test\Trailer\spiderman.2002.720p.bluray.x264.sample-sinners.
mkv':
  Metadata:
    creation_time   : 2007-09-27 11:42:13
  Duration: 00:01:02.48, start: 0.000000, bitrate: 5489 kb/s
    Stream #0:0(eng): Video: h264 (High), yuv420p, 1280x688, SAR 1:1 DAR 80:43, 23.98 fps, 23.98 tbr
, 1k tbn, 47.95 tbc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 640 kb/s (default)

One of the reasons I'm looking into this is that my Viera doesn't play DTS but remuxing gives this problem with DAR viewtopic.php?f=5&t=5403&start=20 so I transcode the video as well with DAR 16:9.

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Fri Apr 26, 2013 11:21 am
by zip
I'm not sure if it's correct on the TV. It might be a bit off, as it's relatively close to 16/9 but not really.

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Fri Apr 26, 2013 11:28 am
by JezzaT
zip wrote:I'm not sure if it's correct on the TV. It might be a bit off, as it's relatively close to 16/9 but not really.
Your right - just had a closer look and there are small horizontal black bars on Viera both mkv and transcoded and padded - both look the same. Seemed to take up full screen on Bravia though but will have another look.

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Sat Apr 27, 2013 11:39 am
by JezzaT
zip wrote:Ok, looks like I've not been taking into account SAR (in this case anamorphic pixels of the DVD content) when comparing DAR. Should be finex in 1.3, hopefully it won't break other stuff. Will need proper testing (Illico ;-) )
I have a some anamorphic x264 such as
  Code:
C:\Program Files (x86)\WinFF>"C:\Program Files (x86)\WinFF\ffmpeg.exe" -threads 4  -y -i "S:\Videos\
SingleFiles\Movies\AVC\Anamorphic\13th_Warrior.mp4"
ffmpeg version N-49757-g969039e Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb  9 2013 20:28:03 with gcc 4.7.2 (GCC)
  configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzli
b --enable-fontconfig --enable-frei0r --enable-gnutls --enable-libass --enable-libbluray --enable-li
bcaca --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopencore-amrnb --enable-l
ibopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --e
nable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvo-aacenc --enabl
e-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libxavs --enable-libxv
id --enable-zlib
  libavutil      52. 17.101 / 52. 17.101
  libavcodec     54. 91.102 / 54. 91.102
  libavformat    54. 62.100 / 54. 62.100
  libavdevice    54.  3.103 / 54.  3.103
  libavfilter     3. 37.101 /  3. 37.101
  libswscale      2.  2.100 /  2.  2.100
  libswresample   0. 17.102 /  0. 17.102
  libpostproc    52.  2.100 / 52.  2.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\Videos\SingleFiles\Movies\AVC\Anamorphic\13th_Warrior.mp
4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.61.104
  Duration: 01:42:39.49, start: 0.041000, bitrate: 1892 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 714x366 [SAR 32:27 DAR 3808:1
647], 1504 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 384 kb/s
    Metadata:
      handler_name    : SoundHandler
Which currently gets trancsoded like this:
  Code:
-c:v mpeg2video -qscale:v 1 -vf pad=714:402:0:18:black,setdar=4:3 -r 24000/1001 -g 15 -c:a copy -map 0:0 -map 0:1 -sn
which come out very wrong i.e. no letterbox. Will the fix you make likely sort that as well?

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Sat Apr 27, 2013 8:17 pm
by zip
How does it come out? Can you post an image? Or upload the file somewhere for me to test?

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Sun Apr 28, 2013 11:20 am
by JezzaT
zip wrote:How does it come out? Can you post an image? Or upload the file somewhere for me to test?
Sure
13th_Warrior_Orig.jpg
Original
13th_Warrior_Orig.jpg (39.48 KiB) Viewed 15132 times
13th_Warrior cropped.png
After Transcode
13th_Warrior cropped.png (477.99 KiB) Viewed 15132 times

Cropped file
  Code:
[mpegts @ 0226bee0] max_analyze_duration 5000000 reached at 5004000 microseconds
Input #0, mpegts, from '\\JEREMYWHSERVER\Videos\Videos\SingleFiles\Movies\AVC\Anamorphic\13th_Warrio
r cropped.m2ts':
  Duration: 00:04:13.00, start: 1.400000, bitrate: 3114 kb/s
  Program 1
    Metadata:
      service_name    : Service01
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: mpeg2video (Main) ([2][0][0][0] / 0x0002), yuv420p, 714x402 [SAR 268:
357 DAR 4:3], 23.98 fps, 23.98 tbr, 90k tbn, 47.95 tbc
    Stream #0:1[0x101](eng): Audio: ac3 ([129][0][0][0] / 0x0081), 48000 Hz, 5.1(side), fltp, 384 kb


I have a whole bunch of movies that for some reason have the horizontal bars cropped off AND are anamorphic :x

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Sun Apr 28, 2013 5:24 pm
by zip
Could you try the same FFMpeg command with this instead and see how it looks?

  Code:
pad=652:366:31:0:black,setdar=4:3


and also

  Code:
pad=714:402:0:18:black,setdar=4:3


to see which works better

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Mon Apr 29, 2013 9:40 am
by JezzaT
zip wrote:Could you try the same FFMpeg command with this instead and see how it looks?

  Code:
pad=652:366:31:0:black,setdar=4:3
Gave error:
  Code:
S:\Videos\SingleFiles\Movies\AVC\Anamorphic>"C:\Program Files\Serviio\bin\\..\li
b/ffmpeg.exe" -threads auto -i S:\Videos\SingleFiles\Movies\AVC\Anamorphic\13th_
Warrior.mp4 -y -c:v mpeg2video -qscale:v 1 -vf pad=652:366:31:0:black,setdar=4:3
 -r 24000/1001 -g 15 -c:a copy -map 0:0 -map 0:1 -sn -f mpegts "13th_Warrior cro
pped2.m2ts"
ffmpeg version 1.1.1 Copyright (c) 2000-2013 the FFmpeg developers
  built on Feb  5 2013 21:59:54 with gcc 4.7.2 (GCC)
  configuration: --enable-static --disable-shared --disable-ffplay --disable-ffs
erver --enable-memalign-hack --enable-libmp3lame --enable-libass --enable-librtm
p --enable-fontconfig --enable-libfreetype --enable-zlib --extra-libs='-lrtmp -l
polarssl -lws2_32 -lwinmm -lexpat -lfreetype -lfribidi -lz' --arch=x86 --enable-
runtime-cpudetect --enable-pthreads --target-os=mingw32 --cross-prefix=i686-w64-
mingw32- --pkg-config=pkg-config
  libavutil      52. 13.100 / 52. 13.100
  libavcodec     54. 86.100 / 54. 86.100
  libavformat    54. 59.106 / 54. 59.106
  libavdevice    54.  3.102 / 54.  3.102
  libavfilter     3. 32.100 /  3. 32.100
  libswscale      2.  1.103 /  2.  1.103
  libswresample   0. 17.102 /  0. 17.102
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'S:\Videos\SingleFiles\Movies\AVC\Anamor
phic\13th_Warrior.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf54.61.104
  Duration: 01:42:39.49, start: 0.041000, bitrate: 1892 kb/s
    Stream #0:0(eng): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 714x366 [
SAR 32:27 DAR 3808:1647], 1504 kb/s, 23.98 fps, 23.98 tbr, 11988 tbn, 47.95 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(eng): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp,
 384 kb/s
    Metadata:
      handler_name    : SoundHandler
[Parsed_setdar_1 @ 003D9F20] num:den syntax is deprecated, please use num/den or
 named options instead
[Parsed_pad_0 @ 020126A0] Input area 30:0:744:366 not within the padded area 0:0
:652:366 or zero-sized
[graph 0 input from stream 0:0 @ 01EE5D40] Failed to configure input pad on Pars
ed_pad_0
Error opening filters!


zip wrote:and also

  Code:
pad=714:402:0:18:black,setdar=4:3


to see which works better
Second is the same as what the Serviio transcoded.

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Mon Apr 29, 2013 9:56 am
by Illico
Pay attention to quotes ("" ""), that you have to add for -vf option when you use windows terminal command (on serviio log quotes are removed) :

ffmpeg.exe -threads auto -i "INPUT.mp4" -y -c:v mpeg2video -qscale:v 1 -vf "pad=652:366:31:0:black","setdar=4:3" -r 24000/1001 -g 15 -c:a copy -map 0:0 -map 0:1 -sn -f mpegts "OUTPUT.m2ts"

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Mon Apr 29, 2013 10:05 am
by JezzaT
Illico wrote:Pay attention to quotes ("" ""), that you have to add for -vf option when you use windows terminal command (on serviio log quotes are removed) :

ffmpeg.exe -threads auto -i "INPUT.mp4" -y -c:v mpeg2video -qscale:v 1 -vf "pad=652:366:31:0:black","setdar=4:3" -r 24000/1001 -g 15 -c:a copy -map 0:0 -map 0:1 -sn -f mpegts "OUTPUT.m2ts"
Adding quotes made no difference besides the second vf params you gave ran fine without quotes

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Mon Apr 29, 2013 10:46 am
by zip
any chance you can trim your video (10 seconds or so) and upload it somewhere for me to test?

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Mon Apr 29, 2013 11:59 am
by JezzaT
zip wrote:any chance you can trim your video (10 seconds or so) and upload it somewhere for me to test?

See if this works https://www.asuswebstorage.com/navigate/s/85C460D27B084527B57DF17E5591C9E04

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Mon Apr 29, 2013 12:53 pm
by zip
Great, thanks, I'll give it a try

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Mon Apr 29, 2013 8:23 pm
by zip
THis shold fix it

  Code:
pad=714:402:0:18:black,setdar=4:3,setsar=32:27

Re: DAR 16:9 Sometimes pads when video is already 16:9

PostPosted: Tue Apr 30, 2013 10:24 am
by JezzaT
zip wrote:This should fix it

  Code:
pad=714:402:0:18:black,setdar=4:3,setsar=32:27
No, while it displayed OK in VLC with some thin letterbox bars, on the Bravia it cropped the left and right edges of the picture with very thin letterbox bars, on the Viera it displayed the entire picture with thicker black bars but not as thick as when displaying the original mp4.