Check if file has a video stream - objective-c

I'm on Mac OS X (Objective-C) and I'm looking for a way to determine if a file has a video stream. More specifically, a video stream that can be decoded by FFmpeg. I probably can put something together with Objective-C to see if a file has a QuickTime-compatible video stream but that's not enough. I could try MediaInfo but I don't know which files it can open.. Another option would be running FFmpeg and grep to see if there's a video stream. But this is relatively slow so I looked at FFmpeg's source code to see how they detect it and I couldn't even find out in which file to start.

Here is a tutorial on using libavformat and libavcodec (both part of FFMpeg) to get video stream info.

Related

Using FFMPEG in an OS X application

so I've been wanting to make a real-time live streaming application. Essentially, the application would send the microphone feed from an Xcode application to a website where it can be viewed in real-time. Is FFMPEG the best solution for this? How would I go about doing this? If that's too broad, then how do I use the FFMPEG framework in an OS X objective-c application?
To directly address your questions:
(1) Is FFMPEG the best solution for this?
It depends. When setting up a live streaming environment you will likely stumble over FFMPEG, VLC and gstreamer, which are the options you have to simply stream video/audio. Therefore, yes, FFMPEG can be used as part of the solution. Please look into the following question: DIY Video Streaming Server
(2) How would I go about doing this?
Your requirement is to make a live streaming application which sends the mic input onto the web. This includes the following steps:
(0) Your Xcode application will need to provide a method to start this process. You don't necessarily need to integrate a framework to achieve this.
(1) Streaming / Restreaming
Use FFMPEG or VLC to grab your device and stream it locally:
ffmpeg -i audioDevice -acodec libfaac -ar 44100 -ab 48k -f rtp rtp://host:port
(2) Segmenting for HTTP Live Streaming*
Use a segmenter such as: mediastreamsegmenter (Apple), livehttp (VLC) or segment (FFMPEG) to prepare your stream for web delivery:
vlc -vvv -I dummy <SOURCEADDRESS> --sout='#transcode{acodec=libfaac,ab=48}:std{access=livehttp{seglen=10,delsegs=false,numsegs=10,index=/path/to/your/index/prog_index.m3u8,index-url=YourUrl/fileSequence######.ts},mux=ts{use-key-frames},dst=/path/to/your/ts/files/fileSequence######.ts}'
*you could also simply use VLC to grab your audiodevice with qtsound (see this question) and prepare it for streaming with livehttp.
(3) HTML 5 Delivery
Publish your stream
<audio>
<source src="YOUR_PATH/playlist.m3u8" />
</audio>
(3) If that's too broad, then how do I use the FFMPEG framework in an OS X objective-c application?
Either use an external wrapper framework to access FFMPEG functionality and consult the tutorials to work with these frameworks or you could also approach this by using NSTask to wrap your command line arguments in Objective-C and simply start those tasks from your application - as in this question.
Another way would be to use VLCKit, which offers VLC functionality in a framework for Objective-C (VLCKit wiki). However when tackling streaming challenges I prefer to work with the actual commands instead of pushing another layer of framework in between, which may be missing some options.
I hope this points you in the right directions. There are multiple ways to solve this. It's a broad question, therefore this broad approach to answer your question.

All the examples of WebRTC are video chat, is it possible to send any type of video over WebRTC?

So I want to be able to send a normal video from a video file (AVI or any other) through WebRTC, can that be done? The only examples I see of WebRTC are video chats, so I feel as if its only geared towards webcam and chats.
So my question is, technically can sending normal video from a video file (not webcam) over WebRTC be done?
Try: "Pre-recorded media streaming" --- Documentation and Source Code.
This experiment uses MediaSource API to render Blobs in <video> element. This experiment has some issues need to be fixed e.g. it can't send longer WebM videos.
You can try this experiment as well.
The codecs typically used in AVI are not directly supported by WebRTC clients, but if you are writing your own standalone client then of course it could read an AVI or other video file and transcode it to VP8 video and Opus audio (or whatever other codecs you were able to negotiate), and transmit it via RTP. If you are trying to do video transcoding in JavaScript in a browser then that will be very slow.

play music stream with gstreamer-sharp

I am looking fo an example showing me how to play an mp3 stream from a URL.
I am trying to build a comand line client for apache using mono with gstreamer.
So far I haven't found any clue how to use gstreamer sharp - does anybody have any experience?
Have a look at Banshee source code, we have a GStreamerSharp backend.

H.264 trimming/downsizing and streaming with Apache

I am doing some research on how to do two things: Trim and stream H.264 video.
What does it take to trim a mpeg4 h.264 video to 30 seconds and downsize it to 480p. I am assuming I would need to find a 3rd party library that does H.264 encoding, doing a quick Google search and the only thing I find is VideoLan.org, but I cannot find their commercial license. Are there other options folks know of?
How is streaming of H.264 to a HTML5 work? I know that with Flash, one can have one file format that requires the whole file to be downloaded, then it will play. The other format allows streaming, but requires a Flash server. I am going to be using Apache to serve up the images on the Intranet, how does one go about streaming them on Apache?
1) You can use FFmpeg :
ffmpeg -i in.mp4 -s 720x480 -t 30 out.mp4
-s is to resize and -t is to dump only 30 seconds
2) For http streaming, if the moov atomc(contains the video headers and seek information), is present at the start of the video, the video will start playing as soon as it buffers up few seconds, it does not wait for the whole file to download. Forward seek is possible through ByteRange headers in http. To put moov atom in the beginning use qt-fastart . It comes with FFmpeg
qt-faststart in.mp4 out.mp4

Red 5 publish Issue

I m publishing a stream on red5 using microphone on client side as3 code . but it not published good stream but the same thing i m doing on FMS it creates perfect stream
I need to be understand what is the issue during publish on red 5 .
Read Red5 documentation for that. And ofcourse there are differences between the performances of the two servers. However if you want to improve the quality of stream you can use FFMPEG or Xuggler with Red5 to encode streams.
Because you are not saying what your encoder is, it is hard to give a clear answer. If you are using Adobe's FMLE to create the stream that goes to your FMS server, it is the FMLE that explains why you have good video and audio encoding 'out-of-the-box'.
I have never tried to use FMLE with RED5, so I cannot tell you if it works, but doubtful it works out-of-the-box. It probably can work with a bit of tweaking on both client and server side.
To use your own encoder, what you do is capture two streams using ffmpeg, a great example on how to do that is on stackoverflow here.
Once you are capturing, you can use ffmpeg to send the combined audio and video streams to a file, or you can send it directly to your red 5 server. A simplified version of the ffmpeg command to show mapping two streams to give a single rtmp output is shown below. ffmpeg -i video_stream -i audio_stream -map 0:0 -map 1:0 -f flv rtmp://my.red5.server:1935/live/mystream