Reputation: 159
I am using FC23 machine and FFMPEG version is 2.8.10
Using below command, I can stream flv over tcp successfully and able to receive it successfully at receiver side as well. I play it using vlc player. Both audio and video are played well.
./ffmpeg -f x11grab -s 1920x1080 -framerate 15 -i :0.0 -f alsa -ac 2 -i hw:1 -vcodec libx264 -r 30 -pix_fmt yuv420p -tune zerolatency -preset ultrafast -acodec aac -strict -2 -ar 48000 -ab 96k -f flv -metadata streamName=naseeb.sdp tcp://127.0.0.1:6666
But in actually i need to do this using an application. So i wrote an application in 'C' language. I have done following things in the application.
1. Open `AVOutputFormat` using below API
fmt = av_guess_format("flv", NULL , NULL);
2. Get `AVFormatContext` using below API
avformat_alloc_output_context2(&oc, fmt, NULL, NULL);
3. Then added streams(audio and video) using required APIs
4. Then open codecs using required APIs
5. Then set the output using below API
ret = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE);
(A) If I need to write flv into a file on system then I provide filename
in step 5 as muxer.flv
.
muxer.flv
using VLC player both video and audio are played well(B) If I need to stream flv over tcp then I provide filename
as tcp://127.0.0.1:6666
.
I have no doubt on Receiver side as it works very well with FFmpeg
utility (command mentioned above).
Currently I have downloaded ffmpeg 2.8.10 source code and looking into ffmpeg.c
file for some extra setting. Till now I have not found anything helpful.
Please suggest something why Green frames shown when flv is sent on network where it works well when dump on system hard disk.
Upvotes: 2
Views: 1777
Reputation: 159
I have solved the issue.
Earlier, i was calling avformat_write_header
before extracting extradata which is required for flv container.
Now first i update st->codec->extradata
and st->codec->extradata_size
then i call avformat_write_header
api and everything works fine.
Upvotes: 1