sannies / mp4parser

A Java API to read, write and create MP4 files
Apache License 2.0
2.76k stars 568 forks source link

I420Frame to mp4 #81

Open Ewg777 opened 9 years ago

Ewg777 commented 9 years ago

I want to convert the raw I420Frames in to mp4.I am using the mp4 parser. Should I use MemoryDataSourceImpl? Is it possible?

sannies commented 9 years ago

What are I420 frames? I guess h264 interlaced yuv420? Have a look here: https://github.com/sannies/mp4parser/blob/master/examples/src/main/java/com/googlecode/mp4parser/muxformats/H264Example.java

The DataSource just abstracts 'where the data comes from'. It has nothing to do with any format. (I think you need to clarify a bit what you are trying to achieve)

2015-05-08 10:08 GMT+02:00 Ewg notifications@github.com:

I want to convert the raw I420Frames in to mp4.I am using the mp4 parser. Should I use MemoryDataSourceImpl? Is it possible?

— Reply to this email directly or view it on GitHub https://github.com/sannies/mp4parser/issues/81.

Ewg777 commented 9 years ago

I420Frame implemented here: https://chromium.googlesource.com/external/webrtc/stable/talk/+/master/app/webrtc/java/src/org/webrtc/VideoRenderer.java It's kind of a byte array describing particular video frame which I receive. I'm trying to achieve saving raw video frames received one-by-one from webrtc library to a file.

sannies commented 9 years ago

So it's an uncompressed video frame? Hmm is there a specification that describes his to package these frames in MP4? Or do you perhaps have an example video that uses this codec? Remember : You cannot encode with the mp4parser. You can only package what has been encoded before. Am 08.05.2015 10:27 schrieb "Ewg" notifications@github.com:

I420Frame implemented here: https://chromium.googlesource.com/external/webrtc/stable/talk/+/master/app/webrtc/java/src/org/webrtc/VideoRenderer.java It's kind of a byte array describing particular video frame which I receive. I'm trying to achieve saving raw video frames received one-by-one from webrtc library to a file.

— Reply to this email directly or view it on GitHub https://github.com/sannies/mp4parser/issues/81#issuecomment-100151403.

Ewg777 commented 9 years ago

So I need some codec (for example MediaCodec) to convert an uncompressed video frames into H.264 stream and after that pack it with the mp4parser. Am I right?

sannies commented 9 years ago

Yes. Mediacodec is the right choice on android. Am 08.05.2015 10:52 schrieb "Ewg" notifications@github.com:

So I need some codec (for example MediaCodec) to convert an uncompressed video frames into H.264 stream and after that pack it with the mp4parser. Am I right?

— Reply to this email directly or view it on GitHub https://github.com/sannies/mp4parser/issues/81#issuecomment-100159637.

Ewg777 commented 9 years ago

Okay. MediaCodec returns encoded data portion-by-portion. So how to pass this data to mp4parser?

sannies commented 9 years ago

Ok. I guess you want to grow the file sample by sample. Unfortunately you'll have to buffer it before at the moment. Currently this streaming in to a file is not possible but I see this request not for the first time. I'll try to make it possible at least for h264 in the next weeks. Stay tuned. Sebastian Am 08.05.2015 11:05 schrieb "Ewg" notifications@github.com:

Okay. MediaCodec returns encoded data portion-by-portion. So how to pass this data to mp4parser?

— Reply to this email directly or view it on GitHub https://github.com/sannies/mp4parser/issues/81#issuecomment-100164384.

Ewg777 commented 9 years ago

Thanks. That's work for me! Streaming support will be perfect!

Ewg777 commented 9 years ago

Any idea?

sannies commented 9 years ago

I only got a few lines of code done. I have an idea how it will look like but it's not yet done. I have to do it in my spare time as I'm full time employed. Please be patient. From July, 1st I'll be working as a freelancer and most likely find more time to devote to the mp4parser and then of course you could book me to get your issues to the top of my list.

Best Regards, Sebastian

2015-06-02 9:26 GMT+02:00 Ewg notifications@github.com:

Anyy idea?

— Reply to this email directly or view it on GitHub https://github.com/sannies/mp4parser/issues/81#issuecomment-107837356.

hoang89yenthe commented 9 years ago

I have just recognized I have a same issue. @Ewg777 Can you support me to convert I420Frames into H.264 stream. Would we discuss outside while waitting for @sannies ...:) Please contact me : hoang89yenthe@gmail.com .

Ewg777 commented 9 years ago

@hoang89yenthe I ended up with i420Frames and started use byte[] from onPreviewFrame. More info on http://bigflake.com/mediacodec/

hoang89yenthe commented 9 years ago

Thanks @Ewg777