difference between yuv and yv12

591 views
Skip to first unread message

MS

unread,
Oct 8, 2012, 3:10:40 PM10/8/12
to webm-d...@webmproject.org
Hi All,

I am having an issue. I am trying to take the sample code for vp8 encoding on the WebM website: http://www.webmproject.org/docs/vp8-sdk/example__simple__encoder.html. However, I used a yuv file rather than a yv12 file (I am not sure if that makes a difference). However, the resulting IVF file first of all is a lot smaller than the original yuv file. Assuming that is because of compression, I played it in a player, but I don't get the original video back. I get a weird distorted version.

Can someone please enlighten me on what's going on?

THanks,

MS

John Koleszar

unread,
Oct 8, 2012, 3:16:19 PM10/8/12
to WebM Discussion
I think you mean you used a y4m file, based on your other thread.
simple_encoder takes raw input, not y4m files. If you have a y4m file,
you want to use vpxenc.
> --
> You received this message because you are subscribed to the Google Groups
> "WebM Discussion" group.
> To view this discussion on the web visit
> https://groups.google.com/a/webmproject.org/d/msg/webm-discuss/-/qYg_79UCJBgJ.
> To post to this group, send email to webm-d...@webmproject.org.
> To unsubscribe from this group, send email to
> webm-discuss...@webmproject.org.
> For more options, visit this group at
> http://groups.google.com/a/webmproject.org/group/webm-discuss/?hl=en.

Rajesh Pamula

unread,
Oct 8, 2012, 3:18:56 PM10/8/12
to webm-d...@webmproject.org
How is the YUV data organized in your input raw file. If it is Y followed by U followed by V then it is I420 format and not yv12. yv12 has an organization of Y followed by V followed by U.

--
You received this message because you are subscribed to the Google Groups "WebM Discussion" group.
To view this discussion on the web visit https://groups.google.com/a/webmproject.org/d/msg/webm-discuss/-/qYg_79UCJBgJ.
To post to this group, send email to webm-d...@webmproject.org.
To unsubscribe from this group, send email to webm-discuss...@webmproject.org.
For more options, visit this group at http://groups.google.com/a/webmproject.org/group/webm-discuss/?hl=en.



--
Rajesh Pamula
Post Graduate Student
Analogue and Digital Integrated Circuit Design
Imperial College London.
Residence Phone: +44-20-78522056

MS

unread,
Oct 8, 2012, 3:19:39 PM10/8/12
to webm-d...@webmproject.org
I am trying to create a test app. When you say "raw input", where can I get a sample of that (a video)?

Thanks,

MS

John Koleszar

unread,
Oct 8, 2012, 3:26:04 PM10/8/12
to WebM Discussion
On Mon, Oct 8, 2012 at 12:19 PM, MS <meera....@utdallas.edu> wrote:
> I am trying to create a test app. When you say "raw input", where can I get
> a sample of that (a video)?
>

You can convert your y4m files to raw video with ffmpeg/avconv.

$ ffmpeg -i test.y4m -f rawvideo test.yuv

MS

unread,
Oct 8, 2012, 4:20:49 PM10/8/12
to webm-d...@webmproject.org
unfortunately, I am getting the same distorted video if I encode after converting the y4m file to raw video with ffmpeg. 

I am able to successfully convert to ivf from the y4m using vpxenc; however, I think I will finally need an encoder from raw bytes for my final application. 

Any suggestions?

Thanks for your help!

MS

MS

unread,
Oct 8, 2012, 4:25:58 PM10/8/12
to webm-d...@webmproject.org
Can I use vpxenc to encode from raw video?

John Koleszar

unread,
Oct 8, 2012, 5:06:54 PM10/8/12
to WebM Discussion
Yes. Specify --i420 -w <width> -h <height> to vpxenc for raw video.
The important thing with raw video is you must get the correct width
and height of the input file, otherwise your video won't look right.
This is probably your issue with simple_encoder. The width/height
would have been displayed by ffmpeg when you converted from y4m to
raw.
> --
> You received this message because you are subscribed to the Google Groups
> "WebM Discussion" group.
> To view this discussion on the web visit
> https://groups.google.com/a/webmproject.org/d/msg/webm-discuss/-/RHdz6fSffCcJ.

MS

unread,
Oct 8, 2012, 5:50:41 PM10/8/12
to webm-d...@webmproject.org
THanks so much! that worked! In retrospect that makes a lot of sense :).

I just have one more question -- if I strip the IVF file and frame headers, and if I take the rest of the frame and add each frame as a frame in a WEBM segment, can I get a valid WEBM file that way?

Thanks,

MS

John Koleszar

unread,
Oct 8, 2012, 6:05:33 PM10/8/12
to WebM Discussion
Parsing the data out of the ivf that way is fine, but you have to make
sure you're putting the frames into simpleblocks, and the simpleblocks
into clusters, and the clusters into the segment. libwebm will handle
all of this for you in Segment::AddFrame(), I think you were trying to
use that iirc. The only additional thing you'll need for libwebm is to
know whether each frame is a keyframe. You can look at the LSB of the
first byte of encoded data on each frame to get that:

keyframe = !(data[0] & 0x01)

You'll also need the frame's timestamp, which you can either parse out
of the ivf or calculate manually, since you're using fixed framerate
right now.
> https://groups.google.com/a/webmproject.org/d/msg/webm-discuss/-/xhKDz_GyxKEJ.

MS

unread,
Oct 8, 2012, 8:07:32 PM10/8/12
to webm-d...@webmproject.org
Thanks John -- that was very helpful -- have it almost working. However, I didn't quite understand how to calcuate the frame's timestamp manually. Also, I can't fine where the timestamp gets added to the ivf file. Does it get added to the vpx_codec_cx_pkt_t?

Thanks,

MS

MS

unread,
Oct 9, 2012, 12:17:08 AM10/9/12
to webm-d...@webmproject.org




Can I use either of these:

unsigned long vpx_codec_cx_pkt::duration (duration to show frame (in timebase units)
vpx_codec_pts_t vpx_codec_cx_pkt::pts (time stamp to show frame (in timebase units)

John Koleszar

unread,
Oct 9, 2012, 12:02:42 PM10/9/12
to webm-d...@webmproject.org
Yes, the pts is the timestamp you want to put into the webm file. But it's in timebase units, and you'll have to convert it to nanoseconds for libwebm.

Just to get something going, and since you're getting fixed 30fps out of simple_encoder anyway, I suggest you just calculate the time stamps yourself, roughly:

timestamp = frame_num++ * 1000000000ULL / 30;

MS

unread,
Oct 9, 2012, 7:01:19 PM10/9/12
to webm-d...@webmproject.org
Thanks so much John -- your responses have been extremely helpful!

I got the video to work now with this rough timestamp estimate.

I am trying to simulate live streaming with this though, and I cannot really find the code that does something based on set_mode(mkvmuxer::Segment::kLive). Would you know anything abou tthat?

Thanks again,

MS
Reply all
Reply to author
Forward
0 new messages