Как сделать проще и быстрее работу с ffmpeg
Эта программа работает в графическом и терминальном режиме сразу. Она дополняет и упрощает работу по редактированию видео-файлов с помощью мощной терминальной программы ffmpeg.
Особенности работы
- многопоточность -- для каждого файла открывается свой поток -- можно не ждать окончания обработки предыдущего задания;
- можно задавать свои метаданные;
- оптимизированная матрица кодирования:
- готовые шаблоны видео-фильтров
- и многое другое.
Зависимости
- ffmpeg
Листинг файла программы на С
;;; todo
#include "proc.h"
#include <gtk/gtk.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <regex.h>
/********************************************/
/* datas */
/********************************************/
char infile_name[255], infile_sub[255], outfile_name[255];
char* outfile_type = ".mpg" ;
char* aspect="4:3", *resize="720:576";
char* map_sub="", *map_sub_add="";
char* h264_preset="slow";
char* h264_tune="grain";
char video_filter[1023], outfile_title[511];
char* b_frame="1", *quality="6" ;
char* acanal="2", *abitrate="192";
int calfil[30];
int h264 = 0, file_info = 0;
char time_start[63]="0", time_end[63]="36000";
char bitrate[63] = "1000";
long int t_start, t_end;
char* inter_matrix = "16,17,18,19,20,21,22,23,"
"17,18,19,20,21,22,23,24,"
"18,19,20,21,22,23,24,25,"
"19,20,21,22,23,24,26,27,"
"20,21,22,23,25,26,27,28,"
"21,22,23,24,26,27,28,30,"
"22,23,24,26,27,28,30,31,"
"23,24,25,27,28,30,31,33" ;
#define FLT_NAME_1 "f::Нормализация изображения YUV=4:4:4"
#define FLT_1 ",format=yuv444p,normalize=blackpt=black:whitept=white:smoothing=50:independence=0"
#define FLT_AVC_1 ""
#define FLT_NAME_2 "YUV=4:2:0"
#define FLT_2 ",format=yuv420p"
#define FLT_AVC_2 ",format=yuv420p"
#define FLT_NAME_3 "f::Авто яркость,контраст,деблок"
#define FLT_3 ",pp=ac"
#define FLT_AVC_3 ""
#define FLT_NAME_4 "Временной--улучшение сжимаемости"
#define FLT_4 ",atadenoise"
#define FLT_AVC_4 ",hqdn3d"
#define FLT_NAME_5 "Увеличение резкости sharpen/яркость+цвет"
#define FLT_5 ",unsharp=5:5:2:5:5:1.5"
#define FLT_AVC_5 ",unsharp=5:5:2:5:5:1.5"
#define FLT_NAME_6 "Увеличение резкости sharpen/яркость"
#define FLT_6 ",unsharp=5:5:1.5"
#define FLT_AVC_6 ",unsharp=5:5:1.5"
#define FLT_NAME_7 "Деинтерлейс"
#define FLT_7 ",kerndeint=sharp=1:twoway=1"
#define FLT_AVC_7 ",yadif"
#define FLT_NAME_8 "Отражение/по горизонтали"
#define FLT_8 ",hflip"
#define FLT_AVC_8 ",hflip"
#define FLT_NAME_9 "Отражение/по вертикали "
#define FLT_9 ",vflip"
#define FLT_AVC_9 ",vflip"
#define FLT_NAME_11 "f::Устранение дрожания"
#define FLT_11 ",deshake=rx=64:ry=64"
#define FLT_AVC_11 ""
#define FLT_NAME_12 "Преобразование аспекта/2.21:1 -> 16:9/HD"
#define FLT_12 ",scale=1588:720,crop=1280:720:154:0"
#define FLT_AVC_12 ",scale=1588:720,crop=1280:720:154:0"
#define FLT_NAME_13 "Преобразование аспекта/2.21:1 -> 16:9/MPEG"
#define FLT_13 ",scale=896:576,crop=720:576:88:0"
#define FLT_AVC_13 ",scale=896:576,crop=720:576:88:0"
#define FLT_NAME_14 "Преобразование аспекта/16:9 -> 4:3/HD"
#define FLT_14 ",scale=1706:960,crop=1280:960:213:0"
#define FLT_AVC_14 ",scale=1706:960,crop=1280:960:213:0"
#define FLT_NAME_15 "Преобразование аспекта/16:9 -> 4:3/MPEG"
#define FLT_15 ",scale=1024:576,crop=720:576:152:0"
#define FLT_AVC_15 ",scale=1024:576,crop=720:576:152:0"
#define FLT_NAME_16 "Преобразование аспекта/ 4:3 -> 3:4/HD"
#define FLT_16 ",scale=1280:960,crop=720:960:280:0"
#define FLT_AVC_16 ",scale=1280:960,crop=720:960:280:0"
#define FLT_NAME_17 "Преобразование аспекта/ 4:3 -> 3:4/MPEG"
#define FLT_17 ",scale=768:576,crop=720:576:168:0"
#define FLT_AVC_17 ",scale=768:576,crop=720:576:168:0"
#define FLT_NAME_18 "Изменение яркости/х0.5"
#define FLT_18 ",lutyuv=y=val*0.5"
#define FLT_AVC_18 ",lutyuv=y=val*0.5"
#define FLT_NAME_19 "Изменение яркости/х1.2"
#define FLT_19 ",lutyuv=y=val*1.2"
#define FLT_AVC_19 ",lutyuv=y=val*1.2"
#define FLT_NAME_21 "Изменение яркости/х1.5"
#define FLT_21 ",lutyuv=y=val*1.5"
#define FLT_AVC_21 ",lutyuv=y=val*1.5"
#define FLT_NAME_22 "Изменение яркости/х2.0"
#define FLT_22 ",lutyuv=y=val*2.0"
#define FLT_AVC_22 ",lutyuv=y=val*2.0"
#define FLT_NAME_23 "Поворот/по часовой"
#define FLT_23 ",transpose=1"
#define FLT_AVC_23 ",transpose=1"
#define FLT_NAME_24 "Поворот/против часовой"
#define FLT_24 ",transpose=2"
#define FLT_AVC_24 ",transpose=2"
#define FLT_NAME_25 "Преобразование аспекта/ 16:9 внутрь 4:3/MPEG"
#define FLT_25 ",scale=720:404,pad=720:540:0:68"
#define FLT_AVC_25 ",scale=720:404,pad=720:540:0:68"
#define FLT_NAME_26 "Преобразование аспекта/2.21:1 внутрь 16:9/MPEG"
#define FLT_26 ",scale=720:326,pad=720:406:0:40"
#define FLT_AVC_26 ",scale=720:576,pad=720:406:0:40"
/********************************************/
/* procedures */
/********************************************/
static void add_filter(){
video_filter[0]='0';
strcpy( video_filter,( 0 == h264 )? "atadenoise" : "hqdn3d" );
if( 12 == calfil[12] ) strcat( video_filter, FLT_12 );
if( 13 == calfil[13] ) strcat( video_filter, FLT_13 );
if( 14 == calfil[14] ) strcat( video_filter, FLT_14 );
if( 15 == calfil[15] ) strcat( video_filter, FLT_15 );
if( 16 == calfil[16] ) strcat( video_filter, FLT_16 );
if( 17 == calfil[17] ) strcat( video_filter, FLT_17 );
if( 18 == calfil[18] ) strcat( video_filter, FLT_18 );
if( 19 == calfil[19] ) strcat( video_filter, FLT_19 );
if( 21 == calfil[21] ) strcat( video_filter, FLT_21 );
if( 22 == calfil[22] ) strcat( video_filter, FLT_22 );
if( 23 == calfil[23] ) strcat( video_filter, FLT_23 );
if( 24 == calfil[24] ) strcat( video_filter, FLT_24 );
if( 26 == calfil[26] ) strcat( video_filter, FLT_26 );
if( 25 == calfil[25] ) strcat( video_filter, FLT_25 );
char scl[24];
char *sc=",scale=";
strcpy ( scl, sc );
strcat ( scl, resize );
strcat ( video_filter, scl );
if( 1 == calfil[1] ) strcat( video_filter, FLT_1 );
if( 2 == calfil[2] ) strcat( video_filter, FLT_2 );
if( 3 == calfil[3] ) strcat( video_filter, FLT_3 );
/* Этот фильтр включен по умолчанию */
/* if( 4 == calfil[4] ) strcat( video_filter, FLT_4 );*/
if( 5 == calfil[5] ) strcat( video_filter, FLT_5 );
if( 6 == calfil[6] ) strcat( video_filter, FLT_6 );
if( 7 == calfil[7] ) strcat( video_filter, FLT_7 );
if( 8 == calfil[8] ) strcat( video_filter, FLT_8 );
if( 9 == calfil[9] ) strcat( video_filter, FLT_9 );
if( 11 == calfil[11] ) strcat( video_filter, FLT_11 );
g_message ( "-vf : %s!n", video_filter );
}
/********************************************/
int a2a ( const gchar* in ){
g_message (" --= start a2a =--%s!n", in);
int out = 0;
int i = strlen ( in ) -1 ;;
for ( i; i >=0; i-- ){
// g_message (" in[%d]=%c=%d n", i, in[i], in[i] );
if ( '.' > in[i] || ':' < in[i] ){
out = 1;
// g_message (" %s!n", "not number");
continue;
}
}
return out;
}
/********************************************/
static void enter_callback_start( GtkWidget *widget,
GtkWidget *entry_start )
{
const gchar *entry_text;
entry_text = gtk_entry_get_text (GTK_ENTRY (entry_start));
strcpy( time_start, entry_text );
printf ("Entry contents: %sn", time_start);
}
/********************************************/
static void enter_callback_stop( GtkWidget *widget,
GtkWidget *entry_stop )
{
const gchar *entry_text;
entry_text = gtk_entry_get_text (GTK_ENTRY (entry_stop));
strcpy( time_end, entry_text );
printf ("Entry contents: %sn", time_end);
}
/********************************************/
static void enter_callback_title_file( GtkWidget *widget,
GtkWidget *entry_title_file )
{
const gchar *entry_text;
entry_text = gtk_entry_get_text (GTK_ENTRY (entry_title_file));
strcpy(outfile_title, entry_text );
printf ("Entry contents: %sn", outfile_title);
}
/********************************************/
static void enter_callback_bitrate( GtkWidget *widget,
GtkWidget *entry_bitrate )
{
const gchar *entry_text;
entry_text = gtk_entry_get_text (GTK_ENTRY (entry_bitrate));
strcpy(bitrate, entry_text );
printf ("Entry contents: %sn", bitrate);
}
/********************************************/
/* Obligatory basic callback */
static void f_open_sub( GtkWidget *w,
gpointer data ) {
insub();
// file_info = 0;
g_message ("new %s!n", infile_sub);
}
/********************************************/
static void h_about( GtkWidget *w,
gpointer data ) {
about();
g_message ("open %s!n", "about");
}
/********************************************/
static void f_open( GtkWidget *w,
gpointer data ) {
infile();
file_info = 0;
g_message ("open %s!n", infile_name);
}
/********************************************/
static void f_info( GtkWidget *w,
gpointer data ) {
infile();
file_info = 1;
g_message ("info %s!n", infile_name);
}
/********************************************/
static void f_save_mpg( GtkWidget *w,
gpointer data ) {
outfile_type = ".mpg";
outfile();
h264 = 0;
g_message ("%sn", outfile_name);
}
/********************************************/
static void f_save_gif( GtkWidget *w,
gpointer data ) {
outfile_type = ".gif";
outfile();
h264 = 0;
g_message ("%sn", outfile_name);
}
/**********************************************/
static void f_save_mkv( GtkWidget *w,
gpointer data ) {
outfile_type = ".mkv" ;
outfile();
h264 = 0;
g_message ("%sn", outfile_name);
}
/**********************************************/
static void f_save_mkv_h264( GtkWidget *w,
gpointer data ) {
outfile_type = ".mkv" ;
outfile();
h264 = 1;
g_message ("%sn", outfile_name);
}
/**********************************************/
static void f_save_mkv_h264_2pass( GtkWidget *w,
gpointer data ) {
outfile_type = ".mkv" ;
outfile();
h264 = 2;
g_message ("%sn", outfile_name);
}
/**********************************************/
static void f_save_mp4( GtkWidget *w,
gpointer data ) {
outfile_type = ".mp4" ;
outfile();
h264 = 1;
g_message ("%sn", outfile_name);
}
/**********************************************/
static void f_save_avi( GtkWidget *w,
gpointer data ) {
outfile_type = ".avi" ;
outfile();
h264 = 0;
g_message ("%sn", outfile_name);
}
/*******************************************/
static int selected_time( GtkWidget *widget, GtkWidget *entry_lin) {
/* timer()*/
g_message ("%sn", " Start timer" );
if ( 0 != a2a ( time_start ) || 0 != a2a ( time_end ) ){
g_message ("%sn", " Время и длительность должны быть числами" );
return 1;
}
if ( 0 != a2a ( bitrate ) ){
if ( 'k' != bitrate[ strlen ( bitrate ) -1 ] ){
g_message ("%sn", " Битрейт должен быть числом" );
return 1;}
}else{
strcat ( bitrate, "k" );
}
g_message ("bitrate = %sn", bitrate);
if ( NULL == infile_name ){
g_message ("%sn", " не задан входной файл" );
return 1;
}
if ( NULL == outfile_name ){
g_message ("%sn", " не задан выходной файл" );
return 1;
}
g_message ("%sn", " File names -- OK" );
add_filter();
g_message ("%s : %s : %sn", " :278", outfile_name, outfile_type );
strcat( outfile_name, outfile_type );
g_message ("outfile_name = %sn", outfile_name );
char mtitle[400]="title=";
strcat( mtitle, outfile_title );
strcat( mtitle, ":software=gtk_video_converter-" );
strcat( mtitle, PROGRAMM_VERSION );
g_message ("%sn", " :283" );
char* ffmpeg_xvid_args[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",infile_name,
"-map","0:v","-c:v","libxvid","-vtag","XVID","-qmin","0",
"-qmax",quality,"-bufsize","4096","-mbd","rd","-flags","+qpel",
/*"-coder","1",*/"-subq","8",/*"-psy-rd","1.0:0.8",*/"-bf",b_frame,
/*"-trellis","1","-cmp","satd",*/"-r","24",
"-aspect",aspect,"-vf",video_filter,"-metadata", mtitle,"-s",resize,
"-inter_matrix",inter_matrix,"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,
outfile_name,
NULL };
g_message ("%sn", " :295" );
char* ffmpeg_xvid_args_sub[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",infile_name,
"-map","0:v","-c:v","libxvid","-vtag","XVID","-qmin","0",
"-qmax",quality,"-bufsize","4096","-mbd","rd","-flags","+qpel",
"-subq","8","-bf",b_frame,
"-cmp","satd","-r","24",
"-aspect",aspect,"-vf",video_filter,"-metadata", mtitle,"-s",resize,
"-inter_matrix",inter_matrix,"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,"-map","0:s",
outfile_name,
NULL };
char* ffmpeg_xvid_args_sub_add[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",
infile_name, "-i", infile_sub,
"-map","0:v","-c:v","libxvid","-vtag","XVID","-qmin","0",
"-qmax",quality,"-bufsize","4096","-mbd","rd","-flags","+qpel",
"-subq","8","-bf",b_frame,
"-cmp","satd","-r","24",
"-aspect",aspect,"-vf",video_filter,"-metadata", mtitle,"-s",resize,
"-inter_matrix",inter_matrix,"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,"-map","0:s","-map","1",
outfile_name,
NULL };
char* ffmpeg_xvid_args_add[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",
infile_name, "-i", infile_sub,
"-map","0:v","-c:v","libxvid","-vtag","XVID","-qmin","0",
"-qmax",quality,"-bufsize","4096","-mbd","rd","-flags","+qpel",
"-subq","8","-bf",b_frame,
"-cmp","satd","-r","24",
"-aspect",aspect,"-vf",video_filter,"-metadata", mtitle,"-s",resize,
"-inter_matrix",inter_matrix,"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,/*"-map","0:s",*/"-map","1",
outfile_name,
NULL };
g_message ("%sn", " :307" );
char* ffmpeg_mpg_args[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",infile_name,
"-target","pal-dvd",
"-map","0:v","-c:v","mpeg2video","-vf",video_filter,"-mbd","rd",
"-trellis","1","-cmp","2",
"-subcmp","2","-b_strategy","1","-mpv_flags","+skip_rd+qp_rd+cbp_rd",
"-qscale",quality, "-s",resize, "-aspect",aspect,"-metadata", mtitle,
"-inter_matrix",inter_matrix,"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,
outfile_name,
NULL };
char ffmpeg_gif[511];
sprintf ( ffmpeg_gif,
"ffmpeg -y -ss %s -t %s -i '%s' -f gif -filter_complex "
" '[0:v] fps=9,scale=480:-1,split[a][b];"
"[a] palettegen=max_colors=128 [p];"
"[b][p] paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle'"
" %s",
time_start,time_end,infile_name, outfile_name );
g_message ("%sn", ffmpeg_gif );
g_message ("%sn", " :319" );
char* avconv_mp4_args[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",infile_name,
"-map","0:v","-c:v","libx265","-preset",h264_preset,
"-tune",h264_tune,"-crf","20","-r","24",
"-aspect",aspect,"-vf",video_filter,"-s",resize,"-metadata", mtitle,
"-map","0:a","-ar","44100",
"-ac","2","-ab",abitrate,
outfile_name,
NULL };
g_message ("%sn", " :329" );
char* avconv_mkv_args[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",infile_name,
"-map","0:v","-c:v","libx265","-preset",h264_preset,
"-tune",h264_tune,"-crf","20","-r","24",
"-aspect",aspect,"-vf",video_filter,"-s",resize,"-metadata", mtitle,
"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,
outfile_name,
NULL };
char avconv_mkv_args1pass[511];
sprintf ( avconv_mkv_args1pass,
"ffmpeg -y -ss %s -t %s -i '%s' -map 0:v -c:v libx265 "
"-tune %s -b:v %s -r 24 -s %s -aspect %s -vf %s -pass 1 "
"-an -sn -f null /dev/null",
time_start,time_end,infile_name,h264_tune,bitrate,resize,aspect,video_filter );
char* avconv_mkv_args2pass[] = {
"ffmpeg","-y","-ss",time_start, "-t",time_end, "-i",infile_name,
"-map","0:v", "-c:v","libx265",
"-tune",h264_tune, "-b:v",bitrate, "-r","24","-vf",video_filter, "-s",resize,
"-aspect",aspect, "-metadata", mtitle, "-pass","2",
"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,
outfile_name,
NULL };
char* avconv_mkv_args2pass_sub[] = {
"ffmpeg","-y","-ss",time_start, "-t",time_end, "-i",infile_name,
"-map","0:v", "-c:v","libx265",
"-tune",h264_tune, "-b:v",bitrate, "-r","24","-vf",video_filter,
"-s",resize, "-aspect",aspect, "-metadata", mtitle, "-pass","2",
"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,"-map","0:s",
outfile_name,
NULL };
char* avconv_mkv_args2pass_addsub[] = {
"ffmpeg","-y","-ss",time_start, "-t",time_end, "-i",infile_name,
"-i", infile_sub,
"-map","0:v", "-c:v","libx265",
"-tune",h264_tune, "-b:v",bitrate, "-r","24","-vf",video_filter,
"-s",resize, "-aspect",aspect, "-metadata", mtitle, "-pass","2",
"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,"-map","1",
outfile_name,
NULL };
g_message ("%sn", " :339" );
char* avconv_mkv_args_sub[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",infile_name,
"-map","0:v","-c:v","libx265","-preset",h264_preset,
"-tune",h264_tune,"-crf","20","-r","24","-vf",video_filter,
"-s",resize, "-aspect",aspect,"-metadata", mtitle,
"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,"-map","0:s",
outfile_name,
NULL };
char* avconv_mkv_args_sub_add[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",
infile_name, "-i", infile_sub,
"-map","0:v","-c:v","libx265","-preset",h264_preset,
"-tune",h264_tune,"-crf","20","-r","24","-vf",video_filter,
"-s",resize, "-aspect",aspect,"-metadata", mtitle,
"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,"-map","0:s","-map","1",
outfile_name,
NULL };
char* avconv_mkv_args_add[] = {
"ffmpeg","-y","-ss",time_start,"-t",time_end,"-i",
infile_name, "-i", infile_sub,
"-map","0:v","-c:v","libx264","-preset",h264_preset,
"-tune",h264_tune,"-crf","20","-r","24","-vf",video_filter,
"-s",resize, "-aspect",aspect,"-metadata", mtitle,
"-map","0:a","-c:a","ac3","-ar","48000",
"-ac",acanal,"-ab",abitrate,/*"-map","0:s",*/"-map","1",
outfile_name,
NULL };
pid_t result;
g_message ("%sn", "start timer");
result = fork ();
if( -1 == result ){
g_message( "fork errorn" );
return 1;
}
g_message ("%dn", file_info);
if ( result == 0 ){
if ( 1 == file_info ) {
g_message ("%sn", "start file_info-play:353");
file_info = 0;
execlp ("ffmpeg","ffmpeg","-i",infile_name, NULL );
g_message( "execve errorn" );
return 1;
}
if ( 0 == h264 ) {
g_message ("%sn", "start ffmpeg:360");
if (".gif" == outfile_type ){
system ( ffmpeg_gif );
}else{
execvp ("ffmpeg",
(".mpg" == outfile_type )?ffmpeg_mpg_args:
("1" == map_sub && "2" == map_sub_add)?ffmpeg_xvid_args_sub_add:
("1" == map_sub)?ffmpeg_xvid_args_sub:
("2" == map_sub_add)?ffmpeg_xvid_args_add: ffmpeg_xvid_args);
g_message( "execve errorn" );
return 1;
}
}
if ( 1 == h264 ) {
g_message ("%sn", "start h264:368");
execvp ("ffmpeg",
(".mp4" == outfile_type )? avconv_mp4_args:
("1" == map_sub && "2" == map_sub)?avconv_mkv_args_sub_add:
("1" == map_sub)?avconv_mkv_args_sub:
("2" == map_sub)?avconv_mkv_args_add: avconv_mkv_args );
g_message( "execve errorn" );
return 1;
}
if ( 2 == h264 ) {
h264 = 0;
g_message ("h264=%d, %sn",h264, "start h264:471 1 pass");
system ( avconv_mkv_args1pass );
g_message ("h264=%d, %sn",h264, "start h264:471 2 pass");
execvp ( "ffmpeg",
("1" == map_sub)?avconv_mkv_args2pass_sub:
("2" == map_sub)?avconv_mkv_args2pass_addsub: avconv_mkv_args2pass );
g_message( "execve errorn" );
return 1;
}
/* if ( 3 == h264 ) {
h264 = 0;
g_message ("h264=%d, %sn",h264, "start h264:471 2 pass");
execvp ( "avconv",
("1" == map_sub)?avconv_mkv_args2pass_sub:
("2" == map_sub)?avconv_mkv_args2pass_addsub: avconv_mkv_args2pass );
g_message( "execve errorn" );
return 1;
}*/
g_message ("%sn", "start avconv:375");
// execlp ( "avconv","avconv","-i", infile_name,NULL );
execlp ("ffmpeg","ffmpeg","-i",infile_name, NULL );
} else {
g_message( "I'm parent with PID=%dn", getpid() ) ;
}
g_message ("else %sn", "done");
return 0;
}
/************************/
/* For the check button */
static void print_toggle( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item )
{
g_message ("Check button state - %dn",
GTK_CHECK_MENU_ITEM (menu_item)->active);
}
/***************************************/
static void filter_toggle( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item ) {
if( 1 == callback_action ){
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[1]=1;
}else{
calfil[1]=0;
}
}
if( 2 == callback_action ){
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[2]=2;
}else{
calfil[2]=0;
}
}
/* Этот фильтр включен по умолчанию */
/* if( 3 == callback_action ) strcat( video_filter, FLT_3 );*/
if( 4 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[4]=4;
}else{
calfil[4]=0;
}
}
if( 5 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[5]=5;
}else{
calfil[5]=0;
}
}
if( 6 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[6]=6;
}else{
calfil[6]=0;
}
}
if( 7 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[7]=7;
}else{
calfil[7]=0;
}
}
if( 8 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[8]=8;
}else{
calfil[8]=0;
}
}
if( 9 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[9]=9;
}else{
calfil[9]=0;
}
}
if( 11 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[11]=11;
}else{
calfil[11]=0;
}
}
if( 12 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[12]=12;
}else{
calfil[12]=0;
}
}
if( 13 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[13]=13;
}else{
calfil[13]=0;
}
}
if( 14 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[14]=14;
}else{
calfil[14]=0;
}
}
if( 15 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[15]=15;
}else{
calfil[15]=0;
}
}
if( 15 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[15]=15;
}else{
calfil[15]=0;
}
}
if( 16 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[16]=16;
}else{
calfil[16]=0;
}
}
if( 17 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[17]=17;
}else{
calfil[17]=0;
}
}
if( 18 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[18]=18;
}else{
calfil[18]=0;
}
}
if( 19 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[19]=19;
}else{
calfil[19]=0;
}
}
if( 21 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[21]=21;
}else{
calfil[21]=0;
}
}
if( 22 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[22]=22;
}else{
calfil[22]=0;
}
}
if( 23 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[23]=23;
}else{
calfil[23]=0;
}
}
if( 24 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[24]=24;
}else{
calfil[24]=0;
}
}
if( 25 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[25]=25;
}else{
calfil[25]=0;
}
}
if( 26 == callback_action ) {
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
calfil[26]=26;
}else{
calfil[26]=0;
}
}
g_message ("Check button state - %d callbackn+action=%d video_filter=%sn",
GTK_CHECK_MENU_ITEM (menu_item)->active,
callback_action,
video_filter );
}
/*************************/
/* For the radio buttons */
static void print_selected( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item )
{
if(GTK_CHECK_MENU_ITEM(menu_item)->active)
g_message ("Radio button %d selectedn", callback_action);
}
/***************************************************/
static void selected_audio( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item ) {
if(GTK_CHECK_MENU_ITEM(menu_item)->active){
if( 1 == callback_action ){
acanal = "2";
abitrate ="192k";
}
if( 2 == callback_action ){
acanal = "2";
abitrate ="64k";
}
if( 3 == callback_action ){
acanal = "2";
abitrate ="192k";
}
if( 4 == callback_action ){
acanal = "6";
abitrate ="384k";
}
if( 5 == callback_action ){
acanal = "6";
abitrate ="448k";
}
g_message ("aspect Radio button %d selectedn", callback_action);
g_message ("acanal Radio button %s selectedn", acanal);
g_message ("abitrate Radio button %s selectedn", abitrate);
}
}
/****************************************************/
static void selected_razmer( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item ) {
if(GTK_CHECK_MENU_ITEM(menu_item)->active){
if( 1 == callback_action ) resize = "720:576" ;
if( 2 == callback_action ) resize = "1280:960" ;
if( 3 == callback_action ) resize = "1280:720" ;
if( 13 == callback_action ) resize = "960:720" ;
if( 4 == callback_action ) resize = "1024:576" ;
if( 5 == callback_action ) resize = "720:576" ;
if( 6 == callback_action ) resize = "352:576" ;
if( 7 == callback_action ) resize = "852:480" ;
if( 8 == callback_action ) resize = "640:480" ;
if( 9 == callback_action ) resize = "480:480" ;
if( 10 == callback_action ) resize = "640:360" ;
if( 11 == callback_action ) resize = "480:360" ;
if( 12 == callback_action ) resize = "352:288" ;
if( 13 == callback_action ) resize = "960:720" ;
if( 14 == callback_action ) resize = "1920:1080" ;
g_message ("resize Radio button %d selectedn", callback_action);
g_message ("razmer Radio button %s selectedn", resize);
}
}
/******************************************************/
static void selected_aspect( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item ) {
if(GTK_CHECK_MENU_ITEM(menu_item)->active){
if( 2 == callback_action ) aspect = "4:3" ;
if( 3 == callback_action ) aspect = "16:9" ;
if( 4 == callback_action ) aspect = "221:100" ;
g_message ("aspect Radio button %d selectedn", callback_action);
g_message ("aspect Radio button %s selectedn", aspect);
}
}
/******************************************************/
static void selected_qual( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item ) {
if(GTK_CHECK_MENU_ITEM(menu_item)->active){
if( 2 == callback_action ){
quality = "1" ;
h264_preset = "placebo";
}
if( 3 == callback_action ){
quality = "2" ;
h264_preset = "veryslow";
}
if( 4 == callback_action ){
quality = "3" ;
h264_preset = "slower";
}
if( 5 == callback_action ){
quality = "4" ;
h264_preset = "slow";
}
if( 6 == callback_action ){
quality = "5" ;
h264_preset = "medium";
}
if( 7 == callback_action ){
quality = "6" ;
h264_preset = "fast";
}
if( 8 == callback_action ){
quality = "7" ;
h264_preset = "faster";
}
if( 9 == callback_action ){
quality = "8" ;
h264_preset = "veryfast";
}
if( 10 == callback_action ){
quality = "9" ;
h264_preset = "superfast";
}
if( 11 == callback_action ){
quality = "10" ;
h264_preset = "ultrafast";
}
if( 12 == callback_action ) quality = "11" ;
if( 13 == callback_action ) quality = "12" ;
g_message ("quality Radio button %d selectedn", callback_action);
g_message ("quality Radio button %s selectedn", quality);
}
}
/******************************************************/
static void selected_b_frame( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item ) {
if(GTK_CHECK_MENU_ITEM(menu_item)->active){
if( 1 == callback_action ){
b_frame = "1" ;
h264_tune = "grain";
}
if( 2 == callback_action ){
b_frame = "2" ;
h264_tune = "fastdecode";
}
if( 3 == callback_action ){
b_frame = "2" ;
h264_tune = "zerolatency";
}
if( 4 == callback_action ){
b_frame = "3" ;
h264_tune = "grain";
}
g_message ("b_frame Radio button %d selectedn", callback_action);
g_message ("b_frame Radio button %s selectedn", b_frame);
}
}
/***********************************************************/
static void selected_subtitle( gpointer callback_data,
guint callback_action,
GtkWidget *menu_item ) {
if( 1 == callback_action ){
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
map_sub="1";
}else{
map_sub="0";
}
}
if( 2 == callback_action ){
if( 1 == GTK_CHECK_MENU_ITEM (menu_item)->active){
map_sub_add="2";
}else{
map_sub_add="0";
}
}
g_message ("map_sub Radio button %d selectedn", callback_action);
g_message ("map_sub = %s selectedn", map_sub);
g_message ("map_sub_add = %s selectedn", map_sub_add);
}
/*********************************************************************/
/* Our menu, an array of GtkItemFactoryEntry structures that defines each menu item */
static GtkItemFactoryEntry menu_items[] = {
{ "/_File", NULL, NULL, 0, "<Branch>" },
{ "/File/Open_Sub", "<control>S", f_open_sub, 0, "<StockItem>", GTK_STOCK_NEW },
{ "/File/_Open", "<control>O", f_open, 0, "<StockItem>", GTK_STOCK_OPEN },
{ "/File/_Info-Play","<control>I", f_info, 0, "<StockItem>", GTK_STOCK_MEDIA_PLAY },
{ "/File/sep1", NULL, NULL, 0, "<Separator>" },
{ "/File/Save _GIF","<control>G",f_save_gif, 0, "<StockItem>", GTK_STOCK_SAVE_AS },
{ "/File/Save _MPEG","<control>M",f_save_mpg, 0, "<StockItem>", GTK_STOCK_SAVE_AS },
{ "/File/Save MKV _h265","<control>H",f_save_mkv_h264,0,"<StockItem>",GTK_STOCK_SAVE },
{ "/File/Save MKV h265 2 _pass","<control>P",f_save_mkv_h264_2pass,0,"<StockItem>",GTK_STOCK_SAVE },
{ "/File/Save MP4 h265", NULL ,f_save_mp4,0, "<StockItem>", GTK_STOCK_SAVE },
{ "/File/Save MKV _xvid","<control>X",f_save_mkv,0,"<StockItem>", GTK_STOCK_SAVE_AS },
{ "/File/Save _AVI xvid","<CTRL>A", f_save_avi, 0, "<StockItem>", GTK_STOCK_SAVE_AS },
{ "/File/sep1", NULL, NULL, 0, "<Separator>" },
{ "/File/_Quit", "<CTRL>Q", gtk_main_quit, 0, "<StockItem>", GTK_STOCK_QUIT },
{ "/_Timer", NULL,NULL, 0, "<Branch>" },
{ "/Timer/start process",NULL,selected_time,0,"<StockItem>",GTK_STOCK_MEDIA_RECORD },
{ "/_Video", NULL, NULL, 0, "<Branch>" },
{ "/Video/tear", NULL, NULL, 0, "<Tearoff>" },
{ "/Video/аспект/ 4:3", NULL, selected_aspect, 2, "<RadioItem>" },
{ "/Video/аспект/ 16:9", NULL, selected_aspect, 3, "/Video/аспект/ 4:3" },
{ "/Video/аспект/2.21:1", NULL, selected_aspect, 4, "/Video/аспект/ 4:3" },
{ "/Video/sep", NULL, NULL, 0, "<Separator>" },
{ "/Video/размер/Off", NULL, selected_razmer, 1, "<RadioItem>" },
{ "/Video/размер/1920x1080", NULL, selected_razmer, 14, "/Video/размер/Off" },
{ "/Video/размер/1280x960", NULL, selected_razmer, 2, "/Video/размер/Off" },
{ "/Video/размер/1280x720", NULL, selected_razmer, 3, "/Video/размер/Off" },
{ "/Video/размер/960x720", NULL, selected_razmer, 13, "/Video/размер/Off" },
{ "/Video/размер/1024x576", NULL, selected_razmer, 4, "/Video/размер/Off" },
{ "/Video/размер/ 720x576", NULL, selected_razmer, 5, "/Video/размер/Off" },
{ "/Video/размер/ 352x576", NULL, selected_razmer, 6, "/Video/размер/Off" },
{ "/Video/размер/ 852x480", NULL, selected_razmer, 7, "/Video/размер/Off" },
{ "/Video/размер/ 640x480", NULL, selected_razmer, 8, "/Video/размер/Off" },
{ "/Video/размер/ 480x480", NULL, selected_razmer, 9, "/Video/размер/Off" },
{ "/Video/размер/ 640x360", NULL, selected_razmer, 10, "/Video/размер/Off" },
{ "/Video/размер/ 480x360", NULL, selected_razmer, 11, "/Video/размер/Off" },
{ "/Video/размер/ 352x288", NULL, selected_razmer, 12, "/Video/размер/Off" },
{ "/Video/sep", NULL, NULL, 0, "<Separator>" },
{ "/Video/фильтр/"FLT_NAME_1, NULL, filter_toggle, 1, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_2, NULL, filter_toggle, 2, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_3, NULL, filter_toggle, 3, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_4, NULL, filter_toggle, 4, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_5, NULL, filter_toggle, 5, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_6, NULL, filter_toggle, 6, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_7, NULL, filter_toggle, 7, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_8, NULL, filter_toggle, 8, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_9, NULL, filter_toggle, 9, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_11, NULL, filter_toggle, 11, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_12, NULL, filter_toggle, 12, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_13, NULL, filter_toggle, 13, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_26, NULL, filter_toggle, 26, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_14, NULL, filter_toggle, 14, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_15, NULL, filter_toggle, 15, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_25, NULL, filter_toggle, 25, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_16, NULL, filter_toggle, 16, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_17, NULL, filter_toggle, 17, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_18, NULL, filter_toggle, 18, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_19, NULL, filter_toggle, 19, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_21, NULL, filter_toggle, 21, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_22, NULL, filter_toggle, 22, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_23, NULL, filter_toggle, 23, "<CheckItem>" },
{ "/Video/фильтр/"FLT_NAME_24, NULL, filter_toggle, 24, "<CheckItem>" },
{ "/Video/sep", NULL, NULL, 0, "<Separator>" },
{ "/Video/качество/Off", NULL, selected_qual, 1, "<RadioItem>" },
{ "/Video/качество/1 placebo", "<CTRL>1", selected_qual, 2, "/Video/качество/Off" },
{ "/Video/качество/2 veryslow", "<CTRL>2", selected_qual, 3, "/Video/качество/Off" },
{ "/Video/качество/3 slower", "<CTRL>3", selected_qual, 4, "/Video/качество/Off" },
{ "/Video/качество/4 slow", "<CTRL>4", selected_qual, 5, "/Video/качество/Off" },
{ "/Video/качество/5 medium", "<CTRL>5", selected_qual, 6, "/Video/качество/Off" },
{ "/Video/качество/6 fast", "<CTRL>6", selected_qual, 7, "/Video/качество/Off" },
{ "/Video/качество/7 faster", "<CTRL>7", selected_qual, 8, "/Video/качество/Off" },
{ "/Video/качество/8 veryfast", "<CTRL>8", selected_qual, 9, "/Video/качество/Off" },
{ "/Video/качество/9 superfast", "<CTRL>9", selected_qual, 10, "/Video/качество/Off" },
{ "/Video/качество/10 ultrafast", NULL, selected_qual, 11, "/Video/качество/Off" },
{ "/Video/качество/11", NULL, selected_qual, 12, "/Video/качество/Off" },
{ "/Video/качество/12", NULL, selected_qual, 13, "/Video/качество/Off" },
{ "/Video/sep", NULL, NULL, 0, "<Separator>" },
{ "/Video/b-кадр/1 grain", NULL, selected_b_frame, 1, "<RadioItem>" },
{ "/Video/b-кадр/2 fastdecode", NULL, selected_b_frame, 2, "/Video/b-кадр/1 grain" },
{ "/Video/b-кадр/2 zerolatency", NULL,selected_b_frame, 3, "/Video/b-кадр/1 grain" },
{ "/Video/b-кадр/3 grain", NULL,selected_b_frame, 4, "/Video/b-кадр/1 grain" },
{ "/_Audio", NULL, NULL, 0, "<Branch>" },
{ "/Audio/tear", NULL, NULL, 0, "<Tearoff>" },
{ "/Audio/ac3", NULL, selected_audio, 1, "<RadioItem>" },
{ "/Audio/ac3-2c-64k", NULL, selected_audio, 2, "/Audio/ac3" },
{ "/Audio/ac3-2c-192k",NULL, selected_audio, 3, "/Audio/ac3" },
{ "/Audio/ac3-6c-384k",NULL, selected_audio, 4, "/Audio/ac3" },
{ "/Audio/ac3-6c-448k",NULL, selected_audio, 5, "/Audio/ac3" },
{ "/_Subtitle", NULL, NULL, 0, "<Branch>" },
{ "/Subtitle/tear", NULL, NULL, 0, "<Tearoff>" },
{ "/Subtitle/On", NULL, selected_subtitle, 1, "<CheckItem>" },
{ "/Subtitle/add", NULL, selected_subtitle, 2, "<CheckItem>" },
{ "/Help", NULL, NULL, 0, "<LastBranch>" },
{ "/Help/Help", "<F1>", h_about, 0, "<StockItem>", GTK_STOCK_HELP },
{ "/Help/About", NULL, h_about, 0, "<StockItem>", GTK_STOCK_ABOUT },
};
/**********************************************************************/
static gint nmenu_items = sizeof (menu_items) / sizeof (menu_items[0]);
/* Returns a menubar widget made from the above menu */
static GtkWidget *get_menubar_menu( GtkWidget *window )
{
GtkItemFactory *item_factory;
GtkAccelGroup *accel_group;
/* Make an accelerator group (shortcut keys) */
accel_group = gtk_accel_group_new ();
/* Make an ItemFactory (that makes a menubar) */
item_factory = gtk_item_factory_new (GTK_TYPE_MENU_BAR, "<main>",
accel_group);
/* This function generates the menu items. Pass the item factory,
the number of items in the array, the array itself, and any
callback data for the the menu items. */
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
/* Attach the new accelerator group to the window. */
gtk_window_add_accel_group (GTK_WINDOW (window), accel_group);
/* Finally, return the actual menu bar created by the item factory. */
return gtk_item_factory_get_widget (item_factory, "<main>");
}
/* Popup the menu when the popup button is pressed */
static gboolean popup_cb( GtkWidget *widget,
GdkEvent *event,
GtkWidget *menu )
{
GdkEventButton *bevent = (GdkEventButton *)event;
/* Only take button presses */
if (event->type != GDK_BUTTON_PRESS)
return FALSE;
/* Show the menu */
gtk_menu_popup (GTK_MENU(menu), NULL, NULL,
NULL, NULL, bevent->button, bevent->time);
return TRUE;
}
/* Same as with get_menubar_menu() but just return a button with a signal to
call a popup menu */
GtkWidget *get_popup_menu( void )
{
GtkItemFactory *item_factory;
GtkWidget *button, *menu;
/* Same as before but don't bother with the accelerators */
item_factory = gtk_item_factory_new (GTK_TYPE_MENU, "<main>",
NULL);
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
menu = gtk_item_factory_get_widget (item_factory, "<main>");
/* Make a button to activate the popup menu */
button = gtk_button_new_with_label (".");
/* Make the menu popup when clicked */
g_signal_connect (G_OBJECT(button),
"event",
G_CALLBACK(popup_cb),
(gpointer) menu);
return button;
}
/* Same again but return an option menu */
GtkWidget *get_option_menu( void )
{
GtkItemFactory *item_factory;
GtkWidget *option_menu;
/* Same again, not bothering with the accelerators */
item_factory = gtk_item_factory_new (GTK_TYPE_OPTION_MENU, "<main>",
NULL);
gtk_item_factory_create_items (item_factory, nmenu_items, menu_items, NULL);
option_menu = gtk_item_factory_get_widget (item_factory, "<main>");
return option_menu;
}
/********************************************/
/* main */
/********************************************/
int main( int argc, char *argv[] ) {
GtkWidget *window;
GtkWidget *frame, *frame1, *frame2, *frame3;
GtkWidget *main_vbox, *hbox1,*hbox2,*hbox,*hbox_2,*hbox3;
GtkWidget *entry_start, *entry_stop,*entry_title_file,*entry_bitrate;
GtkWidget *menubar, *option_menu, *popup_button;
/* Initialize GTK */
gtk_init (&argc, &argv);
/* Make a window */
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (G_OBJECT (window), "destroy",
G_CALLBACK (gtk_main_quit),
NULL);
gtk_window_set_title (GTK_WINDOW(window), PROGRAMM_NAME);
gtk_widget_set_size_request (GTK_WIDGET(window),
WIDTH_MAIN, HIGHT_MAIN);
/* Make a vbox to put the three menus in */
main_vbox = gtk_vbox_new (FALSE, 1);
gtk_container_set_border_width (GTK_CONTAINER (main_vbox), 1);
gtk_container_add (GTK_CONTAINER (window), main_vbox);
/* Get the three types of menu */
/* Note: all three menus are separately created, so they are not the
same menu */
hbox = gtk_hbox_new (FALSE, 5);
hbox1= gtk_hbox_new (FALSE, 5);
hbox2= gtk_hbox_new (FALSE, 5);
hbox3= gtk_hbox_new (FALSE, 5);
hbox_2= gtk_hbox_new (FALSE, 5);
gtk_widget_set_size_request (GTK_WIDGET(hbox_2),
330, 20);
frame = gtk_frame_new ("Время старта:");
frame1= gtk_frame_new ("Длительность:");
frame2= gtk_frame_new ( "Название фильма:");
frame3= gtk_frame_new ( "Битрейт,килобит/c:");
gtk_container_add (GTK_CONTAINER (hbox), frame);
gtk_container_add (GTK_CONTAINER (hbox1), frame1);
gtk_container_add (GTK_CONTAINER (hbox_2), frame2);
gtk_container_add (GTK_CONTAINER (hbox3), frame3);
gtk_box_pack_start (GTK_BOX (hbox2), hbox, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox2), hbox1, FALSE, TRUE, 0);
gtk_box_pack_start (GTK_BOX (hbox2), hbox3, FALSE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (hbox2), hbox_2, FALSE, TRUE, 0);
menubar = get_menubar_menu (window);
popup_button = get_popup_menu ();
gtk_widget_set_size_request (GTK_WIDGET(popup_button),
WIDTH_POPUP, HIGHT_POPUP);
option_menu = get_option_menu ();
/*------------------------*/
/* entry ******************/
entry_start = gtk_entry_new ();
gtk_entry_set_max_length (GTK_ENTRY (entry_start), 12);
g_signal_connect (entry_start, "changed",
G_CALLBACK (enter_callback_start),
(gpointer) entry_start);
gtk_entry_set_text (GTK_ENTRY (entry_start), "1");
entry_stop = gtk_entry_new ();
gtk_entry_set_max_length (GTK_ENTRY (entry_stop), 12);
g_signal_connect (entry_stop, "changed",
G_CALLBACK (enter_callback_stop),
(gpointer) entry_stop);
gtk_entry_set_text (GTK_ENTRY (entry_stop), "6:00:00");
entry_title_file = gtk_entry_new ();
gtk_entry_set_max_length (GTK_ENTRY (entry_title_file), 255);
g_signal_connect (entry_title_file, "changed",
G_CALLBACK (enter_callback_title_file),
(gpointer) entry_title_file);
gtk_entry_set_text (GTK_ENTRY (entry_title_file), "title video");
entry_bitrate = gtk_entry_new ();
gtk_entry_set_max_length (GTK_ENTRY (entry_bitrate), 12);
g_signal_connect (entry_bitrate, "changed",
G_CALLBACK (enter_callback_bitrate),
(gpointer) entry_bitrate);
gtk_entry_set_text (GTK_ENTRY (entry_bitrate), "1000");
/*------------------------*/
/* Pack it all together */
gtk_box_pack_start (GTK_BOX (main_vbox), menubar, FALSE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (main_vbox), option_menu, FALSE, TRUE, 0);
gtk_box_pack_end (GTK_BOX (main_vbox), hbox2, FALSE, FALSE, 0);
gtk_box_pack_end (GTK_BOX (main_vbox), popup_button, FALSE, TRUE, 0);
gtk_container_add (GTK_CONTAINER (frame1), entry_stop);
gtk_container_add (GTK_CONTAINER (frame), entry_start);
gtk_container_add (GTK_CONTAINER (frame2), entry_title_file);
gtk_container_add (GTK_CONTAINER (frame3), entry_bitrate);
/* Show the widgets */
gtk_widget_show_all (window);
/* Finished! */
gtk_main ();
return 0;
}
Makefile
C = gcc
LDLIBS = `pkg-config gtk+-2.0 --libs`
CFLAGS = -Wall
-DG_DISABLE_DEPRECATED
-DGDK_DISABLE_DEPRECATED
-DGDK_PIXBUF_DISABLE_DEPRECATED
-DGTK_DISABLE_DEPRECATED
CFLAGSMENU = -Wall
-DG_DISABLE_DEPRECATED
-DGDK_DISABLE_DEPRECATED
-DGDK_PIXBUF_DISABLE_DEPRECATED
N = gtk_video_conv
$N: menu.o infile.o insub.o outfile.o about.o
$C $^ -o $@ $(LDLIBS)
menu.o: menu.c
$C -c $^ $(CFLAGSMENU) `pkg-config gtk+-2.0 --cflags --libs`
about.o: about.c
$C -c $^ $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs`
infile.o: infile.c
$C -c $^ $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs`
insub.o: insub.c
$C -c $^ $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs`
outfile.o: outfile.c
$C -c $^ $(CFLAGS) `pkg-config gtk+-2.0 --cflags --libs`
clear:
rm -f *.o
Файл "proc.h"
#ifndef PROC_H
#define PROC_H
#define PROGRAMM_VERSION "version 1.4.5"
#define PROGRAMM_NAME " Графическая оболочка ffmpeg и avconv "
#define PROGRAMM_DESCRIPTION "n Конвертирование "
"видеофайлов в форматы 'gif', 'mpeg-2' и 'mpeg-4' "
"с помощью ffmpeg кодеками mpeg2video и xvid "
"и avconv кодеком h264.n"
" Для запуска процесса конвертирования нажмите"
" Timer/start process."
#define FI 1.618
#define HIGHT_MAIN 440
#define WIDTH_MAIN 880
#define HIGHT_POPUP 320
#define WIDTH_POPUP 678
int infile();
int insub();
int outfile();
void about();
#endif
Эпилог
Функции программы документированы, переменные имеют доступные имена.
Но если понадобится помощь -- обращайтесь