What i want is
1. Get video packet from stream source
2. Decode it
3. And write that decoded data as video file(avi, mpeg etc)
I can able to get video Packets from a file (as AVPacket) and also can decode and save as an image.(raw)( FFmpeg tutorials show how to do it). But i can not ( do not know ) write that video data to a file(other) which can be played by media players(such as VLC).
Best Wishes
Ps: Real code samples will be great if possible...
Now i make test with av_interleaved_write but i got strange error "non monotone timestamps" ( i have no control over pts values of media source )
Some Extra Info
In FFmpeg I have to
I need reader and writer. I can read the media source file ( even encode packets according to given format). But i can not write to file...(which any player can play)
And some pseudoCode
File myFile("MyTestFile.avi");
while ( source ->hasVideoPackets)
{
packet = source->GetNextVideoPacket();
Frame decodedFrame = Decode(packet);
VideoPacket encodedPacket = Encode( decodedFrame);
myFile.WriteFile(encodedPacket);
}
Or Just write the original file without encode decode
File myFile("MyTestFile.avi");
while ( source ->hasVideoPackets)
{
packet = source->GetNextVideoPacket();
myFile.WriteFile(packet);
}
Then
I can able to open MyTest.avi file with a player.
FFmpeg is an open-source audio and video converter that supports most industry-standard codecs and can convert from one file format to another quickly and easily. It also lets you capture video and audio from a live source and process it.
FFmpeg can input most container formats natively, including MP4, . ts, MOV, AVI, Y4M, MKV, and many others.
ffmpeg is a command-line tool that converts audio or video formats. It can also capture and encode in real-time from various hardware and software sources such as a TV capture card. ffplay is a simple media player utilizing SDL and the FFmpeg libraries.
Now there's a new example of video transcoding in doc/examples/transcoding.c of FFmpeg trunk, and it does exactly what you need: API example for demuxing, decoding, filtering, encoding and muxing.
This is for the current ffmpeg 2.4.4
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With