Code Monkey home page Code Monkey logo

Comments (11)

tuarua avatar tuarua commented on May 22, 2024 1

So, if you look at Streamer.as and UniversalPlayer.as you'll notice I output my AVANE encode to tcp:127.0.0.1:1234. This is a tcp socket created in AIR. In Streamer.as is where I setup the socket and forward the byteArray via a dispatchEvent. I then consume this in ns.appendBytes.

So, FFmpeg can output to a Socket and it can also read in from a tcp socket!
You could create a socket in AIR. Send your raw video to say 127.0.0.1:1235.
This "url" tcp:127.0.0.1:1235 is your input into AVANE.

I struggled with how to get btyeArrays into/out of FFmpeg for weeks and then it dawned on me I could just use an AIR Socket :)

You might also be able to use a UDP socket (Datagram Socket) which in theory has less latency

from avane.

tuarua avatar tuarua commented on May 22, 2024

I don't have any immediate plans.
Android is not as straight forward. In fact, I didn't include Libavdevice is it refused to build for me for Android.

AS3 actually natively supports camera capture and encoding to FMS (or other rtmp server)
http://www.adobe.com/devnet/adobe-media-server/articles/encoding-live-video-h264.html

Never personally used it.

from avane.

Igazine avatar Igazine commented on May 22, 2024

Sad to hear :(

Unfortunately H264 encoding is not supported on mobile devices, only the old Sorenson Spark codec which can only be played back in a browser with Flash plugin. So it's a no-go

I'm looking for solutions since years now, it looks like I have to build this app in native android/java

Thanks anyway

from avane.

tuarua avatar tuarua commented on May 22, 2024

It might be best to use native functionality Android (ie MediaRecorder) which I imagine has HW acceleration, is easier to specify cameras etc.
You could wrap it in an ANE !
You could then even output it to Socket and send that into AVANE.
Always options

from avane.

Igazine avatar Igazine commented on May 22, 2024

You could then even output it to Socket and send that into AVANE.

Could you please explain this?

I might have access to raw video data in AIR, so if there's any other option to send the bytearray to some kind of a buffer which AVANE can work with would be nice

from avane.

Igazine avatar Igazine commented on May 22, 2024

sounds great, thanks

i'll give it a try

from avane.

Igazine avatar Igazine commented on May 22, 2024

Edit: Nevermind, I made a mistake by connecting twice to the same address. All okay now

It works from command line perfectly, I can stream the camera's rawvideo to ffmpeg and convert it to an mp4 file.

However if I start AVANE, the socket cannot write data ( ioError )

Here's a sample code:

ffmpeg -y -f rawvideo -pixel_format argb -video_size 160x120 -framerate 15 -i tcp://127.0.0.1:1235?listen=1 test.mp4
(works)

The same does not work with AVANE. Camera size, framerate, etc is all correct. Socket connection is made successfully, but the writing fails. Permissions are set properly, file and directory paths exist.

from avane.

Igazine avatar Igazine commented on May 22, 2024

I ran some tests, maybe you're interested:

On a 4 core cpu android device a 1280x720 live video capture is encoded at average 9 fps, a 640x360 can be encoded at 25 fps with the fastest possible encoding. So for now it remains only a tech demo, but good to see that it's working fine with tcp sockets and bytearray.

I might run another test with udp instead, but I don't expect much of an improvement

from avane.

tuarua avatar tuarua commented on May 22, 2024

so you got Sockets working ok?
I'm not very happy with the encoding speeds on Android.
I believe I need to re-compile FFmpeg libs with mediacodec to allow for Hardware Accelerated encoding.
CPU encoding is not perfomant on devices. The information is pretty thin on this, but will revisit when I get a chance.

from avane.

Igazine avatar Igazine commented on May 22, 2024

yep, i got sockets working

just the raw video data is too much: for a 1280x720p 25fps 4 channel raw video is 92MB data in each second to process. that's a liitle bit too much. and i also need to take care of buffering, tcp is easily get stuck, udp packets are much smaller so it takes more cpu to make the chunks, emptying the buffer if needed etc. it's not really worth the headache. and flash does not have any video encoding at all (only for netstreams but it's a different story). so for now it works, but not really a solution. i'll give other ffmpeg builds a try, i've seen some promising implementation of v4l2, but i think ultimately a native android app will be necessary

from avane.

Igazine avatar Igazine commented on May 22, 2024

And for the sockets:

you need to set ffmpeg tcp input to listen mode (to act as some sort of a socket server) and connect from Flash/AIR to that, and everything you send there will be processed and sent to the output. of course you need to tell ffmpeg which format should it expect, but this is the basic logic (see example above)

from avane.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.