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
- Read media packets from media source ( it may be real file(.avi,mov) or even rtsp server).
- Then write those media packets to a real file (physical .avi, .mov etc file)
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.