FAQ  •  Register  •  Login

Erroneous parameters generated when using DAR=16:9

<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Fri Sep 21, 2012 7:31 pm

Erroneous parameters generated when using DAR=16:9

I am attempting to force mediabrowser to use a dar of 16:9 when playing any mpegts file containing an avc video stream with high profile.

The ffmpeg for the file is
Input #0, mpegts, from 'http://77.51.249.16:8032':
Duration: N/A, start: 48526.849867, bitrate: 96 kb/s
Program 1
Stream #0:0[0x44](rus): Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, mono,
s16, 96 kb/s
Stream #0:1[0x45]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 704
x576 [SAR 12:11 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc

To accomplish this I set the following rule in the mediabrowser online transcoding profile. I set aBitrate to 256 in order to verify when the rule was being applied.

<Video targetContainer="flv" targetVCodec="flv" targetACodec="mp3" DAR="16:9" forceStereo="true" aBitrate="256" aSamplerate="44100">
<Matches container="mpegts" vCodec="h264" profile="high"/>
</Video>

I expected the resulting generated ffmpeg command to contain the following -vf parameter which will cause the mediabrowser to play it as 1024x576 =16:9 as I show later.
-vf setdar=16:9,scale=iw*sar:ih,setsar=1

Instead the generated Serviio ffmpeg command is:
C:\Program Files\Serviio\bin\\..\lib/ffmpeg.exe -i http://77.51.249.16:8032 -y -copyts -c:v flv -sameq -vf scale=1024:838,setsar=1,pad=1024:576:0:131:black,setdar=4:3 -r 25 -g 15 -c:a libmp3lame -b:a 256k -ar 44100 -ac 1 -map 0:1 -map 0:0 -sn -f flv pipe:

which opens the correct 1024x576 mediabrowser window but the transcode fails with return code 1. When run from the command line it also fails with the following errors:
C:\Users\John>ffmpeg -i http://77.51.249.16:8032 -y -copyts -c:v flv -sameq -vf
scale=1024:819,setsar=1,pad=1024:576:0:121:black,setdar=4:3 -r 25 -g 15 -c:a lib
mp3lame -b:a 256k -ar 44100 -ac 1 -map 0:1 -map 0:0 -sn -f flv D:/flv.flv
ffmpeg version N-42368-gbf53863 Copyright (c) 2000-2012 the FFmpeg developers
...
Input #0, mpegts, from 'http://77.51.249.16:8032':
Duration: N/A, start: 9881.758711, bitrate: 94 kb/s
Program 1
Stream #0:0[0x44](rus): Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, mono,
s16, 94 kb/s
Stream #0:1[0x45]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 704
x576 [SAR 12:11 DAR 4:3], 25 fps, 25 tbr, 90k tbn, 50 tbc
[graph 0 input from stream 0:1 @ 054F27C0] w:704 h:576 pixfmt:yuv420p tb:1/90000
fr:25/1 sar:12/11 sws_param:flags=2
[output stream 0:0 @ 01335360] No opaque field provided
[Parsed_scale_0 @ 054E6B20] w:704 h:576 fmt:yuv420p sar:12/11 -> w:1024 h:819 fm
t:yuv420p sar:273/256 flags:0x4
[Parsed_pad_2 @ 05500200] Input area 0:120:1024:939 not within the padded area 0
:0:1024:576 or zero-sized
[Parsed_setsar_1 @ 012B4200] Failed to configure input pad on Parsed_pad_2
Error opening filters!

Using the command ffplay -i http://77.51.249.16:8032 -vf setdar=16:9,scale=iw*sar:ih,setsar=1 plays it correctly as 1024x576 16:9 per the following ffplay/ffmpeg output, and also by using my ffmpeg.bat to force the generated ffmpeg command to the expected -vf setdar=16:9,scale=iw*sar:ih,setsar=1 and remove the erroneous ",pad=1024:576:0:121:black,setdar=4:3" string results in the following Serviio command which allows the mediabrowser to open with scale 1024:576 and play the video 16:9 as expected.
[quoteInput #0, mpegts, from 'http://77.51.249.16:8032':
Duration: N/A, start: 14843.303478, bitrate: 83 kb/s
Program 1
Stream #0:0[0x44](rus): Audio: aac ([15][0][0][0] / 0x000F), 48000 Hz, mono,
s16, 83 kb/s
Stream #0:1[0x45]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 704
x576 [SAR 12:11 DAR 4:3], 25.62 fps, 25 tbr, 90k tbn, 50 tbc
[src @ 0688af80] w:704 h:576 pixfmt:yuv420p tb:1/90000 sar:12/11 sws_param:
[Parsed_setdar_0 @ 03edd320] a:16/9
[Parsed_setsar_2 @ 03e3ff00] a:1/1
[Parsed_setdar_0 @ 03edd320] w:704 h:576 -> dar:16/9 sar:16/11
[Parsed_scale_1 @ 063d8880] w:704 h:576 fmt:yuv420p sar:16/11 -> w:1024 h:576 fm
t:yuv420p sar:1/1 flags:0x4[/quote]
ffmpeg.exe" -i http://77.51.249.16:8032 -y -copyts -c:v flv -sameq -vf setdar=16:9,scale=iw*sar:ih,setsar=1 -r 25 -g 15 -c:a libmp3lame -b:a 256k -ar 44100 -ac 1 -map 0:1 -map 0:0 -sn -f flv pipe:

So I conclude that the generated ffmpeg command for DAR=16:9 is incorrect. While the mediabrowser window size is the correct, the ffmpeg -vf values are incorrect and the pad parameters need to be removed.
Please advise if this warrants a ticket.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17215

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sat Sep 22, 2012 1:16 pm

Re: Erroneous parameters generated when using DAR=16:9

Thanks. There is a bug but the padding should still be there, like:

  Code:
ffmpeg.exe -i http://77.51.249.16:8032 -y -copyts -c:v flv -sameq -vf scale=768:576,setsar=1,pad=1024:576:128:0:black,setdar=4:3 -r 25 -g 15 -c:a libmp3lame -b:a 256k -ar 44100 -ac 1 -map 0:1 -map 0:0 -sn -f flv d:\testflv.flv


Basically the DAR functionality works by adding padding to the video to make up full 16:9 rectangle, not stretching the video to 16:9 with no padding. This command produces 1024x576 video with padding on the sides, so that the 4:3 video is in the middle of the rectangle.

I have now fixed the code to produce the above command.
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Sat Sep 22, 2012 4:09 pm

Re: Erroneous parameters generated when using DAR=16:9

OK, so your DAR option is only there to prevent some dumb TV's from erroneously stretching a 4:3 video onto a 16:9 screen.

Seems my only option to correct the mediabrowser display of erroneously speced streams like SOPCAST sar=2:3 is to intercept the ffmpeg command and change it.

I attempted to do this using an actual 2:3 SOPCAST live stream as below, but Serviio scaled it up to 1920:1080 per the generated command rather than keeping it in a 1280:720 DAR. Can you explain why?
Input #0, mpegts, from 'http://localhost:8902':
Duration: N/A, start: 94687.458922, bitrate: 96 kb/s
Program 1
Stream #0:0[0x44]: Audio: mp3 ([3][0][0][0] / 0x0003), 44100 Hz, stereo, s16
, 96 kb/s
Stream #0:1[0x45]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 128
0x720 [SAR 2:3 DAR 32:27], 27.19 fps, 25 tbr, 90k tbn, 50 tbc
[src @ 078d2760] w:1280 h:720 pixfmt:yuv420p tb:1/90000 sar:2/3 sws_param:

2012-09-22 12:31:33,392 DEBUG [ProcessExecutor] Starting "C:\Program Files\Serviio\lib\ffmpeg.bat" -i http://localhost:8902 -y -copyts -c:v flv -sameq -vf scale=1920:1080,setsar=1,pad=1920:1080:0:0:black,setdar=4:3 -r 24000/1001 -g 15 -c:a copy -map 0:1 -map 0:0 -sn -f flv pipe:
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Sun Sep 23, 2012 11:48 am

Re: Erroneous parameters generated when using DAR=16:9

OK, I think you get the 1280x720 to 1920x1080 because you first increase the height by 3/2 rather than shrink the width by 2/3, so 720 becomes 1080, but then to get 16:9 you increase the width by 3/2 rather than decrease the height by 2/3, so 1280 becomes 1920. This is inconsistent. Either both steps should change the height or even better both steps should change the width. With this change the mediabrowser will show the proper 1280x720 resolution above its window.
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17215

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sun Sep 23, 2012 12:06 pm

Re: Erroneous parameters generated when using DAR=16:9

You're right. Changed it now to always change the width and keep height the same, unless requested otherwise with maxHeight.
<<

jhb50

DLNA master

Posts: 2843

Joined: Thu Jun 30, 2011 9:32 pm

Post Sun Sep 23, 2012 12:32 pm

Re: Erroneous parameters generated when using DAR=16:9

Cool!

Return to Transcoding

Who is online

Users browsing this forum: No registered users and 29 guests

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.