h264 encoding "divisible by 2"

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

h264 encoding "divisible by 2"

Igors
Hi All

My test pipleline is

gst-launch-1.0 videotestsrc num-buffers=100 ! videoconvert !
video/x-raw,width=640,height=480,format=YV12 ! x264enc ! qtmux ! filesink
location=test_264.mov

It works fine but only for even image sizes, setting height=479 gives
x264enc error (height not divisible by 2). This restriction can be removed
if change format to Y444 (High Profile 4:4:4) but in this case the created
movies won't open with standard  video players (QT Player for example), and
it irritates user a lot.

After googling it looks like a standard prob, but other apps can do this.
e.g. create h264 files with odd sizes that are opened ok via standard
players. I compared caps for these and thouse files, both have profile
"high" 4:2:0 and all fields are same except of one

1) File with odd video size created in other app
codec_data=buffer)0164001effe100152764001eac5230280f79bc05a8101011856bdef80801000428fe09cb

2) File with even video size created with pipeline above
codec_data=buffer)0164001effe1001f6764001eacd940c82fe59b016a0c020b4a000003000200000300791e2c5b2c01000568ebecb22c

I've tried to specify codec_name in command line but it has no effect. Any
idea? Or I need other encoder instead of x264enc?

Thx



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: h264 encoding "divisible by 2"

Igors
Hello again

My venture with h264 is continuing. I've found another h264 encoder:
vtenc_x264, it works fine with odd size(s) and produced files are readable
with popular players. But I've got another prob: it can't save a single
frame or few frames, for example

gst-launch-1.0 videotestsrc num-buffers=10 ! videoconvert !
video/x-raw,format=I420 ! vtenc_h264 ! qtmux ! filesink
location=test_264.mov

It works fine but if num-buffers=3 (or 1) then output movie is junk 616
bytes

I want a simple thing - just save video in a popular h264, why all is so
complex? What am I doing wrong?

Thx



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: h264 encoding "divisible by 2"

Nicolas Dufresne-5


Le mar. 2 avr. 2019 04 h 10, Igors <[hidden email]> a écrit :
Hello again

My venture with h264 is continuing. I've found another h264 encoder:
vtenc_x264, it works fine with odd size(s) and produced files are readable
with popular players. But I've got another prob: it can't save a single
frame or few frames, for example

gst-launch-1.0 videotestsrc num-buffers=10 ! videoconvert !
video/x-raw,format=I420 ! vtenc_h264 ! qtmux ! filesink
location=test_264.mov

It works fine but if num-buffers=3 (or 1) then output movie is junk 616
bytes

I want a simple thing - just save video in a popular h264, why all is so
complex? What am I doing wrong?

This seems like a bug in vtenc draining flow. Because of reordering, h2264 encoder queue up to 16 buffers before letting one go, this requires special casing at EOS and is often a source a bugs. The right thing to do is to file a bug.

About x264, it historically didn't fully support padding and cropping. H264 encoding happens in minimum macroblock of 16x16 (that part seems handled) on top of which there is special casing for subsampled format. I would also recommend to file a bug, I'm quite certain if some dev find the time we could lift this limitation. You could also give a try yourself if you feel like it.


Thx



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: h264 encoding "divisible by 2"

Igors
In reply to this post by Igors
Hi, Nicolas, All

Thx for your reply. The bug looks already reported  

https://lists.freedesktop.org/archives/gstreamer-bugs/2015-April/145803.html

Ok, I realize in any big system not all should be perfect and run
immediately. So I've found another one h264 encoder (openh264). It works as
I need (image size(s) can be odd and any count of frames can be saved). A
small prob is only a bit better quality is wanted. I'm experimenting with
propertoes but no luck yet. Is it possible with "constrained baseline"
profile this encoder does?

Thx

Thx



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: h264 encoding "divisible by 2"

Nicolas Dufresne-5


Le sam. 6 avr. 2019 06 h 10, Igors <[hidden email]> a écrit :
Hi, Nicolas, All

Thx for your reply. The bug looks already reported 

https://lists.freedesktop.org/archives/gstreamer-bugs/2015-April/145803.html

Ok, I realize in any big system not all should be perfect and run
immediately. So I've found another one h264 encoder (openh264). It works as
I need (image size(s) can be odd and any count of frames can be saved). A
small prob is only a bit better quality is wanted. I'm experimenting with
propertoes but no luck yet. Is it possible with "constrained baseline"
profile this encoder does?

Indeed OpenH264 is limited to baseline profile, so to achieve better quality you will need to consider higher bitrate. You could also switch to variable bitrate or constant qp, I believe both are supported, but the default is trying to match the raison d'être of OpenH264, which was designed for live video conferencing where constant bitrate is generally the preferred encoding strategy.



Thx

Thx



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/
_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel