[Ffmpeg-devel] Modifing output_example.c for Sony PSP support
Lars Blumberg
Lars.Blumberg
Mon Apr 3 19:01:41 CEST 2006
Hello newsgroup,
I made a few changes to output_example.c to create a test video for "Sony
Play Station Portable" Devices.
So I had to change the screen size and some compression values (bit rate,
sample rate, ...).
Now the problem is, that output_example does not generate a valid audio
stream. The audio stream is correctly played with VLC, but the Sony PSP
device only plays very strange noises. output_example uses the right codecs
for encoding, but there is something wrong with the audio.
Can anyone check my changes, please? I want to know, what I did wrong in
order to create a test video for Sony PSP devices.
Here are the differences between the original, current output_example.c and
my changes:
--- output_example.c Sun Apr 2 09:46:56 2006
+++ output_example_psp.c Mon Apr 3 16:53:40 2006
@@ -35,8 +35,9 @@
/* 5 seconds stream duration */
#define STREAM_DURATION 5.0
-#define STREAM_FRAME_RATE 25 /* 25 images/s */
-#define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE))
+#define STREAM_FRAME_RATE_DEN 2997 /* 25 images/s */
+#define STREAM_FRAME_RATE_NUM 100
+#define STREAM_NB_FRAMES ((int)(STREAM_DURATION * STREAM_FRAME_RATE_DEN /
STREAM_FRAME_RATE_NUM))
#define STREAM_PIX_FMT PIX_FMT_YUV420P /* default pix_fmt */
/**************************************************************/
@@ -68,7 +69,7 @@
/* put sample parameters */
c->bit_rate = 64000;
- c->sample_rate = 44100;
+ c->sample_rate = 24000;
c->channels = 2;
return st;
}
@@ -195,16 +196,16 @@
c->codec_type = CODEC_TYPE_VIDEO;
/* put sample parameters */
- c->bit_rate = 400000;
+ c->bit_rate = 480000;
/* resolution must be a multiple of two */
- c->width = 352;
- c->height = 288;
+ c->width = 320;
+ c->height = 240;
/* time base: this is the fundamental unit of time (in seconds) in
terms
of which frame timestamps are represented. for fixed-fps content,
timebase should be 1/framerate and timestamp increments should be
identically 1. */
- c->time_base.den = STREAM_FRAME_RATE;
- c->time_base.num = 1;
+ c->time_base.den = STREAM_FRAME_RATE_DEN;
+ c->time_base.num = STREAM_FRAME_RATE_NUM;
c->gop_size = 12; /* emit one intra frame every twelve frames at most
*/
c->pix_fmt = STREAM_PIX_FMT;
if (c->codec_id == CODEC_ID_MPEG2VIDEO) {
@@ -218,7 +219,7 @@
c->mb_decision=2;
}
// some formats want stream headers to be seperate
- if(!strcmp(oc->oformat->name, "mp4") || !strcmp(oc->oformat->name,
"mov") || !strcmp(oc->oformat->name, "3gp"))
+ if(!strcmp(oc->oformat->name, "mp4") || !strcmp(oc->oformat->name,
"mov") || !strcmp(oc->oformat->name, "3gp") || !strcmp(oc->oformat->name,
"psp"))
c->flags |= CODEC_FLAG_GLOBAL_HEADER;
return st;
@@ -420,7 +421,7 @@
/* auto detect the output format from the name. default is
mpeg. */
- fmt = guess_format(NULL, filename, NULL);
+ fmt = guess_format("psp", NULL, NULL);
if (!fmt) {
printf("Could not deduce output format from file extension: using
MPEG.\n");
fmt = guess_format("mpeg", NULL, NULL);
@@ -438,6 +439,7 @@
}
oc->oformat = fmt;
snprintf(oc->filename, sizeof(oc->filename), "%s", filename);
+ snprintf(oc->title, sizeof(oc->title), "test video");
/* add the audio and video streams using the default format codecs
and initialize the codecs */
Best regards
Lars
More information about the ffmpeg-devel
mailing list