-
大小: 3.94MB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2024-01-08
- 語言: Java
- 標簽: ffmpegh.264??
資源簡介
一直苦于沒辦法用JAVA解碼H.264,而且FMJ什么的非常難用,終于發(fā)現(xiàn)這個FFMPEG-JAVA既可以解決問題,庫函數(shù)什么又和FFMPEG一致的類庫了!而且連例程都非常相擬。

代碼片段和文件信息
//?avcodec_sample.0.4.9.cpp
//?from?http://www.inb.uni-luebeck.de/~boehme/avcodec_sample.0.4.9.cpp
//?A?small?sample?program?that?shows?how?to?use?libavformat?and?libavcodec?to
//?read?video?from?a?file.
//
//?This?version?is?for?the?0.4.9-pre1?release?of?ffmpeg.?This?release?adds?the
//?av_read_frame()?API?call?which?simplifies?the?reading?of?video?frames?
//?considerably.?
//
//?Use
//
//?g++?-o?avcodec_sample.0.4.9?avcodec_sample.0.4.9.cpp?-lavformat?-lavcodec?\
//?????-lz
//
//?to?build?(assuming?libavformat?and?libavcodec?are?correctly?installed?on
//?your?system).
//
//?Run?using
//
//?avcodec_sample.0.4.9?myvideofile.mpg
//
//?to?write?the?first?five?frames?from?“myvideofile.mpg“?to?disk?in?PPM
//?format.
extern?“C“?{
#include?
#include?
}
#include?
void?Saveframe(AVframe?*pframe?int?width?int?height?int?iframe)
{
????FILE?*pFile;
????char?szFilename[32];
????int??y;
????//?Open?file
????sprintf(szFilename?“frame%d.ppm“?iframe);
????pFile=fopen(szFilename?“wb“);
????if(pFile==NULL)
????????return;
????//?Write?header
????fprintf(pFile?“P6\n%d?%d\n255\n“?width?height);
????//?Write?pixel?data
????for(y=0;?y ????????fwrite(pframe->data[0]+y*pframe->linesize[0]?1?width*3?pFile);
????//?Close?file
????fclose(pFile);
}
int?main(int?argc?char?*argv[])
{
????AVFormatContext?*pFormatCtx;
????int?????????????i?videoStream;
????AVCodecContext??*pCodecCtx;
????AVCodec?????????*pCodec;
????AVframe?????????*pframe;?
????AVframe?????????*pframeRGB;
????AVPacket????????packet;
????int?????????????frameFinished;
????int?????????????numBytes;
????uint8_t?????????*buffer;
????//?Register?all?formats?and?codecs
????av_register_all();
????//?Open?video?file
????if(av_open_input_file(&pFormatCtx?argv[1]?NULL?0?NULL)!=0)
????????return?-1;?//?Couldn‘t?open?file
????//?Retrieve?stream?information
????if(av_find_stream_info(pFormatCtx)<0)
????????return?-1;?//?Couldn‘t?find?stream?information
????//?Dump?information?about?file?onto?standard?error
????dump_format(pFormatCtx?0?argv[1]?false);
????//?Find?the?first?video?stream
????videoStream=-1;
????for(i=0;?inb_streams;?i++)
????????if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO)
????????{
????????????videoStream=i;
????????????break;
????????}
????if(videoStream==-1)
????????return?-1;?//?Didn‘t?find?a?video?stream
printf(“Video?stream?index:?%d\n“?videoStream);
????//?Get?a?pointer?to?the?codec?context?for?the?video?stream
????pCodecCtx=pFormatCtx->streams[videoStream]->codec;
printf(“Codec?id:?%d\n“?pCodecCtx->codec_id);
????//?Find?the?decoder?for?the?video?stream
????pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
????if(pCodec==NULL)
????????return?-1;?//?Codec?not?found
????//?Open?codec
????if(avcodec_open(pCodecCtx?pCodec)<0)
????????return?-1;?//?Could?not?open?codec
#if?0
????//?Hack?to?correct?wrong?frame?rates?that?seem?to?be?generated?by?some?
????//?codecs
????if(pCodecCtx->fram
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????7639??2007-08-29?05:25??ffmpeg-java-20070916-0351\LICENSE
?????文件???????1539??2007-09-16?03:51??ffmpeg-java-20070916-0351\README
?????文件???????5391??2007-08-29?05:25??ffmpeg-java-20070916-0351\build.xm
?????文件??????64156??2007-09-16?03:51??ffmpeg-java-20070916-0351\ffmpeg-java.jar
?????文件????????543??2007-09-16?03:51??ffmpeg-java-20070916-0351\version-history.txt
?????文件??????92166??2007-08-29?05:25??ffmpeg-java-20070916-0351\ffmpeg_headers\libavcodec\avcodec.h
?????文件???????2999??2007-08-29?05:25??ffmpeg-java-20070916-0351\ffmpeg_headers\libavcodec\opt.h
?????文件??????31943??2007-08-29?05:25??ffmpeg-java-20070916-0351\ffmpeg_headers\libavformat\avformat.h
?????文件???????9132??2007-08-29?05:25??ffmpeg-java-20070916-0351\ffmpeg_headers\libavformat\avio.h
?????文件???????6036??2007-08-29?05:25??ffmpeg-java-20070916-0351\ffmpeg_headers\libavutil\avutil.h
?????文件???????3599??2007-08-29?05:25??ffmpeg-java-20070916-0351\ffmpeg_headers\libavutil\log.h
?????文件???????1979??2007-08-29?05:25??ffmpeg-java-20070916-0351\ffmpeg_headers\libavutil\mem.h
?????文件???????2943??2007-08-29?05:25??ffmpeg-java-20070916-0351\ffmpeg_headers\libavutil\rational.h
?????文件?????268395??2007-08-29?05:25??ffmpeg-java-20070916-0351\lib\jna.jar
?????文件???????4917??2007-08-29?05:25??ffmpeg-java-20070916-0351\native\avcodec_sample.0.4.9.cpp
?????文件????????100??2007-08-29?05:25??ffmpeg-java-20070916-0351\src\overview.html
?????文件?????135762??2007-09-16?03:51??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\AVCodecLibrary.java
?????文件??????40486??2007-09-16?03:51??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\AVFormatLibrary.java
?????文件???????1200??2007-09-16?03:51??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\AVUtilLibrary.java
?????文件??????11131??2007-08-29?05:25??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\FFMPEGLibrary.java
?????文件???????1130??2007-08-29?05:25??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\custom_protocol\CallbackURLProtocolHandler.java
?????文件???????6021??2007-08-29?05:25??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\custom_protocol\CallbackURLProtocolMgr.java
?????文件???????3554??2007-08-29?05:25??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\custom_protocol\FileCallbackURLProtocolHandler.java
?????文件???????7017??2007-08-29?05:25??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\example\AVCodecSample.java
?????文件???????7052??2013-06-11?21:20??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\example\Pla
?????文件???????7440??2007-09-16?03:51??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\example\URLProtocolTest.java
?????文件???????2544??2007-09-16?03:51??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\gui\Imagefr
?????文件???????1380??2007-08-29?05:25??ffmpeg-java-20070916-0351\src\net\sf\ffmpeg_java\util\fr
?????文件????????401??2013-05-13?09:56??ffmpeg-java-20070916-0351\.project
?????文件????????100??2007-08-29?05:25??ffmpeg-java-20070916-0351\bin\overview.html
............此處省略87個文件信息
評論
共有 條評論