FFmpeg的如何写的视频文件 [英] FFmpeg How to write video to a file
问题描述
我要的是
1.使用视频流从源数据包
2.德code将其
3.和写入德codeD数据如视频文件(AVI,MPEG等)
我也能够从一个文件(如AVPacket)获取视频数据包,也可以去code和保存为图像(RAW)(FFmpeg的教程展示如何做到这一点)。
但是我不能(不知道)的视频数据写入一个文件(其他的),它可以通过媒体播放器(如VLC)进行播放。
最良好的祝愿
诗:真正的code样品将是巨大的,如果可能的...
现在我做测试用的 av_interleaved_write 但是我得到奇怪的错误非单调时间戳(我对媒体来源的PTS值没有控制)
一些额外的信息
在FFmpeg的我不得不
- 阅读媒体包(它可能是真正的文件(.AVI,MOV),甚至RTSP服务器)。
- 然后写这些媒体数据包发送到真正的文件(物理.AVI,.MOV文件等)
从媒体源
我需要的读者和作家。我可以(根据给定的格式,甚至连接code包)读取媒体源文件。但我不能写入文件...(其中任何玩家都可以玩)
和一些伪code
myfile文件(MyTestFile.avi);而(来源 - > hasVideoPackets)
{
包=源 - > GetNextVideoPacket();
帧去codedFrame =德code(数据包);
VideoPacket EN codedPacket = EN code(德codedFrame);
myFile.WriteFile(EN codedPacket);
}
或者只在没有原始文件的EN code德code
myfile文件(MyTestFile.avi); 而(来源 - > hasVideoPackets)
{
包=源 - > GetNextVideoPacket();
myFile.WriteFile(包);
}
然后
我也能打开MyTest.avi文件与播放器。
也许这个链接可以帮助你:
我希望它能帮助。
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.
Probably this link may help you:
Output a media file in any supported libavformat format
I hope it helps.
这篇关于FFmpeg的如何写的视频文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!