MP4 file from raw H.264 input

1,384 views
Skip to first unread message

indorian

unread,
Dec 10, 2012, 12:37:46 PM12/10/12
to mp4parser-...@googlegroups.com
Hi,

I am getting H.264 encoded frames from camera->mediacodec and would like to use MP4Parser to create .mp4 from this data. Is it possible to use MP4Parser to create files from raw frames, not from existing MP4 file?

Thanks in advance!

Sebastian Annies

unread,
Dec 11, 2012, 5:11:02 AM12/11/12
to mp4parser-...@googlegroups.com

Peter Bruinink

unread,
Feb 4, 2013, 5:11:37 AM2/4/13
to mp4parser-...@googlegroups.com
Hi Sebastian or Indorian,

I am trying to achieve the same. I can generate basic h264 files with my Android app that Totem Movie Player (Linux Mint) will show correctly. But trying to add these tracks to a MP4 "Movie" gives me the following exception:

java.lang.NullPointerException
at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl.readSamples(H264TrackImpl.java:283)
at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl.parse(H264TrackImpl.java:87)
at com.googlecode.mp4parser.authoring.tracks.H264TrackImpl.<init>(H264TrackImpl.java:76)
at com.plusot.osee.encoder.MP4Builder.buildMP4(MP4Builder.java:27)
at com.plusot.osee.EncoderActivity$1.run(EncoderActivity.java:100)
at java.lang.Thread.run(Thread.java:856)

I am afraid that the h264 file I produce with the Android MediaCodec is missing something. But what is missing? I have attached source from "MP4Buider.java" and  "VideoEncoder.java".
Any help will be very much appreciated.

Best regards,

Peter Bruinink
the Netherlands



Op dinsdag 11 december 2012 11:11:02 UTC+1 schreef Sebastian Annies het volgende:
MP4Builder.java
VideoEncoder.java

Peter Bruinink

unread,
Feb 4, 2013, 5:57:33 AM2/4/13
to mp4parser-...@googlegroups.com
Hi Sebastian and Indorian,

Solved it myself. I was using the MP4Parser from the Nexus master source tree (http://source.android.com/source/index.html). Updated it with the newer version and the problem was gone.

Regards,

Peter

Op maandag 4 februari 2013 11:11:37 UTC+1 schreef Peter Bruinink het volgende:

Bill Gockeler

unread,
May 10, 2013, 4:33:38 PM5/10/13
to mp4parser-...@googlegroups.com
Peter,

How did you get this to work?

The H264TrackImpl takes and InputStream and building the movie throws an IOException because FileInputStream does not support read/mark.

Did you get this to work? Did you find a workaround?

If so please let me know...I'm stuck.

Thanks,

Bill

Sebastian Annies

unread,
May 11, 2013, 8:58:38 AM5/11/13
to mp4parser-...@googlegroups.com

Wrap it with a BufferedInputStream or use the latest version which uses a FileChannel instead of a stream!

--
You received this message because you are subscribed to the Google Groups "mp4parser-discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mp4parser-discus...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Yuriy Solovyov

unread,
May 13, 2013, 6:04:39 AM5/13/13
to mp4parser-...@googlegroups.com
Hi, Im curious, 

Current version of the library is using FileChannel interface only, no BufferedInputStream, so I can't create H264TrackImpl from BufferedInputStream in the latest version of the library, so how i can write my encoded frames to H264TrackImpl on android? Should I rewrite ur library by myself to add support of BufferedInputStream?

Also question about isoparser-default.properties, should this file always be present on my android device, no default values?

To unsubscribe from this group and stop receiving emails from it, send an email to mp4parser-discussion+unsub...@googlegroups.com.

Sebastian Annies

unread,
May 13, 2013, 6:18:40 AM5/13/13
to mp4parser-...@googlegroups.com

Please do not copy my source code into your project. Please depend on the jar as you will have less problems, the jar includes the properties file at the right place. Promised!

---

FileInputStream fis = new FileInputStream(“c:\file.mp3”);

new H264TrackImpl(fis);

 

Fails as FileInputStream doesn’t support mark/reset

 

FileInputStream fis = new FileInputStream(“c:\file.mp3”);

new H264TrackImpl(new BufferedInputStream(fis));

 

succeeds as wrapping it with BufferedInputStream adds support for mark/reset.

To unsubscribe from this group and stop receiving emails from it, send an email to mp4parser-discus...@googlegroups.com.


For more options, visit https://groups.google.com/groups/opt_out.
 
 

--

You received this message because you are subscribed to the Google Groups "mp4parser-discussion" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mp4parser-discus...@googlegroups.com.

Yuriy Solovyov

unread,
May 13, 2013, 6:33:26 AM5/13/13
to mp4parser-...@googlegroups.com
Thanks for the answer, what jar ur talking about? Is there prebuild version exist?
I've downloaded sources from https://code.google.com/p/mp4parser/source/checkout and trying to make it work in my android project in eclipse.

To unsubscribe from this group and stop receiving emails from it, send an email to mp4parser-discussion+unsub...@googlegroups.com.


For more options, visit https://groups.google.com/groups/opt_out.
 
 

--
You received this message because you are subscribed to the Google Groups "mp4parser-discussion" group.

To unsubscribe from this group and stop receiving emails from it, send an email to mp4parser-discussion+unsub...@googlegroups.com.

Paul Kapustin

unread,
Jun 3, 2013, 5:30:10 AM6/3/13
to mp4parser-...@googlegroups.com
Hi Peter!

Could you be so kind to share the source code of your sample project?
I cannot even get past the encoding phase. 
It seems like you are one of the very few people (if not alone) who was able to get this to work.

Thanks in advance,
Paul

Peter Bruinink

unread,
Jun 3, 2013, 12:54:13 PM6/3/13
to mp4parser-...@googlegroups.com

Hi Paul,

I am away for a few days. As soon as I am back, I ll share the code.

Peter
Op 3 jun. 2013 11:30 schreef "Paul Kapustin" <pkap...@gmail.com> het volgende:

> --
> You received this message because you are subscribed to a topic in the Google Groups "mp4parser-discussion" group.
> To unsubscribe from this topic, visit https://groups.google.com/d/topic/mp4parser-discussion/Xccb53ndgHM/unsubscribe?hl=en.
> To unsubscribe from this group and all its topics, send an email to mp4parser-discus...@googlegroups.com.

Peter Bruinink

unread,
Jun 10, 2013, 5:39:06 AM6/10/13
to mp4parser-...@googlegroups.com
Hi Paul,

I can't seem to find the discussion on groups.google any more. What is your problem in in encoding?

regards,

Peter

2013/6/3 Paul Kapustin <pkap...@gmail.com>

--
You received this message because you are subscribed to a topic in the Google Groups "mp4parser-discussion" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mp4parser-discussion/Xccb53ndgHM/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to mp4parser-discus...@googlegroups.com.

Mansi Goyal

unread,
Jul 19, 2014, 4:13:53 AM7/19/14
to mp4parser-...@googlegroups.com
hello Peter 
can you provide the updated version of mp4parser . i searched a lot but could not find it.
you can mail it at ma...@ebabu.co

Peter Bruinink

unread,
Jul 20, 2014, 9:03:31 AM7/20/14
to mp4parser-...@googlegroups.com

Hi Mansi

I am on vacation now. I will need to have a look. I think it is in the Android sources ( source.android.com) as third party software.

Regards Peter

Op 19 jul. 2014 04:13 schreef "Mansi Goyal" <ma...@ebabu.co>:
hello Peter 
can you provide the updated version of mp4parser . i searched a lot but could not find it.
you can mail it at ma...@ebabu.co

--
You received this message because you are subscribed to a topic in the Google Groups "mp4parser-discussion" group.

To unsubscribe from this group and all its topics, send an email to mp4parser-discus...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages