Commit 78ba63ca authored by Jan Gerber's avatar Jan Gerber
Browse files

thanks to Fabio Pedretti for this 1 Jan 2006 patch.

parent 4a0b4f17
svn
- support encoding from .ogg input file.
- don't change samplerate and audio channel unless we use command line
options.
- don't change samplerate and audio channels unless we use command
line options -H or -c, or when the input channels are > 2
(limiting it to a maximum of 2).
- don't change the image resolution, unless we use the presets or the
-x or -y options (old default was to encode to preset preview).
- change the audio quality levels that were multiplied by 0.99, now
match the quality settings of oggenc, e.g. -a2 == -q2.
- add --optimize option: use a full search for motion vectors and
reduce Theora bitrate by about 5%, but it is slower.
- compile video4linux only under linux.
- update to help and man page.
0.15 2005-08-31
- ti.dropframes_p = 0 so we do not loos half of the frames.
......
.\" Hey, EMACS: -*- nroff -*-
.TH FFMPEG2THEORA 1 "November 27, 2005"
.TH FFMPEG2THEORA 1 "December 30, 2005"
.\" Please adjust this date whenever revising the manpage.
.\"
.\" Some roff macros, for reference:
......@@ -17,7 +17,7 @@ ffmpeg2theora \- command-line converter to create Ogg Theora and Ogg
Vorbis files.
.SH SYNOPSIS
.B ffmpeg2theora
.RI [ options ] " inputfile"
.RI [ options ] " inputfile"
.SH DESCRIPTION
This manual page documents briefly the \fBffmpeg2theora\fP command.
.PP
......@@ -29,35 +29,46 @@ To read from standard input, specify `\-' as the input filename.
These programs follow the usual GNU command line syntax, with long
options starting with two dashes (`-').
A summary of options is included below.
.SS Output options:
.SS General output options:
.TP
.B \-o, \-\-output
Specify the output filename. If no output filename is specified, output will
be written to \fIinputfile\fP.ogg. To output to standard output, specify
/dev/stdout as the output file.
.TP
.B \-s, \-\-starttime
Start encoding at this time (in seconds).
.TP
.B \-e, \-\-endtime
End encoding at this time (in seconds).
.TP
.B \-p, \-\-v2v-preset
Encode file with v2v preset. Right now, there is preview and pro. Run
\*(lqffmpeg2theora -p info\*(rq for more information.
.SS Video output options:
.TP
.B \-v, \-\-videoquality
[0 to 10] Set encoding quality for video (default: 5).
.TP
.B \-V, \-\-videobitrate
[45 to 2000] Set encoding bitrate for video (in kb/s).
[1 to 16000] Set encoding bitrate for video (in kb/s).
.TP
.B \-\-optimize
Optimize output Theora video, using a full search for motion vectors
instead of a hierarchical one. This can reduce video bitrate about 5%,
but it is slower and therefore is disabled by default.
.TP
.B \-x, \-\-width
Scale to given width.
Scale to given width (in pixels).
.TP
.B \-y, \-\-height
Scale to given height.
Scale to given height (in pixels).
.TP
.B \-\-aspect
Define frame aspect ratio (e.g. 4:3, 16:9).
.TP
.B \-\-crop[top|bottom|left|right]
Crop input before resizing.
.TP
.B \-\-optimize
Optimize output Theora video, using a full search for motion vectors
instead of a hierarchical one. This can reduce video bitrate about 5%,
but it is slower and therefore is disabled by default.
.B \-\-croptop, \-\-cropbottom, \-\-cropleft, \-\-cropright
Crop input by given pixels before resizing.
.TP
.B \-S, \-\-sharpness
[0 to 2] Sharpness of images (default: 2). Note: lower values make the video
......@@ -65,31 +76,22 @@ sharper.
.TP
.B \-K, \-\-keyint
[8 to 65536] Set keyframe interval (default: 64).
.SS Audio output options:
.TP
.B \-a, \-\-audioquality
[-2 to 10] Set encoding quality for audio (default: 1).
.TP
.B \-A, \-\-audiobitrate
[32 to 2000] Set encoding bitrate for audio (in kb/s).
.TP
.B \-H, \-\-samplerate
Set output samplerate (in Hz).
[32 to 500] Set encoding bitrate for audio (in kb/s).
.TP
.B \-c, \-\-channels
Set number of output channels.
.TP
.B \-H, \-\-samplerate
Set output samplerate (in Hz).
.TP
.B \-\-nosound
Disable the sound from input.
.TP
.B \-e, \-\-endtime
End encoding at this time (in seconds).
.TP
.B \-s, \-\-starttime
Start encoding at this time (in seconds).
.TP
.B \-p, \-\-v2v-preset
Encode file with v2v preset. Right now, there is preview and pro. Run
\*(lqffmpeg2theora -p info\*(rq for more information.
.SS Input options:
.TP
.B \-\-deinterlace
......@@ -100,24 +102,33 @@ deinterlaced.
Specify input format.
.TP
.B \-\-v4l /dev/video0
read data from v4l device /dev/video0,
you have to specify an output file with -0
read data from v4l device /dev/video0,
you have to specify an output file with -o.
.TP
.B \-\-inputfps
Override input fps.
.TP
.B \-\-audiostream id
By default the last audio stream is selected, use this to select
another audio stream.
.TP
.B \-\-sync
Use A/V sync from input container. Since this does not work with
all input format you have to manualy enable it if you have
issues with A/V sync.
.SS Metadata options:
.TP
.B \-\-artist
Name of artist (director)
Name of artist (director).
.TP
.B \-\-title
Title
Title.
.TP
.B \-\-date
Date
Date.
.TP
.B \-\-location
Location
Location.
.TP
.B \-\-organization
Name of organization (studio).
......@@ -129,12 +140,9 @@ Copyright.
License.
.SS Other options:
.TP
.B \-\-nice
.B \-\-nice n
Set niceness to n.
.TP
.B \-\-debug
Output some more information during encoding.
.TP
.B \-h, \-\-help
Output a help message.
.SH AUTHOR
......
......@@ -43,6 +43,7 @@
#endif
#define DEINTERLACE_FLAG 1
#define OPTIMIZE_FLAG 2
#define SYNC_FLAG 3
#define NOSOUND_FLAG 4
#ifdef VIDEO4LINUX_ENABLED
......@@ -55,7 +56,6 @@
#define ASPECT_FLAG 10
#define INPUTFPS_FLAG 11
#define AUDIOSTREAM_FLAG 12
#define OPTIMIZE_FLAG 13
#define V2V_PRESET_PRO 1
#define V2V_PRESET_PREVIEW 2
......@@ -226,8 +226,10 @@ void ff2theora_output(ff2theora this) {
for (i = 0; i < this->context->nb_streams; i++){
AVCodecContext *enc = this->context->streams[i]->codec;
switch (enc->codec_type){
case CODEC_TYPE_VIDEO:
if (this->video_index < 0)
this->video_index = i;
break;
......@@ -251,9 +253,9 @@ void ff2theora_output(ff2theora this) {
if(this->force_input_fps)
fps=this->force_input_fps;
if (vcodec == NULL || avcodec_open (venc, vcodec) < 0)
if (vcodec == NULL || avcodec_open (venc, vcodec) < 0) {
this->video_index = -1;
}
this->fps = fps;
if(this->preset == V2V_PRESET_PREVIEW){
......@@ -370,13 +372,15 @@ void ff2theora_output(ff2theora this) {
}
}
if (this->audio_index >= 0){
astream = this->context->streams[this->audio_index];
aenc = this->context->streams[this->audio_index]->codec;
acodec = avcodec_find_decoder (aenc->codec_id);
if(this->channels==-1) {
this->channels = aenc->channels;
if (this->channels == -1) {
if (aenc->channels > 2)
this->channels = 2;
else
this->channels = aenc->channels;
}
if(this->sample_rate==-1) {
this->sample_rate = aenc->sample_rate;
......@@ -501,7 +505,7 @@ void ff2theora_output(ff2theora this) {
if(this->start_time) {
av_seek_frame( this->context, -1, (int64_t)AV_TIME_BASE*this->start_time, 1);
}
/*check for end time and caclulate number of frames to encode*/
/*check for end time and calculate number of frames to encode*/
no_frames = fps*(this->end_time - this->start_time);
if(this->end_time > 0 && no_frames <= 0){
fprintf(stderr,"end time has to be bigger than start time\n");
......@@ -739,96 +743,107 @@ int crop_check(ff2theora this, char *name, const char *arg)
void print_presets_info() {
fprintf (stderr,
fprintf (stdout,
// "v2v presets - more info at http://wiki.v2v.cc/presets"
"v2v presets\n"
"preview\t\thalf size DV video. encoded with Ogg Theora/Ogg Vorbis\n"
"\t\t\tVideo: Quality 5;\n"
"\t\t\tAudio: Quality 1 - Stereo\n\n"
"pro\t\tfull size DV video. encoded with Ogg Theora/Ogg Vorbis \n"
"\t\t\tVideo: Quality 7;\n"
"\t\t\tAudio: Quality 3 - Stereo\n"
"\n");
"v2v presets:\n"
" preview Video: 384x288 if fps ~ 25, 320x240 if fps ~ 30\n"
" Quality 5 - Sharpness 2\n"
" Audio: Max 2 channels - Quality 1\n"
"\n"
" pro Video: 720x576 if fps ~ 25, 720x480 if fps ~ 30\n"
" Quality 7 - Sharpness 0\n"
" Audio: Max 2 channels - Quality 3\n"
"\n"
);
}
void print_usage (){
fprintf (stdout,
PACKAGE " " PACKAGE_VERSION "\n\n"
" usage: " PACKAGE " [options] input\n\n"
"Output options:\n"
"\t --output,-o\t\talternative output filename\n"
"\t --videoquality,-v\t[0 to 10] encoding quality for video\n"
"\t \t (default: 5)\n"
"\t --videobitrate,-V\t[45 to 2000] encoding bitrate for video\n"
"\t --width, -x\t\tscale to given size\n"
"\t --height,-y\t\tscale to given size\n"
"\t --aspect\t\tdefine frame aspect ratio: i.e. 4:3 or 16:9\n"
"\t --crop[top|bottom|left|right]\tcrop input before resizing\n"
"\t --optimize \toptimize video output filesize (very slow)\n"
"\t --sharpness,-S \t[0 to 2] sharpness of images (default: 2)\n"
"\t \t { lower values make the video sharper. }\n"
"\t --keyint,-K \t[8 to 65536] keyframe interval (default: 64)\n"
"\t --audioquality,-a\t[-2 to 10] encoding quality for audio\n"
"\t \t (default: 1)\n"
"\t --audiobitrate,-A\t[32 to 2000] encoding bitrate for audio\n"
"\t --samplerate,-H\tset output samplerate in Hz\n"
"\t --channels,-c\t\tset number of output sound channels\n"
"\t --nosound\t\tdisable the sound from input\n"
"\t --endtime,-e\t\tend encoding at this time (in sec)\n"
"\t --starttime,-s\t\tstart encoding at this time (in sec)\n"
"\t --v2v-preset,-p\tencode file with v2v preset, \n"
"\t\t\t\t right now there is preview and pro,\n"
"\t\t\t\t '"PACKAGE" -p info' for more informations\n"
"\nInput options:\n"
"\t --deinterlace \t\tforce deinterlace\n"
"\t\t\t\totherwise only material marked as interlaced \n"
"\t\t\t\twill be deinterlaced\n"
"\t --format,-f\t\tspecify input format\n"
PACKAGE " " PACKAGE_VERSION "\n"
"\n"
" Usage: " PACKAGE " [options] input\n"
"\n"
"General output options:\n"
" -o, --output alternative output filename\n"
" -s, --starttime start encoding at this time (in sec.)\n"
" -e, --endtime end encoding at this time (in sec.)\n"
" -p, --v2v-preset encode file with v2v preset.\n"
" Right now there is preview and pro. Run\n"
" '"PACKAGE" -p info' for more informations\n"
"\n"
"Video output options:\n"
" -v, --videoquality [0 to 10] encoding quality for video\n"
" (default: 5)\n"
" -V, --videobitrate [1 to 16000] encoding bitrate for video (kb/s)\n"
" --optimize optimize video output filesize (slower)\n"
" -x, --width scale to given width (in pixels)\n"
" -y, --height scale to given height (in pixels)\n"
" --aspect define frame aspect ratio: i.e. 4:3 or 16:9\n"
" --croptop, --cropbottom, --cropleft, --cropright\n"
" crop input by given pixels before resizing\n"
" -S, --sharpness [0 to 2] sharpness of images (default: 2).\n"
" Note: lower values make the video sharper.\n"
" -K, --keyint [8 to 65536] keyframe interval (default: 64)\n"
"\n"
"Audio output options:\n"
" -a, --audioquality [-2 to 10] encoding quality for audio\n"
" (default: 1)\n"
" -A, --audiobitrate [32 to 500] encoding bitrate for audio (kb/s)\n"
" -c, --channels set number of output channels\n"
" -H, --samplerate set output samplerate (in Hz)\n"
" --nosound disable the sound from input\n"
"\n"
"Input options:\n"
" --deinterlace force deinterlace, otherwise only material\n"
" marked as interlaced will be deinterlaced\n"
" -f, --format specify input format\n"
#ifdef VIDEO4LINUX_ENABLED
"\t --v4l /dev/video0\tread data from v4l device /dev/video0\n"
"\t \t\tyou have to specifiy an output file with -o\n"
" --v4l /dev/video0 read data from v4l device /dev/video0\n"
" you have to specifiy an output file with -o\n"
#endif
"\t --inputfps [fps]\toverride input fps\n"
"\t --audiostream streamid\tby default the last audiostream is selected,\n"
"\t \tuse this to select another audio stream\n"
"\t --sync\t\t\tUse A/V Sync from input container.\n"
"\t \t\tsince this does not work with all input format\n"
"\t \t\tyou have to manualy enable it if you have issues\n"
"\t \t\twith A/V sync.\n"
"\nMetadata options:\n"
"\t --artist\tName of artist (director)\n"
"\t --title\tTitle\n"
"\t --date\t\tDate\n"
"\t --location\tLocation\n"
"\t --organization\tName of organization (studio)\n"
"\t --copyright\tCopyright\n"
"\t --license\tLicence\n"
"\nOther options:\n"
" --inputfps fps override input fps\n"
" --audiostream id by default the last audio stream is selected,\n"
" use this to select another audio stream\n"
" --sync use A/V sync from input container.\n"
" Since this does not work with all input format\n"
" you have to manualy enable it if you have\n"
" issues with A/V sync\n"
"\n"
"Metadata options:\n"
" --artist Name of artist (director)\n"
" --title Title\n"
" --date Date\n"
" --location Location\n"
" --organization Name of organization (studio)\n"
" --copyright Copyright\n"
" --license License\n"
"\n"
"Other options:\n"
#ifndef _WIN32
"\t --nice\t\t\tset niceness to n\n"
" --nice n set niceness to n\n"
#endif
"\t --help,-h\t\tthis message\n"
"\n Examples:\n"
"\tffmpeg2theora videoclip.avi (will write output to videoclip.ogg)\n\n"
"\tcat something.dv | ffmpeg2theora -f dv -o output.ogg -\n\n"
" -h, --help this message\n"
"\n"
"Examples:\n"
" ffmpeg2theora videoclip.avi (will write output to videoclip.ogg)\n"
"\n"
" cat something.dv | ffmpeg2theora -f dv -o output.ogg -\n"
"\n"
#ifdef VIDEO4LINUX_ENABLED
"\tLive streaming from V4L Device:\n"
"\t ffmpeg2theora --v4l /dev/video0 --inputfps 15 -x 160 -y 128 -o - \\ \n"
"\t\t | oggfwd iccast2server 8000 password /theora.ogg\n\n"
" Live streaming from V4L Device:\n"
" ffmpeg2theora --v4l /dev/video0 --inputfps 15 -x 160 -y 128 -o - \\\n"
" | oggfwd iccast2server 8000 password /theora.ogg\n"
"\n"
#endif
"\tLive encoding from a DV camcorder (needs a fast machine):\n"
"\t dvgrab - | ffmpeg2theora -f dv -x 352 -y 288 -o output.ogg -\n"
"\n\tLive encoding and streaming to icecast server:\n"
"\t dvgrab --format raw - | \\\n"
"\t ffmpeg2theora -f dv -x 160 -y 128 -o /dev/stdout - | \\\n"
"\t oggfwd iccast2server 8000 password /theora.ogg\n"
"\n");
" Live encoding from a DV camcorder (needs a fast machine):\n"
" dvgrab - | ffmpeg2theora -f dv -x 352 -y 288 -o output.ogg -\n"
"\n"
" Live encoding and streaming to icecast server:\n"
" dvgrab --format raw - | \\\n"
" ffmpeg2theora -f dv -x 160 -y 128 -o /dev/stdout - | \\\n"
" oggfwd iccast2server 8000 password /theora.ogg\n"
"\n"
);
exit (0);
}
......@@ -839,8 +854,8 @@ int main (int argc, char **argv){
char inputfile_name[255];
char *str_ptr;
static int flag=-1;
static int metadata_flag=0;
static int flag = -1;
static int metadata_flag = 0;
AVInputFormat *input_fmt = NULL;
AVFormatParameters *formatParams = NULL;
......@@ -909,16 +924,16 @@ int main (int argc, char **argv){
switch (flag)
{
case DEINTERLACE_FLAG:
convert->deinterlace=1;
flag=-1;
convert->deinterlace = 1;
flag = -1;
break;
case SYNC_FLAG:
convert->sync=1;
flag=-1;
convert->sync = 1;
flag = -1;
break;
case NOSOUND_FLAG:
convert->disable_audio=1;
flag=-1;
convert->disable_audio = 1;
flag = -1;
break;
case OPTIMIZE_FLAG:
convert->quick_p = 0;
......@@ -928,37 +943,37 @@ int main (int argc, char **argv){
case V4L_FLAG:
formatParams = malloc(sizeof(AVFormatParameters));
formatParams->device = optarg;
flag=-1;
flag = -1;
break;
#endif
/* crop */
case CROPTOP_FLAG:
convert->frame_topBand=crop_check(convert,"top",optarg);
flag=-1;
convert->frame_topBand = crop_check(convert,"top",optarg);
flag = -1;
break;
case CROPBOTTOM_FLAG:
convert->frame_bottomBand=crop_check(convert,"bottom",optarg);
flag=-1;
convert->frame_bottomBand = crop_check(convert,"bottom",optarg);
flag = -1;
break;
case CROPRIGHT_FLAG:
convert->frame_rightBand=crop_check(convert,"right",optarg);
flag=-1;
convert->frame_rightBand = crop_check(convert,"right",optarg);
flag = -1;
break;
case CROPLEFT_FLAG:
convert->frame_leftBand=crop_check(convert,"left",optarg);
flag=-1;
convert->frame_leftBand = crop_check(convert,"left",optarg);
flag = -1;
break;
case ASPECT_FLAG:
convert->frame_aspect=aspect_check(optarg);
flag=-1;
convert->frame_aspect = aspect_check(optarg);
flag = -1;
break;
case INPUTFPS_FLAG:
convert->force_input_fps=atof(optarg);
flag=-1;
convert->force_input_fps = atof(optarg);
flag = -1;
break;
case AUDIOSTREAM_FLAG:
convert->audiostream=atoi(optarg);;
flag=-1;
convert->audiostream = atoi(optarg);;
flag = -1;
break;
}
}
......@@ -1020,8 +1035,8 @@ int main (int argc, char **argv){
break;
case 'V':
convert->video_bitrate=rint(atof(optarg)*1000);
if(convert->video_bitrate<0 || convert->video_bitrate>2000000){
fprintf(stderr,"only values from 0 to 2000000 are valid for video bitrate(in kb/s)\n");
if (convert->video_bitrate < 1000 || convert->video_bitrate > 16000000) {
fprintf(stderr, "only values from 1 to 16000 are valid for video bitrate (in kb/s)\n");
exit(1);
}
convert->video_quality=0;
......@@ -1040,7 +1055,7 @@ int main (int argc, char **argv){
fprintf(stderr,"only values >0 are valid for audio bitrate\n");
exit(1);
}
convert->audio_quality=-990;
convert->audio_quality = -990;
break;
case 'S':
convert->sharpness = atoi(optarg);
......@@ -1074,16 +1089,14 @@ int main (int argc, char **argv){
convert->preset=V2V_PRESET_PRO;
convert->video_quality = rint(7*6.3);
convert->audio_quality = 3.00;
convert->channels=2;
convert->sharpness=0;
convert->sharpness = 0;
}
else if(!strcmp(optarg,"preview")){
//need a way to set resize here. and not later
convert->preset=V2V_PRESET_PREVIEW;
convert->video_quality = rint(5*6.3);
convert->audio_quality = 1.00;
convert->channels=2;
convert->sharpness=2;
convert->sharpness = 2;
}
else{
fprintf(stderr,"\nunknown preset.\n\n");
......
#!/bin/sh
#optional, if you have the libs installed:
#extra="--enable-faad --enable-dts"
#extra="--enable-faad --enable-dts --enable-libgsm --enable-amr_nb --enable-amr_nb-fixed --enable-amr_wb --enable-amr_if2"
cvs -z3 -d:pserver:anonymous@cvs.mplayerhq.hu:/cvsroot/ffmpeg/ co ffmpeg
cd ffmpeg
./configure --enable-libogg --enable-theora --enable-a52 --enable-pthreads --enable-gpl --disable-encoders $extra
cvs -z3 -d:pserver:anonymous@cvs.mplayerhq.hu:/cvsroot/ffmpeg co ffmpeg
cd ffmpeg && ./configure --enable-libogg --enable-theora --enable-a52 --enable-pthreads --enable-gpl --disable-encoders --disable-muxes $extra && make
make
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment