Page 1 of 2
Aspect Ratio, Transcoded Files

Posted:
Sun Feb 19, 2012 8:47 pm
by PMI
I downloaded a few samples of 1080p files from one of the websites linked in the Serviio forum, and they play with the wrong aspect ratio.
http://tomtom2k5.free.fr/mkv/1080p/Only happens when
transcoded 2.40:1 files are played. When played with
no transcoding, aspect ratio is correct.
Usually I can correct this by changing the aspect ratio of transcoded files at the TV by selecting one of the alternate formats from the remote, but not on any of these 1080p samples. The video is squashed horizontally and plays as if the codes for anamorpic video were missing.
Any ideas?
Re: Aspect Ratio, Transcoded Files

Posted:
Mon Feb 20, 2012 8:54 am
by Illico
I suppose you use a Panasonic device with transcoding ?
Same issue with Sony Bravia device :
viewtopic.php?f=11&t=2956Ticket opened :
https://bitbucket.org/xnejp03/serviio/i ... proper-parFor me the issue is that file is not transcoded with the correct PAR.
Re: Aspect Ratio, Transcoded Files

Posted:
Mon Feb 20, 2012 3:05 pm
by PMI
Illico wrote:I suppose you use a Panasonic device with transcoding ?
Correct.
I seem to be able to fix by changing the playback aspect ratio of files smaller than 1080p while playing, but NOT 1080pfiles.
I will read that thread later today, thanks.
Illico wrote:For me the issue is that file is not transcoded with the correct PAR.
How can I check/verify this? I can run ffmpeg from a command line window with the same options, and create the cropped mpeg-ts file (I mean, one that is not in the temp directory), but then what? In other words, where do I look to see if the aspect ratio is correct in the file?
Re: Aspect Ratio, Transcoded Files

Posted:
Mon Feb 20, 2012 4:50 pm
by Illico
Could you provide the ffmpeg command line used when you transcode a mkv 1080p file? (check on detailed logging)
Re: Aspect Ratio, Transcoded Files

Posted:
Mon Feb 20, 2012 9:15 pm
by PMI
Illico wrote:Could you provide the ffmpeg command line used when you transcode a mkv 1080p file? (check on detailed logging)
I assume you mean from the log, not when I run the command manually from the command line...
Starting C:\Program Files (x86)\Serviio\bin\\..\lib/ffmpeg.exe -i I:\DVD_Video\Samples\Ocean's.Twelve.HDDVD.1080p.x264.AC3.sample-AE.mkv -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts C:\Windows\TEMP\Serviio\transcoding-temp-3263-MPEG2TS.stf
Explanation (perhaps not necessary, but for anyone else reading):
The file only needs transcoding, b/c the number of reference frames was set too high during encoding.
Otherwise, 1080p video would stream & play fine without transcoding if # of ref frames is set to something sane.
This can be demonstrated by re-encoding same video with Handbrake and default settings, which result in 4 ref frames, and a video which plays with no transcoding. (I say "re-encode" to distinguish from "transcode" by ffmpeg in serviio)
High # of ref. frames -> high memory requirement to buffer frames at player -> video becomes jerky (stutters) or skips frames outright. At the same time as memory requirement increases, Level becomes high, so this is used to trigger transcoding (not 100% reliable, but close).
The rule in the device profile from profiles.xml which triggers transcoding of this file:
<!-- Transcode h264 videos with profile level > 4.2 to mpegts with mpeg2video and ac3 audio -->
<!-- (attempt to avoid video "stuttering" due to memory limit at higher ref frame settings) -->
<Video targetContainer="mpegts" targetVCodec="mpeg2video" targetACodec="ac3">
<Matches container="matroska" vCodec="h264" profile="high" levelGreaterThan="4.2" />
....
and this is a bigger section of the log file:
Re: Aspect Ratio, Transcoded Files

Posted:
Tue Feb 21, 2012 8:06 am
by Illico
Could you try this in local windows terminal, add the output files in serviio library and check the aspect ratio.
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST0.stf
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST1.stf
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "pad=max(iw,ih*16/9):max(ih,iw/16*9):(ow-iw)/2:(oh-ih)/2:black,setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST2.stf
Re: Aspect Ratio, Transcoded Files

Posted:
Tue Feb 21, 2012 9:59 pm
by PMI
Illico wrote:Could you try this in local windows terminal, add the output files in serviio library and check the aspect ratio.
OK, I will do that later, and post the results tonight (my time). It might help if you told me what this is supposed to do...

?
However, it IS Punchka Day in the Midwest (known to you as Mardi Gras), and although finding a decent crepe on a street corner is all but impossible, consuming a variable quantity of punchkas (sweet dough with even sweeter filling) is considered a religious obligation - by me, at least, along with the inevitable liquid refreshments. So, what I am trying to say is that my own aspect ratio might be a bit skewed by tonight...

Re: Aspect Ratio, Transcoded Files

Posted:
Wed Feb 22, 2012 4:41 am
by PMI
from command line:
I:\DVD_Video\Samples>ffmpeg.exe -i "Oceans.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r
24000/1001 -g 15 -vf "pad=max(iw,ih*16/9):max(ih,iw/16*9):(ow-iw)/2:(oh-ih)/2:black,setdar=4:3" -cop
yts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST2.ts
ffmpeg version 0.9, Copyright (c) 2000-2011 the FFmpeg developers
built on Dec 13 2011 20:46:11 with gcc 4.4.2
configuration: --enable-static --disable-shared --disable-ffplay --disable-ffserver --enable-memal
ign-hack --enable-libmp3lame --enable-librtmp --extra-libs='-lrtmp -lpolarssl -lws2_32 -lwinmm' --ar
ch=x86 --enable-runtime-cpudetect --enable-pthreads --target-os=mingw32 --cross-prefix=i686-mingw32-
--pkg-config=pkg-config
libavutil 51. 32. 0 / 51. 32. 0
libavcodec 53. 42. 0 / 53. 42. 0
libavformat 53. 24. 0 / 53. 24. 0
libavdevice 53. 4. 0 / 53. 4. 0
libavfilter 2. 53. 0 / 2. 53. 0
libswscale 2. 1. 0 / 2. 1. 0
Seems stream 0 codec frame rate differs from container frame rate: 47.95 (5000000/104271) -> 47.92 (
575/12)
Input #0, matroska,webm, from 'Oceans.mkv':
Duration: 00:01:07.09, start: 0.000000, bitrate: 9348 kb/s
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x800, SAR 1:1 DAR 12:5, 23.98 fps, 47.92 tbr,
1k tbn, 47.95 tbc (default)
Metadata:
title : Ocean's.Twelve.HDDVD.1080p.x264.12039kbps-AE.mkv
Stream #0:1(eng): Audio: ac3, 48000 Hz, 5.1(side), s16, 640 kb/s (default)
Metadata:
title : Ocean's.Twelve.HDDVD.AC3.640kbps-AE.mkv
[buffer @ 013fff80] w:1920 h:800 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
No such filter: 'ih*16/9):max(ih'
Error opening filters!
Re: Aspect Ratio, Transcoded Files

Posted:
Wed Feb 22, 2012 8:37 am
by Illico
PMI wrote:[buffer @ 013fff80] w:1920 h:800 pixfmt:yuv420p tb:1/1000000 sar:1/1 sws_param:
No such filter: 'ih*16/9):max(ih'
Error opening filters!
Oops.
Could you try this:
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "pad=max(iw\,ih*16/9):max(ih\,iw/16*9):(ow-iw)/2:(oh-ih)/2:black,setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST2.stf
Re: Aspect Ratio, Transcoded Files

Posted:
Wed Feb 22, 2012 2:50 pm
by PMI
Ok, will do this later today.
I already tried the method you suggest in the thread you posted above (padding in ffmpeg). Is this different?
What I mean, padding like you showed how to do in your earlier thread keeps the video from being stretched vertically - BUT - it does not return the video to the correct aspect ratio. So, if you tell me what you are attempting to do, I know what to pay attention to when I run your test.
P.
Re: Aspect Ratio, Transcoded Files

Posted:
Wed Feb 22, 2012 4:43 pm
by Illico
So:
Could you try this in local windows terminal, add the output files in serviio library and check the aspect ratio.
TEST0 : This is how Serviio/FFmpeg transcode with the current version
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST0.stf
TEST1 : This option change the DAR=4:3 of the resulting video, you can also try with 16:9 to see if that change the vertical aspect ratio on your Panasonic TV
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST1.stf
TEST2 : This option (be carefull with the syntaxe '\' before ',' ) add black box padding to match a 16/9 ratio and change DAR=4:3, check on your TV if that change the vertical aspect ratio
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "pad=max(iw\,ih*16/9):max(ih\,iw/16*9):(ow-iw)/2:(oh-ih)/2:black,setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST2.stf
Re: Aspect Ratio, Transcoded Files

Posted:
Wed Feb 22, 2012 5:11 pm
by PMI
Ok, I will do this.
(And, I forgot to mention, when I tried ffmpeg to pad on top and bottom, like you showed in the other thread, I also got the missing (cropped?) pixels on the sides, like you say there.)
Later,
P.
Re: Aspect Ratio, Transcoded Files

Posted:
Wed Feb 22, 2012 7:33 pm
by PMI
Ok, I tried this quickly, so you have an answer today:
Illico wrote:So:
Could you try this in local windows terminal, add the output files in serviio library and check the aspect ratio.
Yes, done.
Illico wrote:TEST0 : This is how Serviio/FFmpeg transcode with the current version
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST0.stf
Yes, the same.
Illico wrote:TEST1 : This option change the DAR=4:3 of the resulting video, you can also try with 16:9 to see if that change the vertical aspect ratio on your Panasonic TV
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST1.stf
With dar=4:3, same, no change compared to test 0. With DAR=16:9, better, but still wrong. (same vertical size, but greater horizontal size, AR as defined by H:V is very close to 16:9, but NOT 12:5 (2.40:1), which would be the correct aspect ratio).
Illico wrote:TEST2 : This option (be carefull with the syntaxe '\' before ',' ) add black box padding to match a 16/9 ratio and change DAR=4:3, check on your TV if that change the vertical aspect ratio
ffmpeg.exe -i "YOUR.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "pad=max(iw\,ih*16/9):max(ih\,iw/16*9):(ow-iw)/2:(oh-ih)/2:black,setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST2.stf
Yes, used syntax exactly as you wrote, only changed file names.
When played in original format, the Test3 video is about the same as Test1 with dar set to 16:9. Because it is padded (black bars top and bottom), video can be adjusted on the TV to fit the screen (the padded video is about 16:9 with the bars added). But, edges are still cut off (sides and top), and picture quality is less than expected from 1080p.
P.
Re: Aspect Ratio, Transcoded Files

Posted:
Thu Feb 23, 2012 10:28 am
by Illico
Original MKV HD Streamhttp://tomtom2k5.free.fr/mkv/1080p/Ocea ... ple-AE.mkvInput #0, matroska,webm, from 'Ocean.mkv':
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x800, SAR 1:1 DAR 12:5, 23.98 fps, 47.92 tbr, 1k tbn, 47.95 tbc (default)The original DAR 12:5 is not conventional, I mean 4:3 or 16:9
=> But when delivered in native format,
H264 video displayed with
GOOD display ratio on TV
Serviio current transcodingffmpeg.exe -i "Ocean.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST0.tsOutput #0, mpegts, to 'MPEG2TS_TEST0.ts':
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x800 [SAR 1:1 DAR 12:5], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)Current Serviio version keep the source resolution DAR 12:5
=> But
MPEG2VIDEO video displayed with
BAD display ratio on TV
Custom change DAR=4:3ffmpeg.exe -i "Ocean.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST1.tsOutput #0, mpegts, to 'MPEG2TS_TEST1.ts':
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x800 [SAR 5:9 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)With custom
-vf "setdar=4:3" option, DAR will be change to 4:3 resulting SAR=5.9 => same
bad display ratio on TV
Custom Add padding and change DAR=4:3ffmpeg.exe -i "Ocean.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "pad=max(iw\,ih*16/9):max(ih\,iw/16*9):(ow-iw)/2:(oh-ih)/2:black,setdar=4:3" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST2.tsOutput #0, mpegts, to 'MPEG2TS_TEST2.ts':
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x1080 [SAR 3:4 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)
With custom
-vf "pad=max(iw\,ih*16/9):max(ih\,iw/16*9):(ow-iw)/2:(oh-ih)/2:black,setdar=4:3" option, Black padding will be added to match a 16:9 resolution and DAR will be change => same
bad display ratio on TV.
Another testCould you try only add padding to match 16:9 aspect ratio:ffmpeg.exe -i "Ocean.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "pad=max(iw\,ih*16/9):max(ih\,iw/16*9):(ow-iw)/2:(oh-ih)/2:black" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST3.tsOutput #0, mpegts, to 'MPEG2TS_TEST3.ts':
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)
Re: Aspect Ratio, Transcoded Files

Posted:
Thu Feb 23, 2012 2:07 pm
by PMI
The original file, as I downloaded it, plays with the correct ratio, and all pixels showing.
This IS conventional for at least SOME files made from DVD.
The video is "cropped" to this to eliminate the black bars.
(not my idea, just the way it is in some s/w)
Yes, I will try it later today.
Re: Aspect Ratio, Transcoded Files

Posted:
Thu Feb 23, 2012 3:00 pm
by Illico
PMI wrote:The original file, as I downloaded it, plays with the correct ratio, and all pixels showing.
This IS conventional for at least SOME files made from DVD.
The video is "cropped" to this to eliminate the black bars.
(not my idea, just the way it is in some s/w)
Yes you are right about "conventional" resolution, but I think that MPEG2VIDEO standard is more restricive than H264.
We can see that H264 with 12:5 DAR is supported but not MPEG2VIDEO.
(I could not test on my Sony Bravia 2010, because MKV are not supported, if I get time I could remux this file in m2ts)
Re: Aspect Ratio, Transcoded Files

Posted:
Thu Feb 23, 2012 6:59 pm
by PMI
Illico wrote:PMI wrote:We can see that H264 with 12:5 DAR is supported but not MPEG2VIDEO.

that explains a lot

Re: Aspect Ratio, Transcoded Files

Posted:
Thu Feb 23, 2012 10:09 pm
by PMI
Another test
Could you try only add padding to match 16:9 aspect ratio:
ffmpeg.exe -i "Ocean.mkv" -y -threads 2 -async 1 -vcodec mpeg2video -sameq -r 24000/1001 -g 15 -vf "pad=max(iw\,ih*16/9):max(ih\,iw/16*9):(ow-iw)/2:(oh-ih)/2:black" -copyts -acodec copy -map 0:0 -map 0:1 -sn -f mpegts MPEG2TS_TEST3.ts
Output #0, mpegts, to 'MPEG2TS_TEST3.ts':
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)
Test 3 (MPEG2TS_TEST3.ts) plays exactly the same as Test2.
I know the files are not identical, or a mistake, b/c I compare in VLC player first, before I use the Viera set.
In other words, in VLC player there is a difference between the aspect ratio for Test 2 and Test 3. On the Viera set, there is no difference. I do not understand this completely, I also did the same with Test0, 1, and 2. In VLC player, the aspect ratio of the video is what I think it should be (after reading your explanation). But on the Viera set, Test1 is identical to Test0, and Test3 is identical to Test2...
So, the main difference is that the video which is padded with black bars can be adjusted to play with the correct aspect ratio using the controls on the TV, but with some pixels lost on the sides, and some loss of quality.
Re: Aspect Ratio, Transcoded Files

Posted:
Fri Feb 24, 2012 8:26 am
by Illico
Original MKV HD Stream "Ocean.mkv"
Stream #0:0(eng): Video: h264 (High), yuv420p, 1920x800, SAR 1:1 DAR 12:5, 23.98 fps, 47.92 tbr, 1k tbn, 47.95 tbc (default) => GOOD
Serviio current transcoding MPEG2TS_TEST0.ts
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x800 [SAR 1:1 DAR 12:5], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default) => BAD
Custom change DAR=4:3 MPEG2TS_TEST1.ts
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x800 [SAR 5:9 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default) => BAD
Custom Add padding and change DAR=4:3 MPEG2TS_TEST2.ts
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x1080 [SAR 3:4 DAR 4:3], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default) => BAD
Custom Add padding to match 16:9 ratio MPEG2TS_TEST3.ts
Stream #0:0(eng): Video: mpeg2video, yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 90k tbn, 23.98 tbc (default)=> BAD
These results make no sense for me !!
The latest TEST3 have to display with good ratio...this is a standard?!
Could you check your Panasonic Options, is there an automatic mode or could your force 4:3 or 16:9? is there an automatic Wide mode ?
Re: Aspect Ratio, Transcoded Files

Posted:
Fri Feb 24, 2012 8:29 am
by Illico
PMI wrote:Test1 is identical to Test0, and Test3 is identical to Test2.
Don't know if we can conclude, but probably DAR was ignored and only resolution is taken into account Test0=Test1 = 1920x800, Test3=Test2=1920x1080