MPEG-2 encoding problem

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

MPEG-2 encoding problem

Jane
  Hello everyone! I'm encoding video to MPEG-2 using Zeranoe's Windows builds.  The source file is 720p 60fps, progressive. I want to keep high quality and compatibility with DVD standards, so I use:
ffmpeg -hwaccel auto -i "input" -vf scale=ntsc,interlace,fps=fps=29.97 -c:v mpeg2video -q:v 3 -g 15 -mpeg_quant 1 -aspect 16:9 -sc_threshold 40 -bf 2 -intra_vlc 1 -b_stratgey 2 -flags ilme+ildct -maxrate 9M -bufsize 224k -c:a mp2 -b:a 224k "output"
It works all right, but the quality is very low. And I noticed during encoding, qp is floting around 31, what's wrong? After disabled ildct and ilme, the quality is normal. Is the command incorrect?

Due to the lack of information about codec mpeg2 video, I'm not sure about the sc_threshold, b_strategy and the dia_size value. How can i get detailed information?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-2 encoding problem

Moritz Barsnick
Hi Jane,

On Thu, Feb 14, 2019 at 21:14:07 +0800, Jane wrote:
>   Hello everyone! I'm encoding video to MPEG-2 using Zeranoe's Windows builds.  The source file is 720p 60fps, progressive. I want to keep high quality and compatibility with DVD standards, so I use:
> ffmpeg -hwaccel auto -i "input" -vf scale=ntsc,interlace,fps=fps=29.97 -c:v mpeg2video -q:v 3 -g 15 -mpeg_quant 1 -aspect 16:9 -sc_threshold 40 -bf 2 -intra_vlc 1 -b_stratgey 2 -flags ilme+ildct -maxrate 9M -bufsize 224k -c:a mp2 -b:a 224k "output"

For best assistance, we recommend to also post the complete, uncut
output of this ffmpeg command.

Furthermore:
* " -b_stratgey 2" won't be accepted by ffmpeg, there's a typo in
  there.

* ffmpeg provides a set of defaults for maximum DVD compatibility,
  provided by "-target dvd". I wonder whether you really need to fiddle with
  any of the other parameters you provided.

  Here's what this "target" sets (from the source code):
        opt_video_codec(o, "c:v", "mpeg2video");
        opt_audio_codec(o, "c:a", "ac3"); // you can of course set mp2 instead // Moritz
        parse_option(o, "f", "dvd", options);

        parse_option(o, "s", norm == PAL ? "720x576" : "720x480", options);
        parse_option(o, "r", frame_rates[norm], options);
        parse_option(o, "pix_fmt", "yuv420p", options);
        opt_default(NULL, "g", norm == PAL ? "15" : "18");

        opt_default(NULL, "b:v", "6000000");
        opt_default(NULL, "maxrate:v", "9000000");
        opt_default(NULL, "minrate:v", "0"); // 1500000;
        opt_default(NULL, "bufsize:v", "1835008"); // 224*1024*8;

        opt_default(NULL, "packetsize", "2048");  // from www.mpucoder.com: DVD sectors contain 2048 bytes of data, this is also the size of one pack.
        opt_default(NULL, "muxrate", "10080000"); // from mplex project: data_rate = 1260000. mux_rate = data_rate * 8

        opt_default(NULL, "b:a", "448000");
        parse_option(o, "ar", "48000", options);

* As far as I understand, DVD supports progressive content just fine,
  so you can actually avoid interlacing (and requiring those flags).

* "-q:v 3" will result in quite low bandwith, IIRC. This may be one of
  your issues. Note how the defaults above specify a bandwidth, with a
  significant size. (If we saw your output, we could see which
  bandwidth your ffmpeg command resulted in. Probably much too low.)

> After disabled ildct and ilme, the quality is normal. Is the command incorrect?

That's interesting. Possibly, your "-flags" parameter is erasing other
flags. You should try "-flags +ilme+ildct". (Just a hunch, I'm not sure.)

> Due to the lack of information about codec mpeg2 video, I'm not sure
> about the sc_threshold, b_strategy and the dia_size value. How can i
> get detailed information?

Can't you just leave them at their/ffmpeg's defaults, if you don't know
what to do about them? Especially since you don't have knowledge of the
codec and their influences on it?

Cheers,
and let us know how it goes,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-2 encoding problem

Carl Eugen Hoyos-2
In reply to this post by Jane
2019-02-14 14:14 GMT+01:00, Jane <[hidden email]>:
>   Hello everyone! I'm encoding video to MPEG-2 using Zeranoe's Windows
> builds.  The source file is 720p 60fps, progressive. I want to keep high
> quality and compatibility with DVD standards, so I use:
> ffmpeg -hwaccel auto -i "input" -vf scale=ntsc,interlace,fps=fps=29.97 -c:v
> mpeg2video -q:v 3 -g 15 -mpeg_quant 1 -aspect 16:9 -sc_threshold 40 -bf 2
> -intra_vlc 1 -b_stratgey 2 -flags ilme+ildct -maxrate 9M -bufsize 224k -c:a
> mp2 -b:a 224k "output"

Apart from what Moritz wrote (use -target if you need dvd compatibility)
note that "29.97" is not correct, ntsc framerate is 30000/1001.

> It works all right, but the quality is very low. And I noticed during
> encoding, qp is floting around 31, what's wrong? After disabled ildct and
> ilme, the quality is normal. Is the command incorrect?

This does indeed sound like a serious bug but as also indicated by
Moritz the reason is that you overwrite flags by not using "+ilme+ildct".

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-2 encoding problem

Carl Zwanzig
In reply to this post by Moritz Barsnick
On 2/14/2019 5:46 AM, Moritz Barsnick wrote:
>  You should try "-flags +ilme+ildct". (Just a hunch, I'm not sure.)
Yes, with a leading "+".


Here's the command I use for converting content from 480p24 to NTSC "dvd"
format 480i60 (and working from memory here), the output it produces is
acceptable, and since I run it in batches, the processing time isn't
relevant to me.

ffmpeg -hide_banner -i $infile

# this forces the -input- frame rate for anything that has a little i60
#   in front of the remaining p24 content (remove fps if not needed)
-vf fps=24000/1001,telecine

# sound syn and quality (need to look up those options)
-async 1 -dc 9

# target/format flags
#  (some player s/w doesn't like TFF, so force to BFF)
-target ntsc-dvd -flags +ilme+ildct -alternate_scan 1 -top 0

-y  $outfile

I don't think you need 'scale' on the input vf since that should be taken
care of later in the process. May want to try it both ways.

If you want interlaced output, you need +ilme+ildct; that'll take more time
and produce lower-quality output. OTOH if progressive is OK, leave that
whole line out.

Later,

z!
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-2 encoding problem

Francois Visagie
> -----Original Message-----
> From: ffmpeg-user [mailto:[hidden email]] On Behalf Of
> Carl Zwanzig
> Sent: 14 February 2019 16:53
> To: [hidden email]
> Subject: Re: [FFmpeg-user] MPEG-2 encoding problem
>
> On 2/14/2019 5:46 AM, Moritz Barsnick wrote:
> >  You should try "-flags +ilme+ildct". (Just a hunch, I'm not sure.)
> Yes, with a leading "+".
>
>
> Here's the command I use for converting content from 480p24 to NTSC "dvd"
> format 480i60 (and working from memory here), the output it produces is
> acceptable, and since I run it in batches, the processing time isn't
> relevant to me.
>
> ffmpeg -hide_banner -i $infile
>
> # this forces the -input- frame rate for anything that has a little i60
> #   in front of the remaining p24 content (remove fps if not needed)
> -vf fps=24000/1001,telecine
>
> # sound syn and quality (need to look up those options)
> -async 1 -dc 9
>
> # target/format flags
> #  (some player s/w doesn't like TFF, so force to BFF)
> -target ntsc-dvd -flags +ilme+ildct -alternate_scan 1 -top 0
>
> -y  $outfile
>
> I don't think you need 'scale' on the input vf since that should be taken
> care of later in the process. May want to try it both ways.
>
> If you want interlaced output, you need +ilme+ildct; that'll take more time
> and produce lower-quality output. OTOH if progressive is OK, leave that
> whole line out.

For progressive content interlaced scaling should also be disabled, i.e. no '-vf scale=interl=1' (I was unable to find the original post's '-vf scale=interlace' syntax at https://ffmpeg.org/ffmpeg-filters.html#scale-1).

>
> Later,
>
> z!
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".

_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-2 encoding problem

Jane
In reply to this post by Jane
Thank for the detailed information. I'm trying to make full use of MPEG-2, because it's less complex. It's mainly disgned for MP@ML set-top boxes , just hope to keep compliance with DVD standards.
After I corrected flags, it works pretty well. I know a little about sc_threshold, b_strategy and the dia_size, simply I can't find information about that. Only this was found, Is it useful? http://ffmpeg.org/pipermail/ffmpeg-devel/2009-January/068162.html
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: MPEG-2 encoding problem

Carl Eugen Hoyos-2
2019-02-19 4:31 GMT+01:00, Jane <[hidden email]>:
> Thank for the detailed information. I'm trying to make full use
> of MPEG-2, because it's less complex. It's mainly disgned
> for MP@ML set-top boxes ,

> just hope to keep compliance with DVD standards.

Then use the target option.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".