Skip to content

Commit 2fc706d

Browse files
author
Clement Champetier
committed
Merge branch 'develop' of https://github.com/mikrosimage/avTranscoder into build_fixLibAV
Conflicts: src/AvTranscoder/transform/AudioTransform.cpp
2 parents 00afb43 + 3c71de0 commit 2fc706d

File tree

15 files changed

+179
-191
lines changed

15 files changed

+179
-191
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ endif()
3131

3232
add_subdirectory(src)
3333

34-
if(DISABLE_APPS)
34+
if(AVTRANSCODER_DISABLE_APPS)
3535
message("Apps disabled, will not build applications.")
3636
else()
3737
add_subdirectory(app)

INSTALL.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,18 +22,18 @@ cmake .. -DCMAKE_PREFIX_PATH=/path/to/your/install
2222

2323
#### To not build apps
2424
```
25-
cmake .. -DDISABLE_APPS=True
25+
cmake .. -DAVTRANSCODER_DISABLE_APPS=True
2626
```
2727

2828
#### To not build bindings
2929
```
30-
cmake .. -DDISABLE_BINDINGS=True
30+
cmake .. -DAVTRANSCODER_DISABLE_BINDINGS=True
3131
```
3232
```
33-
cmake .. -DDISABLE_PYTHON_BINDING=True
33+
cmake .. -DAVTRANSCODER_DISABLE_PYTHON_BINDING=True
3434
```
3535
```
36-
cmake .. -DDISABLE_JAVA_BINDING=True
36+
cmake .. -DAVTRANSCODER_DISABLE_JAVA_BINDING=True
3737
```
3838

3939
#### Other useful flags

app/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
1+
# C++ apps
12
add_subdirectory(avInfo)
23
add_subdirectory(avMeta)
34
add_subdirectory(avPlay)
45
add_subdirectory(avProcessor)
5-
add_subdirectory(avThumbnail)
6+
7+
# Python apps
8+
add_subdirectory(pyProcessor)
9+
add_subdirectory(pyThumbnail)

app/avThumbnail/CMakeLists.txt

Lines changed: 0 additions & 23 deletions
This file was deleted.

app/avThumbnail/avThumbnail.cpp

Lines changed: 0 additions & 96 deletions
This file was deleted.

app/pyProcessor/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### python/pyProcessor
2+
3+
# Install app
4+
install(
5+
FILES "pyprocessor.py"
6+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
7+
DESTINATION "share/python"
8+
)

app/pyProcessor/pyProcessor.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

app/pyProcessor/pyprocessor.py

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import sys
2+
import argparse # python2.7+
3+
4+
from pyAvTranscoder import avtranscoder as av
5+
6+
7+
def parseConfigFile( inputConfigFile, transcoder ):
8+
file = open( inputConfigFile, 'r' )
9+
for line in file:
10+
line = line.strip( '\n' )
11+
12+
filename, operation = line.split( '=' )
13+
14+
streamIndexes, profileName = operation.split( ':' )
15+
if "." in streamIndexes:
16+
streamIndex, subStreamIndex = map(int, streamIndexes.split( '.' ))
17+
else:
18+
streamIndex = int(streamIndexes)
19+
subStreamIndex = -1
20+
21+
transcoder.add( filename, streamIndex, subStreamIndex, profileName )
22+
23+
24+
# Create command-line interface
25+
parser = argparse.ArgumentParser(
26+
prog='pythumbnail',
27+
description='''Generate jpeg thumbnail from video/image.''',
28+
)
29+
30+
# requirements
31+
parser.add_argument('configFileName', help='The config file will be parsed by foloowing this pattern: <media_file>=<stream_index><.substream_index>:<profile_name> \nGenerated streams (video and audio) and offset are not supported.')
32+
parser.add_argument('outputFileName', help='The output media file.')
33+
# Parse command-line
34+
args = parser.parse_args()
35+
36+
# setup avtranscoder
37+
logger = av.Logger().setLogLevel(av.AV_LOG_QUIET)
38+
av.preloadCodecsAndFormats()
39+
40+
# create Transcoder
41+
ouputFile = av.OutputFile( args.outputFileName )
42+
transcoder = av.Transcoder( ouputFile )
43+
44+
# parse configuration file
45+
parseConfigFile( args.configFileName, transcoder )
46+
47+
# initialize Transcoder
48+
transcoder.setProcessMethod( av.eProcessMethodLongest )
49+
50+
# Process transcode
51+
progress = av.ConsoleProgress()
52+
transcoder.process( progress )

app/pyThumbnail/CMakeLists.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
### python/pyThumbnail
2+
3+
# Install app
4+
install(
5+
FILES "pythumbnail.py"
6+
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ GROUP_EXECUTE GROUP_READ WORLD_READ WORLD_EXECUTE
7+
DESTINATION "share/python"
8+
)

app/pyThumbnail/pythumbnail.py

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
import argparse # python2.7+
2+
3+
from pyAvTranscoder import avtranscoder as av
4+
5+
# Create command-line interface
6+
parser = argparse.ArgumentParser(
7+
prog='pythumbnail',
8+
description='''Generate jpeg thumbnail from video/image.''',
9+
)
10+
11+
# requirements
12+
parser.add_argument('inputFileName', help='It could be any media file with at least one video stream (video, image...). Support file without extension.')
13+
# options
14+
parser.add_argument("-o", "--outputFile", dest="outputFileName", default="thumbnail.jpg", help="Set the output filename (thumbnail.jpg by default). Must be with jpg extension!")
15+
parser.add_argument("-t", "--time", dest="time", type=int, default=0, help="Set time (in seconds) of where to seek in the video stream to generate the thumbnail (0 by default).")
16+
parser.add_argument("-f", "--frame", dest="frame", type=int, default=0, help="Set time (in frames) of where to seek in the video stream to generate the thumbnail (0 by default). Warning: priority to frame if user indicates both frame and time!")
17+
parser.add_argument("-w", "--width", dest="width", type=int, default=0, help="Override the width of the thumbnail (same as input by default).")
18+
parser.add_argument("-he", "--height", dest="height", type=int, default=0, help="Override the height of the thumbnail (same as input by default).")
19+
# Parse command-line
20+
args = parser.parse_args()
21+
22+
# setup avtranscoder
23+
logger = av.Logger().setLogLevel(av.AV_LOG_QUIET)
24+
av.preloadCodecsAndFormats()
25+
26+
# create input file
27+
inputFile = av.InputFile(args.inputFileName)
28+
if len(inputFile.getProperties().getVideoProperties()) == 0:
29+
print "No video stream found in file ", args.inputFileName
30+
exit(1)
31+
32+
# seek in file
33+
if args.frame:
34+
inputFile.seekAtFrame(args.frame)
35+
elif args.time:
36+
inputFile.seekAtTime(args.time)
37+
38+
# create output file (need to set format profile of encoding to force output format to mjpeg)
39+
formatProfile = av.ProfileMap()
40+
formatProfile[ av.avProfileIdentificator ] = "thumbnailFormatPreset"
41+
formatProfile[ av.avProfileIdentificatorHuman ] = "Thumbnail format preset"
42+
formatProfile[ av.avProfileType ] = av.avProfileTypeFormat
43+
formatProfile[ av.avProfileFormat ] = "mjpeg"
44+
outputFile = av.OutputFile( args.outputFileName )
45+
outputFile.setProfile( formatProfile )
46+
47+
# create input stream
48+
videoStreamIndex = inputFile.getProperties().getVideoProperties()[0].getStreamIndex()
49+
inputStream = av.InputStream(inputFile, videoStreamIndex)
50+
inputStream.activate()
51+
52+
# create output stream
53+
videoProfile = av.ProfileMap()
54+
videoProfile[ av.avProfileIdentificator ] = "thumbnailVideoPreset"
55+
videoProfile[ av.avProfileIdentificatorHuman ] = "Thumbnail video preset"
56+
videoProfile[ av.avProfileType ] = av.avProfileTypeVideo
57+
videoProfile[ av.avProfileCodec ] = "mjpeg"
58+
videoProfile[ av.avProfilePixelFormat ] = "yuvj420p"
59+
if args.width:
60+
videoProfile[ av.avProfileWidth ] = str(args.width)
61+
if args.height:
62+
videoProfile[ av.avProfileHeight ] = str(args.height)
63+
outputStream = av.StreamTranscoder( inputStream, outputFile, videoProfile )
64+
65+
# create transcoder
66+
transcoder = av.Transcoder( outputFile )
67+
transcoder.add( outputStream );
68+
69+
# launch process
70+
outputFile.beginWrap();
71+
transcoder.preProcessCodecLatency();
72+
transcoder.processFrame();
73+
outputFile.endWrap();

src/AvTranscoder/avTranscoder.i

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@
1515
%include "AvTranscoder/swig/avLogLevel.i"
1616

1717
%{
18+
#include <AvTranscoder/Library.hpp>
1819
#include <AvTranscoder/Option.hpp>
20+
#include <AvTranscoder/log.hpp>
1921
%}
2022

2123
namespace std {
@@ -27,7 +29,9 @@ namespace std {
2729
%include "AvTranscoder/frame/frame.i"
2830
%include "AvTranscoder/profile/profile.i"
2931

32+
%include <AvTranscoder/Library.hpp>
3033
%include <AvTranscoder/Option.hpp>
34+
%include <AvTranscoder/log.hpp>
3135

3236
%include "AvTranscoder/codec/codec.i"
3337
%include "AvTranscoder/stream/stream.i"

src/AvTranscoder/log.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class AvExport Logger
2626
/**
2727
* @brief Set the log level of ffmpeg/libav.
2828
* @param level: refer to define AV_LOG_xxx (from AV_LOG_QUIET to AV_LOG_DEBUG)
29+
* @note By default AV_LOG_INFO
2930
* @see SWIG interface avLogLevel.i
3031
*/
3132
static void setLogLevel( const int level );

0 commit comments

Comments
 (0)