FAQ  •  Register  •  Login

-sameq Change from v0.6.0.1 to v0.6.1

<<

digitalhack

Serviio newbie

Posts: 5

Joined: Sun Jan 08, 2012 5:38 pm

Location: Rockville, MD

Post Sun Jan 08, 2012 9:34 pm

-sameq Change from v0.6.0.1 to v0.6.1

It appears that between v0.6.0.1 and v0.6.1 the transcoding behavior changed a bit. With v0.6.0.1 when you put a maxVBitrate attribute on it didn't appear to include the -sameq switch on the generated ffmpeg command line. With v0.6.1 it does. This is causing me a problem with transcoding video from a Minolta Dimage Z3. With -sameq the video quality of the file ends up being very degraded but without it the video is fine. With -sameq the bit rate goes from 479 to 614. Without it the bit rate goes from 3826 to 4353. The size of the output file grows about 10 times when -sameq is not specified.

Does anyone know if this change in intentional. If so, is there a way to get the -sameq switch to be left off the ffmpeg command line as before?

Thanks,

digitalhack

Below are the configuration file extract and the two different ffmpeg commands that are generated.

From profile.xml:

<!-- transcode added to support video from Minolta Dimage -->
<Video targetContainer="mpegts" targetACodec="ac3" targetVCodec="mpeg2video" aSamplerate="44100" maxVBitrate="5000">
<Matches container="mp4" vCodec="mjpeg" />
</Video>

From v0.6.0.1 log:

2012-01-07 22:41:34,103 DEBUG [ProcessExecutor] Starting C:\Program Files (x86)\Serviio\bin\\..\lib/ffmpeg.exe -i C:\ServiioLibrary\Video\chesapeake classicalgas.MOV -y -threads 1 -vcodec mpeg2video -b 5000k -maxrate 5000k -bufsize 5097k -r 30 -g 15 -copyts -acodec ac3 -ab 128k -ar 44100 -ac 1 -map 0:0 -map 0:1 -sn -f mpegts C:\Windows\TEMP\Serviio\transcoding-temp-34-MPEG2TS.stf

From v0.6.1 log:

2012-01-08 16:11:37,159 DEBUG [ProcessExecutor] Starting C:\Program Files (x86)\Serviio\bin\\..\lib/ffmpeg.exe -i C:\ServiioLibrary\Video\chesapeake classicalgas.MOV -y -threads 1 -async 1 -vcodec mpeg2video -sameq -b 5000k -maxrate 5000k -bufsize 5000k -r 30 -g 15 -copyts -acodec ac3 -ab 128k -ar 44100 -ac 1 -map 0:0 -map 0:1 -sn -f mpegts C:\Windows\TEMP\Serviio\transcoding-temp-34-MPEG2TS.stf

Below is the format of the source file according to ffmpeg:

Seems stream 0 codec frame rate differs from container frame rate: 600.00 (600/1) -> 30.00 (30/1)
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\ServiioLibrary\Video\chesapeake classicalgas.MOV':
Metadata:
creation_time : 2008-06-22 14:11:44 Duration: 00:01:31.90, start: 0.000000, bitrate: 8577 kb/s
Stream #0:0(eng): Video: mjpeg (jpeg / 0x6765706A), yuvj422p, 640x480, 8381kb/s, 30 fps, 30 tbr, 600 tbn, 600 tbc
Metadata:
creation_time : 2008-06-22 14:11:44
handler_name :
Stream #0:1(eng): Audio: pcm_s16be (twos / 0x736F7774), 7840 Hz, 1 channels, s16, 125 kb/s
Metadata:
creation_time : 2008-06-22 14:11:44
handler_name :
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Sun Jan 08, 2012 11:43 pm

Re: -sameq Change from v0.6.0.1 to v0.6.1

yes, it is intentional. without sameq it produced dodgy output quality-wise with maxrate. you can see the q parameter when transcoding goes to high numbers (like 30) which means the quality suffers (the lower the better). You should see that when using sameq the q value stays at 1 and only increases once the rate boundary is hit. I think this is the correct behaviour.

You can also disable sameq in the console (Generate best video quality on Transcoding tab), it'll use -qscale 3.0 instead of sameq, which will keep the q value at 3 - still produce decent quality but utilizing less CPU.
<<

digitalhack

Serviio newbie

Posts: 5

Joined: Sun Jan 08, 2012 5:38 pm

Location: Rockville, MD

Post Mon Jan 09, 2012 2:42 am

Re: -sameq Change from v0.6.0.1 to v0.6.1

Thanks.

The behavior you describe makes sense but the desired end result isn't what is happens with these files. If you check out the attached file it is a log of two manual runs of ffmpeg. The first one has the -sameq and q is equal to 13. The second one doesn't have -sameq and q is mostly set to 2 with the occasional 1.6. The quality of the second file is much better than the first.

Another thing in the logs is that there are some error messages that appear in the conversions. The only one that looks like it is generated based on the serviio command line used for ffmpeg is that ffmpeg complains that -b is ambiguous. It needs to be either -b:a or -b:v. I think based on how it is being used it needs to be -b:v.
Attachments
Convert.log
Log of two ffmpeg conversions
(13.89 KiB) Downloaded 455 times
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Mon Jan 09, 2012 10:24 am

Re: -sameq Change from v0.6.0.1 to v0.6.1

I think you're right. It looks like -b and -qscale/-sameq are mutually exclusive - I'll remove the -sameq parameter for the next patch version.
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Mon Jan 09, 2012 12:43 pm

Re: -sameq Change from v0.6.0.1 to v0.6.1

zip wrote:I think you're right. It looks like -b and -qscale/-sameq are mutually exclusive - I'll remove the -sameq parameter for the next patch version.

There is no reference to the "-sameq" option in the ffmpeg documentation.
You probably have to change to -b:v option to remove the ffmepg message :
"Please use -b:a or -b:v, -b is ambiguous"

and what about this message on log ?
"[mpeg2video @ 02bc7da0] impossible bitrate constraints, this will fail"

EDIT:libavcodec src:
if (avctx->rc_max_rate &&
00417 avctx->rc_max_rate == avctx->bit_rate &&
00418 avctx->rc_max_rate != avctx->rc_min_rate) {
00419 av_log(avctx, AV_LOG_INFO,
00420 "impossible bitrate constraints, this will fail\n");
00421 }


EDIT2: it seems that when you use -maxrate option (with -bufsize option) like this : -maxrate 30000k -bufsize 30000k
it will transcode with a CBR, so is recommended to also add -minrate option equal to -maxrate option value.(to be confirmed)
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator
<<

digitalhack

Serviio newbie

Posts: 5

Joined: Sun Jan 08, 2012 5:38 pm

Location: Rockville, MD

Post Tue Jan 10, 2012 2:36 am

Re: -sameq Change from v0.6.0.1 to v0.6.1

For what it is worth...

I put together a small wrapper around ffmpeg. The wrapper drops the -sameq switch when -b was found and changes -b to -b:v. These changes solve the problems with the transcoded video. I plan to use this until the changes make it into a patch.

Thanks to all for the help,

digitalhack

I added the following line to ServiioService.exe.vmoptions:

  Code:
-Dffmpeg.location="c:\perl\bin\perl.exe c:\serviiolibrary\serviio-ffmpeg.pl"


serviio-ffmpeg.pl contains the following:

  Code:
use strict;

my $args = '';

foreach my $arg (@ARGV) {
  $args = $args . "\"$arg\" ";
}

if ($args =~ /^(.*)\s\"\-b\"\s(.*)$/) {
  $args = $1 . ' "-b:v" ' . $2;
  $args =~ s/\s\"-sameq\"\s/ /;
}

my $cmd = "\"C:\\Program Files (x86)\\Serviio\\lib\\ffmpeg.exe\" $args";

open(LOGFILE, ">>C:\\Program Files (x86)\\Serviio\\log\\ffmpeg-wrapper.log");

if (system($cmd) != 0) {
  print LOGFILE scalar localtime . " Failed: " . $cmd . " with $?\n";
  close (LOGFILE);
  die "Failed\n";
  } else {
  print LOGFILE scalar localtime . " Success: " . $cmd . "\n";
  close (LOGFILE);
}
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Tue Jan 10, 2012 10:25 am

Re: -sameq Change from v0.6.0.1 to v0.6.1

digitalhack wrote:I put together a small wrapper around ffmpeg.

Thanks for that tips, I modify the perl script to include the "Aspect Ratio fixing" workaround:
I add another test like this on your script.
  Code:
if ($args =~ /^(.*)\s\"mpeg2video\"\s(.*)$/) {
  $args = $1 . ' "mpeg2video" "-vf" "pad=max(iw\,ih*16/9):max(ih\,iw/16*9):(ow-iw)/2:(oh-ih)/2:blue,setdar=4:3" ' . $2;
}
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator
<<

Illico

User avatar

DLNA master

Posts: 4646

Joined: Fri Jul 23, 2010 8:08 am

Location: France

Post Tue Apr 24, 2012 8:54 am

Re: -sameq Change from v0.6.0.1 to v0.6.1

zip wrote:I think you're right. It looks like -b and -qscale/-sameq are mutually exclusive - I'll remove the -sameq parameter for the next patch version.


Not sure it was a good idea to remove -qscale/-sameq option, in fact when maxVBitrate is used on profile, ffmpeg command line used "-b:v", "maxrate=" and "bufsize=" options.
But for example, if you set maxVBitrate=10000, -b:v 10000k -maxrate=10000k, it seems that become a "Constant Video Bitrate" at 10Mbps stream not a "Clipped Video Bitrate" !!

Original file
I try with BigBuckBunny-DivXPlusHD.mkv sample file, with bitrateviewer => average 6Mbps with 21Mbps peak
BigBuckBunny-DivXPlusHD.mkv.jpg
BigBuckBunny-DivXPlusHD.mkv.jpg (38.3 KiB) Viewed 9088 times


Transcoded in mpeg2video :

with -sameq only => average 15Mbps with 64Mbps peak !!! not supported by devices
toto_sameq.ts.jpg
toto_sameq.ts.jpg (33.91 KiB) Viewed 9088 times


with -b:v 10000k -maxrate 10000k -bufsize 10000k => average 9Mbps with 18Mbps peak , looks like a constant bitrate video stream
toto_bv_10k.ts.jpg
toto_bv_10k.ts.jpg (36.56 KiB) Viewed 9088 times


with -sameq -b:v 17000k -maxrate 17000k -bufsize 17000k => average 11Mbps with 30Mbps peak, looks like a clipped bitrate video stream but still have high peak birate
toto_sameq_maxrate.ts.jpg
toto_sameq_maxrate.ts.jpg (37.17 KiB) Viewed 9088 times


Don't know what is the solution...
Illico
Sony 2010 KDL-46EX501 | BDP-S373 | SMP-N100 | Windows 8-i7 | Network DD HD-CE1.5TLU2 | Livebox2-UHD86 | ServiiDroid | ServiiGo | BubbleUPnP
Serviio beta tester - Moderator
<<

zip

User avatar

Serviio developer / Site Admin

Posts: 17212

Joined: Sat Oct 24, 2009 12:24 pm

Location: London, UK

Post Thu Apr 26, 2012 4:48 pm

Re: -sameq Change from v0.6.0.1 to v0.6.1

try to play with bufsize, I think that made some difference. It's more or less contant bitrate, yes. When FFmpeg works you can see the changing q attribute, the higher the more compression to fit into the max bitrate value.

Return to Transcoding

Who is online

Users browsing this forum: No registered users and 10 guests

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