I am using FFMPEG library to mux H.264 and AAC frames to MP4 file. I can do that both using command line and C program.
Now, instead of writing the muxed MP4 data in to file I want to write these muxed data directly on to socket or pipe. Command line options for that will be appreciated. My actual goal is to write a C program though.
I tried using protocols tcp and udp but they are not working with Mp4 format. They are working with the matroska format.
Following is working.
ffmpeg -i Cartoon.mjpeg -f matroska -r 25 -vcodec copy tcp://10.99.19.224:8888
Following is not and gives error as below.
ffmpeg -i Cartoon.mjpeg -f mp4 -r 25 -vcodec copy tcp://10.99.19.224:8888
Could not write header for output file #0 (incorrect codec parameters ?): Operation not permitted
Any help or advice? Thank you in advance.
Just got one way to output the muxed MP4 output directly on the socket using fragments. I know there are limitations of using fragments but this can be useful.
https://www.ffmpeg.org/ffmpeg-formats.html#Example-1
So following command line is working for me now. I am able to play the MP4 file received from the 8888 port. ffprobe also confirms that its really an MP4 file.
ffmpeg -i Stingray.264 -f mp4 -movflags isml+frag_keyframe -vcodec copy tcp://10.99.19.224:8888
Now I will have to write the C program to do this pragmatically.
If you look at all the ffmpeg output, there is a line:
[mp4 # 0033d660] muxer does not support non seekable output
The mp4 container needs to go back at the beggining of the file to write additional information. A thing that your network socket can not do. So it is not possible to use mp4 container here.
Related
My goal is transcode this file with ffmpeg.
https://drive.google.com/open?id=1ATuPtSbZeQLexB1HBP509hInDOTyfEV8
ffplay fails to analize or play this file and returns:
Invalid pixel format.
This is the simply command:
ffplay -i testproxy.mxf
ffprobe -i testproxy.mxf -show_stream
It has been encoded by avid Interplay whit this targhet quality:
H.264 800Kbps Proxy 1080i 25
Maybe it's a raw file? and need same specification ahead input file?
Any suggestion is appreciated
Either Interplay doesn't write* a standard MXF or there's a limitation in ffmpeg's mxf demuxer.
But you can play the file with
ffplay -vcodec h264 testproxy.mxf
and similarly, you can transcode using
ffmpeg -vcodec h264 -i testproxy.mxf ...
*more likely, as mediainfo also fails to detect the video codec.
I am trying to get a sample C source file as example which uses ffmpeg library APIs to stream a ts file as is without changing codec using rtp multicast
./ffmpeg -re -i test_av.ts -acodec copy -vcodec copy -f rtp_mpegts rtp://237.255.5.3:5008
edit:
I am looking for sample C program(s) which could do something close the command I mentioned. I can modify & make required changes if it is somewhat close to what I am trying to achieve. I tried modifying the muxing.c in the doc, however didn't get how to copy codecs & stream through network using rtp multicast.
I am looking for advice on using ffmpeg to convert RTSP stream to udp stream. What would be the simplest general command to do so? This is what I have right now:
ffmpeg -i rtsp://192.168.1.247/play1.sdp -f mpegts -vcodec mpeg4 -acodec mp2 udp://127.0.0.1:1234
The error I'm getting:
UDP timeout, retrying TCP
method PAUSE failed: 405 PAUSE
rtsp://192....: operation not permitted
Finishing stream 0:0 without any data written to it.
I'm running ubuntu 14.04. Thank you!
Looks like the ffmpeg command you are using good enough. I suspect your RTSP input stream is not valid. Have you verified it? You can do so using below command or in vlc also:
ffplay -i rtsp://192.168.1.247:port/filename
One change in the command could be instead of play1.sdp, you can directly give the stream filename i.e, a playable stream than sdp file. Hope it helps.
I need to stream a audio to a Multicast address. And I konw the command could be:
ffmpeg -i input -f mpegts
udp://hostname:port?pkt_size=188&buffer_size=65535
But i don't konw how to do this via code? Can you help me, thanks.
This is not different from any other video conversion with ffmpeg - open input stream, open output stream, and loop around av_read_packet, av_decode_video, av_encode_video, av_write_packet_interleaved.
The easiest way would be to reap apart the ffmpeg utility source code, which is in ffmpeg.c in the ffmpeg source directory.
Is ffmpeg metadata, which is also described in:
http://wiki.multimedia.cx/index.php?title=FFmpeg_Metadata
also supported MISB standard UAV metadata 601.5 ?
Is it same as KLV ?
Thanks,
Ran
FFMPEG does not natively support MISB KLV metadata or have demuxers or decoders for KLV metadata of these types at this time.
However, FFMPEG can be used to extract data elementary streams from containers like MPEG Transport Stream (TS) per ISO 13818-1. Such capability works for UDP streams and local MPEG TS Files. See the examples at end of response. The examples simply extract the data from the stream, they do not parse them. Parsing could easily be accomplished in real time by piping the output or post processing using many languages including C and Python.
It would be helpful to know specifically which containers you are trying to extract data from. In lieu of such information I have assumed MPEG TS in my response and examples. I would like to also point out that the current standard for "UAS Local Dataset" is now ST0601.8 at the time of this response.
I have personally tested the following examples with FFMPEG 2.5.4 on Mac OS X 10.9.5.
The following examples can be modified such that the output is sent to stdout by replacing the <outfile> with '-'.
Extract Data Stream From MPEG-TS File at Line Speed and Save to Binary File:
ffmpeg -i <MPEGTS_infile> -map d -codec copy -f data <binary_outfile>
Extract Data Stream From MPEG-TS File at Frame Rate and Save to Binary File:
ffmpeg -re -i <MPEGTS_infile> -map d -codec copy -f data <binary_outfile>
Extract Data Stream From MPEG-TS UDP Stream at Stream Rate and Save to Binary File:
ffmpeg -i udp://#<address:port> -map d -codec copy -f data <binary_outfile>
Extract Data Stream From MPEG-TS UDP Stream at Stream Rate and Direct to STDOUT:
ffmpeg -i udp://#<address:port> -map d -codec copy -f data -
Stream Video, Audio and Data Streams from MPEG-TS file Over UDP at Frame Rate:
ffmpeg -re -i <MPEGTS_infile> -map 0 -c copy -f mpegts udp://<address:port>
I'm unsure if UAV metadata 601.5 is the same as KLV, but FFmpeg can demux KLV metadata since commit 69a042e from 28 Oct 2013:
mpegts: demux synchronous SMPTE 336M Key-Length-Value (KLV) metadata
This fixes ticket #2579: Data stream from UAV video reported as "Unknown" type and without codec_id set, so you may find other relevant information there too.