author | Stepan777 <stepik-777@mail.ru> |
Mon, 09 Jul 2012 17:03:57 +0400 | |
changeset 7376 | 48b79b3ca592 |
parent 7361 | b73d7688dadc |
child 7528 | f8cf277dca36 |
permissions | -rw-r--r-- |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
1 |
/* |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
2 |
* Hedgewars, a free turn based strategy game |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
3 |
* Copyright (c) 2004-2012 Andrey Korotaev <unC0Rr@gmail.com> |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
4 |
* |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
6 |
* it under the terms of the GNU General Public License as published by |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
7 |
* the Free Software Foundation; version 2 of the License |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
8 |
* |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
12 |
* GNU General Public License for more details. |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
13 |
* |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
17 |
*/ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
18 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
19 |
#define __STDC_CONSTANT_MACROS |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
20 |
extern "C" |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
21 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
22 |
#include "libavformat/avformat.h" |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
23 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
24 |
#include <QVector> |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
25 |
#include <QList> |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
26 |
#include <QMessageBox> |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
27 |
#include <QComboBox> |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
28 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
29 |
#include "libav_iteraction.h" |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
30 |
#include "HWApplication.h" |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
31 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
32 |
struct Codec |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
33 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
34 |
CodecID id; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
35 |
bool isAudio; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
36 |
QString shortName; // used for identification |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
37 |
QString longName; // used for displaying to user |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
38 |
bool isRecomended; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
39 |
}; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
40 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
41 |
struct Format |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
42 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
43 |
QString shortName; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
44 |
QString longName; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
45 |
bool isRecomended; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
46 |
QString extension; |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
47 |
QVector<Codec*> codecs; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
48 |
}; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
49 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
50 |
QList<Codec> codecs; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
51 |
QMap<QString,Format> formats; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
52 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
53 |
LibavIteraction & LibavIteraction::instance() |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
54 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
55 |
static LibavIteraction instance; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
56 |
return instance; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
57 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
58 |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
59 |
// test if given format supports given codec |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
60 |
bool FormatQueryCodec(AVOutputFormat *ofmt, enum CodecID codec_id) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
61 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
62 |
#if LIBAVFORMAT_VERSION_MAJOR >= 54 |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
63 |
return avformat_query_codec(ofmt, codec_id, FF_COMPLIANCE_NORMAL) == 1; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
64 |
#else |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
65 |
if (ofmt->codec_tag) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
66 |
return !!av_codec_get_tag(ofmt->codec_tag, codec_id); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
67 |
return codec_id == ofmt->video_codec || codec_id == ofmt->audio_codec; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
68 |
#endif |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
69 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
70 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
71 |
LibavIteraction::LibavIteraction() |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
72 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
73 |
// initialize libav and register all codecs and formats |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
74 |
av_register_all(); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
75 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
76 |
// get list of all codecs |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
77 |
AVCodec* pCodec = NULL; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
78 |
while (pCodec = av_codec_next(pCodec)) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
79 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
80 |
#if LIBAVCODEC_VERSION_MAJOR >= 54 |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
81 |
if (!av_codec_is_encoder(pCodec)) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
82 |
#else |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
83 |
if (!pCodec->encode) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
84 |
#endif |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
85 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
86 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
87 |
if (pCodec->type != AVMEDIA_TYPE_VIDEO && pCodec->type != AVMEDIA_TYPE_AUDIO) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
88 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
89 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
90 |
// this encoders seems to be buggy |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
91 |
if (strcmp(pCodec->name, "rv10") == 0 || strcmp(pCodec->name, "rv20") == 0) |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
92 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
93 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
94 |
// doesn't support stereo sound |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
95 |
if (strcmp(pCodec->name, "real_144") == 0) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
96 |
continue; |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
97 |
|
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
98 |
if (pCodec->type == AVMEDIA_TYPE_VIDEO) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
99 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
100 |
if (pCodec->supported_framerates != NULL) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
101 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
102 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
103 |
// check if codec supports yuv 4:2:0 format |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
104 |
if (!pCodec->pix_fmts) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
105 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
106 |
bool yuv420Supported = false; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
107 |
for (const PixelFormat* pfmt = pCodec->pix_fmts; *pfmt != -1; pfmt++) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
108 |
if (*pfmt == PIX_FMT_YUV420P) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
109 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
110 |
yuv420Supported = true; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
111 |
break; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
112 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
113 |
if (!yuv420Supported) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
114 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
115 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
116 |
if (pCodec->type == AVMEDIA_TYPE_AUDIO) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
117 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
118 |
// check if codec supports signed 16-bit format |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
119 |
if (!pCodec->sample_fmts) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
120 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
121 |
bool s16Supported = false; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
122 |
for (const AVSampleFormat* pfmt = pCodec->sample_fmts; *pfmt != -1; pfmt++) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
123 |
if (*pfmt == AV_SAMPLE_FMT_S16/* || *pfmt == AV_SAMPLE_FMT_FLT*/) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
124 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
125 |
s16Supported = true; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
126 |
break; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
127 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
128 |
if (!s16Supported) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
129 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
130 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
131 |
// add codec to list of codecs |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
132 |
codecs.push_back(Codec()); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
133 |
Codec & codec = codecs.back(); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
134 |
codec.id = pCodec->id; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
135 |
codec.isAudio = pCodec->type == AVMEDIA_TYPE_AUDIO; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
136 |
codec.shortName = pCodec->name; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
137 |
codec.longName = pCodec->long_name; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
138 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
139 |
codec.isRecomended = false; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
140 |
if (strcmp(pCodec->name, "libx264") == 0) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
141 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
142 |
codec.longName = "H.264/MPEG-4 Part 10 AVC (x264)"; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
143 |
codec.isRecomended = true; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
144 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
145 |
else if (strcmp(pCodec->name, "libxvid") == 0) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
146 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
147 |
codec.longName = "MPEG-4 Part 2 (Xvid)"; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
148 |
codec.isRecomended = true; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
149 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
150 |
else if (strcmp(pCodec->name, "libmp3lame") == 0) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
151 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
152 |
codec.longName = "MP3 (MPEG audio layer 3) (LAME)"; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
153 |
codec.isRecomended = true; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
154 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
155 |
else |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
156 |
codec.longName = pCodec->long_name; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
157 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
158 |
if (strcmp(pCodec->name, "mpeg4") == 0 || strcmp(pCodec->name, "ac3_fixed") == 0) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
159 |
codec.isRecomended = true; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
160 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
161 |
// FIXME: remove next line |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7361
diff
changeset
|
162 |
codec.longName += QString(" (%1)").arg(codec.shortName); |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
163 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
164 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
165 |
// get list of all formats |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
166 |
AVOutputFormat* pFormat = NULL; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
167 |
while (pFormat = av_oformat_next(pFormat)) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
168 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
169 |
if (!pFormat->extensions) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
170 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
171 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
172 |
// skip some strange formats to not confuse users |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
173 |
if (strstr(pFormat->long_name, "raw")) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
174 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
175 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
176 |
Format format; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
177 |
bool hasVideoCodec = false; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
178 |
for (QList<Codec>::iterator codec = codecs.begin(); codec != codecs.end(); ++codec) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
179 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
180 |
if (!FormatQueryCodec(pFormat, codec->id)) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
181 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
182 |
format.codecs.push_back(&*codec); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
183 |
if (!codec->isAudio) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
184 |
hasVideoCodec = true; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
185 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
186 |
if (!hasVideoCodec) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
187 |
continue; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
188 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
189 |
QString ext(pFormat->extensions); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
190 |
ext.truncate(strcspn(pFormat->extensions, ",")); |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
191 |
format.extension = ext; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
192 |
format.shortName = pFormat->name; |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
193 |
format.longName = QString("%1 (*.%2)").arg(pFormat->long_name).arg(ext); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
194 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
195 |
// FIXME: remove next line |
7376
48b79b3ca592
rework saving of camera positions so there is no need to know framerate during prerecording.
Stepan777 <stepik-777@mail.ru>
parents:
7361
diff
changeset
|
196 |
format.longName += QString(" (%1)").arg(format.shortName); |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
197 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
198 |
format.isRecomended = strcmp(pFormat->name, "mp4") == 0 || strcmp(pFormat->name, "avi") == 0; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
199 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
200 |
formats[pFormat->name] = format; |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
201 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
202 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
203 |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
204 |
void LibavIteraction::fillFormats(QComboBox * pFormats) |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
205 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
206 |
// first insert recomended formats |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
207 |
foreach(const Format & format, formats) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
208 |
if (format.isRecomended) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
209 |
pFormats->addItem(format.longName, format.shortName); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
210 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
211 |
// remember where to place separator between recomended and other formats |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
212 |
int sep = pFormats->count(); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
213 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
214 |
// insert remaining formats |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
215 |
foreach(const Format & format, formats) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
216 |
if (!format.isRecomended) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
217 |
pFormats->addItem(format.longName, format.shortName); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
218 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
219 |
// insert separator if necessary |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
220 |
if (sep != 0 && sep != pFormats->count()) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
221 |
pFormats->insertSeparator(sep); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
222 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
223 |
|
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
224 |
void LibavIteraction::fillCodecs(const QString & fmt, QComboBox * pVCodecs, QComboBox * pACodecs) |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
225 |
{ |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
226 |
Format & format = formats[fmt]; |
7235
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
227 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
228 |
// first insert recomended codecs |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
229 |
foreach(Codec * codec, format.codecs) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
230 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
231 |
if (codec->isRecomended) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
232 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
233 |
if (codec->isAudio) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
234 |
pACodecs->addItem(codec->longName, codec->shortName); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
235 |
else |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
236 |
pVCodecs->addItem(codec->longName, codec->shortName); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
237 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
238 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
239 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
240 |
// remember where to place separators between recomended and other codecs |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
241 |
int vsep = pVCodecs->count(); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
242 |
int asep = pACodecs->count(); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
243 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
244 |
// insert remaining codecs |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
245 |
foreach(Codec * codec, format.codecs) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
246 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
247 |
if (!codec->isRecomended) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
248 |
{ |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
249 |
if (codec->isAudio) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
250 |
pACodecs->addItem(codec->longName, codec->shortName); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
251 |
else |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
252 |
pVCodecs->addItem(codec->longName, codec->shortName); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
253 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
254 |
} |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
255 |
|
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
256 |
// insert separators if necessary |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
257 |
if (vsep != 0 && vsep != pVCodecs->count()) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
258 |
pVCodecs->insertSeparator(vsep); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
259 |
if (asep != 0 && asep != pACodecs->count()) |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
260 |
pACodecs->insertSeparator(asep); |
baa69bd025d9
1. Implement new page in frontend with options for video recording.
Stepan777 <stepik-777@mail.ru>
parents:
diff
changeset
|
261 |
} |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
262 |
|
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
263 |
QString LibavIteraction::getExtension(const QString & format) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
264 |
{ |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
265 |
return formats[format].extension; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
266 |
} |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
267 |
|
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
268 |
QString tr(QString a) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
269 |
{ |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
270 |
return a; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
271 |
} |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
272 |
|
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
273 |
// get information abaout file (duration, resolution etc) in multiline string |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
274 |
QString LibavIteraction::getFileInfo(const QString & filepath) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
275 |
{ |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
276 |
AVFormatContext* pContext = NULL; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
277 |
QByteArray utf8path = filepath.toUtf8(); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
278 |
if (avformat_open_input(&pContext, utf8path.data(), NULL, NULL) < 0) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
279 |
return ""; |
7361
b73d7688dadc
fix frontend for ffmpeg 0.7.13
Stepan777 <stepik-777@mail.ru>
parents:
7353
diff
changeset
|
280 |
#if LIBAFORMAT_VERSION_MAJOR < 54 |
b73d7688dadc
fix frontend for ffmpeg 0.7.13
Stepan777 <stepik-777@mail.ru>
parents:
7353
diff
changeset
|
281 |
if (av_find_stream_info(pContext) < 0) |
b73d7688dadc
fix frontend for ffmpeg 0.7.13
Stepan777 <stepik-777@mail.ru>
parents:
7353
diff
changeset
|
282 |
#else |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
283 |
if (avformat_find_stream_info(pContext, NULL) < 0) |
7361
b73d7688dadc
fix frontend for ffmpeg 0.7.13
Stepan777 <stepik-777@mail.ru>
parents:
7353
diff
changeset
|
284 |
#endif |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
285 |
return ""; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
286 |
|
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
287 |
int s = float(pContext->duration)/AV_TIME_BASE; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
288 |
QString desc = QString(tr("Duration: %1m %2s\n")).arg(s/60).arg(s%60); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
289 |
for (int i = 0; i < pContext->nb_streams; i++) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
290 |
{ |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
291 |
AVStream* pStream = pContext->streams[i]; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
292 |
if (!pStream) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
293 |
continue; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
294 |
AVCodecContext* pCodec = pContext->streams[i]->codec; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
295 |
if (!pCodec) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
296 |
continue; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
297 |
|
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
298 |
if (pCodec->codec_type == AVMEDIA_TYPE_VIDEO) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
299 |
{ |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
300 |
desc += QString(tr("Video: %1x%2, ")).arg(pCodec->width).arg(pCodec->height); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
301 |
if (pStream->avg_frame_rate.den) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
302 |
{ |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
303 |
float fps = float(pStream->avg_frame_rate.num)/pStream->avg_frame_rate.den; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
304 |
desc += QString(tr("%1 fps, ")).arg(fps, 0, 'f', 2); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
305 |
} |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
306 |
} |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
307 |
else if (pCodec->codec_type == AVMEDIA_TYPE_AUDIO) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
308 |
desc += tr("Audio: "); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
309 |
else |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
310 |
continue; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
311 |
AVCodec* pDecoder = avcodec_find_decoder(pCodec->codec_id); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
312 |
desc += pDecoder? pDecoder->name : "unknown"; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
313 |
desc += "\n"; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
314 |
} |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
315 |
AVDictionaryEntry* pComment = av_dict_get(pContext->metadata, "comment", NULL, 0); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
316 |
if (pComment) |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
317 |
desc += QString("\n") + pComment->value; |
7361
b73d7688dadc
fix frontend for ffmpeg 0.7.13
Stepan777 <stepik-777@mail.ru>
parents:
7353
diff
changeset
|
318 |
#if LIBAFORMAT_VERSION_MAJOR < 54 |
7280
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
319 |
av_close_input_file(pContext); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
320 |
#else |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
321 |
avformat_close_input(&pContext); |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
322 |
#endif |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
323 |
return desc; |
fd707afbc3a2
pagevideos is now much better that before:
Stepan777 <stepik-777@mail.ru>
parents:
7235
diff
changeset
|
324 |
} |