I have found a lot of examples on how to encode video with MediaCodec, but all of them have to create a input surface. It is possible to encode video without a input surface? A code example will be a great help, thank you!
Asked
Active
Viewed 1,271 times
1 Answers
0
Yes, you can also configure it to use a normal YUV color as input format, and manually fill the input buffers with data in this format. One example of this is https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/EncodeDecodeTest.java - see the encodeDecodeVideoFromBuffer, selectColorFormat and generateFrame methods.

mstorsjo
- 12,983
- 2
- 39
- 62
-
If you start at http://bigflake.com/mediacodec/#EncodeDecodeTest you get an overview description of the test. It should also be noted that the behavior of YUV input is a bit unpredictable pre-API 18. – fadden Jan 04 '15 at 17:10
-
If you are looking at a native level application, please do have a look at `recordVideo` http://androidxref.com/5.0.0_r2/xref/frameworks/av/cmds/stagefright/recordvideo.cpp which records a randomly generated sequence. You can easily modify this to read from a file and you would have a simple `YUV` based recording application. – Ganesh Jan 05 '15 at 00:17
-
Cool, thank you all guys. It's a shame that I have read bigflake's cts tests and didn't find it has a example on how to encode video without a surface. – Chris Tsang Jan 05 '15 at 03:15
-
@ChrisTsang did you solve this problem? Mb you could finally add (post) some examples how to record video without a surface? – user924 Dec 27 '17 at 15:18
-
Yes, just google 'Grafika' and you'll get what you need. – Chris Tsang Jan 04 '18 at 12:12