LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 08-01-2005, 09:15 PM   #1
james_vasant
LQ Newbie
 
Registered: Aug 2005
Posts: 4

Rep: Reputation: 0
ffmpeg - libavcodec & libavformat


Hi all,

I checked out the latest version of ffmpeg from the CVS and installed it on Solaris 5.8. I compiled the source code and built them as static libraries. The build was successful.

Following is a small piece of a program that calls the libavcodec/libavformat functions.

/***********************************************************

AVFormatContext *pFormatCtx;
int i, videoStream;
AVCodecContext *pCodecCtx;
AVCodec *pCodec;
AVFrame *pFrame;
AVFrame *pFrameRGB;
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) {
fprintf(stdout, "Couldn't open file\n");
return -1; // Couldn't open file
}

// Retrieve stream information
if(av_find_stream_info(pFormatCtx)<0) {
fprintf(stdout, "Couldn't find stream information\n");
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; i<pFormatCtx->nb_streams; i++)
if(pFormatCtx->streams[i]->codec->codec_type==CODEC_TYPE_VIDEO)
{
videoStream=i;
break;
}
if(videoStream==-1) {
fprintf(stdout, "Couldn't find a video stream\n");
return -1; // Didn't find a video stream
}

// Get a pointer to the codec context for the video stream
pCodecCtx=pFormatCtx->streams[videoStream]->codec;

fprintf(stdout, "codec_id=%d\n", pCodecCtx->codec_id);

// Find the decoder for the video stream
pCodec=avcodec_find_decoder(pCodecCtx->codec_id);
if(pCodec==NULL) {
fprintf(stdout, "Codec not found\n");
return -1; // Codec not found
}

***********************************************************/

When I compile and run the code with a mpeg-2 video as input, it always exits from the "codec not found" condition. I tried different formats such as mpeg-1, avi, etc... but the code exits not finding the codec.

However, the input stream statistics are output properly -

------------------------------------------------------------------------------------------------
Input #0, mpeg, from 'test.mpg':
Duration: 00:28:33.2, start: 0.366367, bitrate: 7303 kb/s
Stream #0.0[0x1e0]: Video: , 704x480, 29.97 fps, 7000 kb/s
Stream #0.1[0x1c0]: Audio: 0x0000, 32000 Hz, stereo, 256 kb/s
codec_id=2
Codec not found
-----------------------------------------------------------------------------------------------

Then I tried using the "apiexample.c" that comes along with code. For both mpeg1 & mpeg2 input, it bails out with the same problem.

I finally tried using the ffmpeg executable too.

-----------------------------------------------------------------------------------------------
351 keylime: ./ffmpeg -i test.mpg -target dvd output.mpg
ffmpeg version CVS, build 3211264, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --disable-shared
built on Aug 1 2005 18:45:10, gcc: 3.4.2
Input #0, mpeg, from 'test.mpg':
Duration: 00:28:33.2, start: 0.366367, bitrate: 7303 kb/s
Stream #0.0[0x1e0]: Video: , 704x480, 29.97 fps, 7000 kb/s
Stream #0.1[0x1c0]: Audio: 0x0000, 32000 Hz, stereo, 256 kb/s
Assuming NTSC for target.
Unknown codec 'mpeg2video'
------------------------------------------------------------------------------------------------

I also tried encoding a set of ppm images. No luck again

------------------------------------------------------------------------------------------------
$>> ./ffmpeg -i myframe%04d.ppm video.mpg

ffmpeg version CVS, build 3211264, Copyright (c) 2000-2004 Fabrice Bellard
configuration: --disable-shared
built on Aug 1 2005 18:45:10, gcc: 3.4.2
Input #0, image2, from 'myframe%04d.ppm':
Duration: 00:00:04.1, start: 0.000000, bitrate: N/A
Stream #0.0: Video:
Output #0, mpeg, to 'video.mpg':
Stream #0.0: Video: , q=2-31, 200 kb/s
Stream mapping:
Stream #0.0 -> #0.0
Unsupported codec for output stream #0.0
------------------------------------------------------------------------------------------------

Can anyone tell me whats happening? Am at my wits end in fixing this.

I checked the codecs using

$>> ./ffmpeg -formats

and got the following

------------------------------------------------------------------------------------------------
Codecs:
DEA adpcm_4xm
DEA adpcm_adx
DEA adpcm_ct
DEA adpcm_ea
DEA adpcm_ima_dk3
DEA adpcm_ima_dk4
DEA adpcm_ima_qt
DEA adpcm_ima_smjpeg
DEA adpcm_ima_wav
DEA adpcm_ima_ws
DEA adpcm_ms
DEA adpcm_swf
DEA adpcm_xa
DEA adpcm_yamaha
DES dvbsub
D S dvdsub
DEA g726
DEA pcm_alaw
DEA pcm_mulaw
DEA pcm_s16be
DEA pcm_s16le
DEA pcm_s8
DEA pcm_u16be
DEA pcm_u16le
DEA pcm_u8
-------------------------------------------------------------------------------------------------

Now, would this help anyone in resolving my issue?

Any help in this regard will be highly appreciated.

Thanks in advance,
James
 
Old 08-16-2005, 12:43 PM   #2
sangijuela
LQ Newbie
 
Registered: Aug 2005
Posts: 2

Rep: Reputation: 0
Hello:

In my case i need to put the next sequence for initialized the codecs:

avcodec_init();
avcodec_register_all();

then the codecs open right (MPEG1, MPEG2, etc).

I am interested in programming a coder and decoder with these libraries. Have you information about this libraries? . My email is julio_andon@yahoo.es in case you want to contact with me. Thanks you.

PD (Sorry for my English)
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
libavcodec and libavformat shared libraries ivorytower27 Linux - Newbie 3 10-16-2005 05:48 AM
decoder and encoder with ffmpeg (libavcodec) sangijuela Programming 1 08-20-2005 07:53 AM
Using ffmpeg (libavcodec and libavformat) libraries... _UnPrEdictAbLe_ Programming 2 07-27-2005 07:49 AM
Libavformat.so? DeathPrawn Linux - Software 2 07-03-2005 03:13 AM
Transcode & FFMPEG compiling error CrEsPo Slackware 2 05-10-2005 03:17 PM


All times are GMT -5. The time now is 10:12 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration