Skip to content

Commit 34859e3

Browse files
committed
Merge branch 'develop' into dev_propertiesGetCodecPrivateOptions
2 parents 2890f5b + 7ed9558 commit 34859e3

File tree

3 files changed

+188
-54
lines changed

3 files changed

+188
-54
lines changed

INSTALL.md

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Compilation
22

3-
AvTranscoder uses CMake as build system.
3+
AvTranscoder uses [CMake](http://www.cmake.org/) as build system.
44

55
#### Dependencies
66
AvTranscoder can depend on ffmpeg, libav, or any fork of these projects that follow the same API.
@@ -9,31 +9,30 @@ AvTranscoder can depend on ffmpeg, libav, or any fork of these projects that fol
99

1010
#### To build
1111
```
12-
mkdir build && cd build
13-
cmake ..
12+
cmake .
1413
make
1514
make install
1615
```
1716

1817
#### To indicate a specific ffmpeg/libav folder
1918
```
20-
cmake .. -DCMAKE_PREFIX_PATH=/path/to/your/install
19+
cmake . -DCMAKE_PREFIX_PATH=/path/to/your/install
2120
```
2221

2322
#### To not build apps
2423
```
25-
cmake .. -DAVTRANSCODER_DISABLE_APPS=True
24+
cmake . -DAVTRANSCODER_DISABLE_APPS=True
2625
```
2726

2827
#### To not build bindings
2928
```
30-
cmake .. -DAVTRANSCODER_DISABLE_BINDINGS=True
29+
cmake . -DAVTRANSCODER_DISABLE_BINDINGS=True
3130
```
3231
```
33-
cmake .. -DAVTRANSCODER_DISABLE_PYTHON_BINDING=True
32+
cmake . -DAVTRANSCODER_DISABLE_PYTHON_BINDING=True
3433
```
3534
```
36-
cmake .. -DAVTRANSCODER_DISABLE_JAVA_BINDING=True
35+
cmake . -DAVTRANSCODER_DISABLE_JAVA_BINDING=True
3736
```
3837

3938
#### Other useful flags
@@ -50,7 +49,7 @@ cmake .. -DCMAKE_BUILD_TYPE=Release/Debug
5049
cmake .. -DAVTRANSCODER_PYTHON_VERSION_OF_BINDING=2.7
5150
```
5251

53-
#### Mac OSX using homebrew
52+
#### To install on Mac OSX
5453

5554
###### Install homebrew
5655
http://brew.sh/
@@ -73,3 +72,23 @@ brew install avtranscoder --devel
7372
brew deps avtranscoder
7473
brew install avtranscoder --only-dependencies
7574
```
75+
76+
#### Tests
77+
78+
###### nosetests
79+
Python tests using nosetests.
80+
```
81+
cd test/pyTest
82+
nosetests
83+
```
84+
85+
Some tests need environment variables to be executed (otherwise they will be skipped):
86+
* ```AVTRANSCODER_TEST_VIDEO_AVI_FILE```
87+
* ```AVTRANSCODER_TEST_VIDEO_MP4_FILE```
88+
* ```AVTRANSCODER_TEST_VIDEO_MOV_FILE```
89+
* ```AVTRANSCODER_TEST_AUDIO_WAVE_FILE```
90+
* ```AVTRANSCODER_TEST_AUDIO_MOV_FILE```
91+
* ```AVTRANSCODER_TEST_IMAGE_PNG_FILE```
92+
* ```AVTRANSCODER_TEST_IMAGE_JPG_FILE```
93+
94+
Note: for continuous integration, we launch tests with media files contained in [avTranscoder-data](https://github.com/avTranscoder/avTranscoder-data) repository.

README.md

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# avTranscoder
22

3-
C++ API for FFmpeg / Libav
3+
High level API for FFmpeg / Libav.
44

55
Based on FFmpeg/Libav libraries to support various video and audio formats, avTranscoder provides the high level API to re-wrap or transcode media easily.
66

@@ -15,11 +15,11 @@ Click on the badge above to have a big picture view of what's in progress and ho
1515

1616
:warning: The latest avTranscoder API does not fit with libav.
1717

18-
#### What you need to know
19-
* C++ library
20-
* Java and Python bindings generated with SWIG
21-
* multiplateform (Linux, MAC, Windows)
22-
* your call to be based on Libav, FFmpeg, or your custom fork of one of these librairies
18+
#### The basics
19+
* avTranscoder is a C++ library.
20+
* avTranscoder uses [SWIG](http://www.swig.org/) to generate __Java__ and __Python__ bindings.
21+
* avTranscoder is multiplateform (Linux, MAC, Windows).
22+
* avTranscoder could be based on [Libav](https://libav.org/), [FFmpeg](https://ffmpeg.org/), or your custom fork of one of these librairies.
2323

2424
#### License
2525
See [**COPYING.md**](COPYING.md)
@@ -33,23 +33,6 @@ See [**Doxygen documentation**](http://avtranscoder.github.io/avTranscoder-doxyg
3333
#### Compilation
3434
See [**INSTALL.md**](INSTALL.md)
3535

36-
#### Tests
37-
38-
###### nosetests
39-
Python tests using nosetests.
40-
```
41-
cd test/pyTest
42-
nosetests
43-
```
44-
45-
Some tests need environment variables to be executed (otherwise they will be skipped):
46-
* ```AVTRANSCODER_TEST_VIDEO_FILE```
47-
* ```AVTRANSCODER_TEST_AUDIO_WAVE_FILE```
48-
* ```AVTRANSCODER_TEST_AUDIO_MOV_FILE```
49-
50-
Note: for continuous integration, we launch tests with media files contained in ```avTranscoder-data``` repository.
51-
52-
5336
#### Packaging
5437

5538
###### Build openSUSE

USAGE.md

Lines changed: 154 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,124 @@
11
# How to use avTranscoder
22

3-
Check out applications contained in the project to see examples of how to use the library in C++, Java or Python.
3+
## When to use avTranscoder
4+
* when you need to access the API of ffmpeg, but you want to avoid the head-hurting part of AVPacket, AV_TIME_BASE and all the deep ffmpeg components.
5+
* when you would like to access the ffmpeg features in your language (currently Java and Python, tomorrow what you want!).
46

5-
#### In C++
6-
Set environment:
7-
```
8-
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib:/path/to/avtranscoder/lib
9-
export PATH=$PATH:/path/to/avtranscoder/bin
10-
```
117

12-
#### In Java
13-
Add argument to the JVM:
14-
```
15-
-Djava.library.path=/path/to/avtranscoder/lib/java
8+
## API
9+
The original code is in C++, but almost all the methods are translated into Java/Python without any changes.
10+
So you should start having a look at the [C++ code](src/AvTranscoder) (since the generated Java/Python code is ugly).
11+
12+
In the sake of brevity, the example code of the following section is written in python.
13+
14+
#### At the beginning
15+
Before starting anything, you need to register all the codecs, formats, filters which are enabled at configuration time.
16+
So your first avTranscoder instruction should be:
17+
```python
18+
avtranscoder.preloadCodecsAndFormats()
1619
```
17-
Set environment:
20+
21+
#### Analyse media
22+
To analyse a media, you can create an [__InputFile__](src/AvTranscoder/file/InputFile.hpp) and have access to all header [__properties__](src/AvTranscoder/properties).
23+
```python
24+
# create InputFile
25+
inputFile = avtranscoder.InputFile("/path/to/media/file.mov")
26+
27+
# get access to properties
28+
properties = inputFile.getProperties()
29+
30+
# print all format properties
31+
for prop, value in properties.asVector():
32+
print(prop + ": " + str(value))
33+
34+
# print all properties of each stream
35+
for stream in properties.getStreamProperties():
36+
print("------ Properties of stream at index " + str(stream.getStreamIndex()) + " -----")
37+
for prop, value in stream.asVector():
38+
print(prop + ": " + str(value))
39+
40+
# write all media properties as JSON in a file
41+
import json
42+
with open('data.txt', 'w') as outfile:
43+
json.dump(properties.allPropertiesAsJson(), outfile)
1844
```
19-
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib
45+
46+
Some properties could have a value of _null_ because:
47+
* the property is not indicated in the media.
48+
* the property is not accessible in the header.
49+
50+
For the second point, you can launch a deeper analysis.
51+
For instance, you might like to access to the GOP structure:
52+
```python
53+
# create InputFile
54+
inputFile = avtranscoder.InputFile("/path/to/media/file.mov")
55+
56+
# analyse first GOP (show progression in console)
57+
progress = avtranscoder.NoDisplayProgress()
58+
inputFile.analyse(progress, avtranscoder.eAnalyseLevelFirstGop)
59+
60+
# get access to properties
61+
properties = inputFile.getProperties()
62+
videoProperties = properties.getVideoProperties()[0]
63+
print videoProperties.getGopSize()
64+
print videoProperties.getGopStructure()
2065
```
2166

22-
#### In Python
23-
Set environment:
67+
Check out [__avmeta__](app/avMeta/avMeta.cpp) application to see a C++ example of this use case.
68+
69+
#### Process media
70+
An important part of the API concerns media processing. The general overview of the workflow could be separated into two main cases:
71+
* _transcoding_: demuxing, decoding, transform, encoding and muxing. Here we can update all parts of the media, from the container to the codec used to encode data.
72+
See the [transcoding process](https://ffmpeg.org/ffmpeg.html#toc-Detailed-description) in ffmpeg documentation.
73+
* _rewrap_: omit the decoding, transform and encoding steps. It is useful for changing the container format or modifying container-level metadata.
74+
See the [copy](https://ffmpeg.org/ffmpeg.html#Stream-copy) paramer in ffmpeg documentation.
75+
76+
The main class to process media is the [__Transcoder__](src/AvTranscoder/transcoder/Transcoder.hpp).
77+
78+
Here a rewrapping example to update container (from AVI to MOV):
79+
```python
80+
ouputFile = avtranscoder.OutputFile("/path/to/output/media.mov")
81+
transcoder = avtranscoder.Transcoder(ouputFile)
82+
transcoder.add("/path/to/input/media.avi")
83+
transcoder.process()
84+
```
85+
Check out [__pyrewrap__](app/pyRewrap/pyrewrap.py) application to see a python example of this use case.
86+
87+
Here a transcoding example to encode video and audio streams:
88+
```python
89+
ouputFile = avtranscoder.OutputFile("/path/to/output/media.mov")
90+
transcoder = avtranscoder.Transcoder(ouputFile)
91+
92+
# transcode a video stream at index 0 to H264 High Quality
93+
transcoder.add("/path/to/input/media.avi", 0, "h264-hq")
94+
# transcode an audio stream at index 1 to PCM 24bits 48kHz mono
95+
transcoder.add("/path/to/input/media.wav", 1, "wave24b48kmono")
96+
97+
# show the progression in console
98+
progress = avtranscoder.ConsoleProgress()
99+
transcoder.process(progress)
24100
```
25-
export PYTHONPATH=$PYTHONPATH:/path/to/avtranscoder/lib/python<version>/site-packages/
26-
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib
101+
Check out [__avprocessor__](app/avProcessor/avProcessor.cpp) application to see a C++ example of this use case.
102+
103+
An other important parameter is the transcoding policy, which defines how we manage the process in case of several streams. By default the process ends at the end of the longest stream (so the shorter streams are filled with silence or black images).
104+
To change the transcoding policy:
105+
```python
106+
# stop the process when the output stream at index 0 is finished
107+
transcoder.setProcessMethod(avtranscoder.eProcessMethodBasedOnStream, 0)
108+
109+
# stop the process when the output file has a duration of 50s
110+
transcoder.setProcessMethod(avtranscoder.eProcessMethodBasedOnDuration, 0, 50)
27111
```
28112

29-
#### Use profiles
113+
#### More on process: use profiles
30114
To wrap/unwrap/encode/decode, avTranscoder manipulates profiles.
31115
A profile is a set of key-value given as parameters to the InputFile(unwrap), the OutputFile(wrap), the Video/AudioDecoder(decode) or the Video/AudioEncoder(encode).
32116
There are two ways to manipulate profiles:
33117
* create profiles inside your code, by instanciate ```Map``` structures.
34-
* create profiles outside your code, by create text files.
118+
* create profiles outside your code, by create text files. You have examples [here](avprofiles).
119+
35120
To indicate the path to the text files, export environment variable:
36-
```
121+
```bash
37122
export AVPROFILES=/path/to/profiles
38123
```
39124

@@ -44,19 +129,66 @@ avProfileLongName=profileLongName
44129
avProfileType=avProfileTypeFormat
45130
format=formatName
46131
```
47-
48132
The minimum video profile (encode/decode) is:
49133
```
50134
avProfileName=profileName
51135
avProfileLongName=profileLongName
52136
avProfileType=avProfileTypeVideo
53137
codec=codecName
54138
```
55-
56139
The minimum audio profile (encode/decode) is:
57140
```
58141
avProfileName=profileName
59142
avProfileLongName=profileLongName
60143
avProfileType=avProfileTypeAudio
61144
codec=codecName
62145
```
146+
147+
To encode a video stream using your custom profile:
148+
```python
149+
ouputFile = avtranscoder.OutputFile("/path/to/output/media.mov")
150+
transcoder = avtranscoder.Transcoder(ouputFile)
151+
transcoder.add("/path/to/input/media.avi", 0, "profileName")
152+
transcoder.process()
153+
```
154+
155+
To go into more details about the avTranscoder API, take a look at the [__Doxygen documentation__](http://avtranscoder.github.io/avTranscoder-doxygen/).
156+
157+
## Environment
158+
#### In C++
159+
Set environment:
160+
```bash
161+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib:/path/to/avtranscoder/lib
162+
export PATH=$PATH:/path/to/avtranscoder/bin
163+
```
164+
165+
#### In Java
166+
Add argument to the JVM:
167+
```bash
168+
-Djava.library.path=/path/to/avtranscoder/lib/java
169+
```
170+
Set environment:
171+
```bash
172+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib
173+
```
174+
175+
#### In Python
176+
Set environment:
177+
```bash
178+
export PYTHONPATH=$PYTHONPATH:/path/to/avtranscoder/lib/python<version>/site-packages/
179+
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/ffmpeg/lib
180+
```
181+
182+
## Projects which uses avTranscoder
183+
#### TuttleOFX
184+
TuttleOFX is a library to connect and batch operations with OpenFx plugins. It comes with a set of plugins that allows you to batch process on movies and file sequences.
185+
TuttOFX uses avTranscoder for the [AudioVideo plugin](https://github.com/tuttleofx/TuttleOFX/tree/develop/plugins/image/io/AudioVideo), one of its io plugins.
186+
187+
#### PADdef / Slingshot
188+
PADdef is a platform developed by [Mikros Image](http://www.mikrosimage.eu/) for France Télévisions's new digital distribution centers. Its purpose is to handle the delivery of ready-to-broadcast feature material.
189+
Slingshot is its mirror project for Belgium broadcasters: Medialaan, RTBF and RTL.
190+
PADdef / Slingshot uses avTranscoder in one of its application to transcode media in post-production labs.
191+
192+
#### Ploud
193+
A set of applications developed by [Mikros Image](http://www.mikrosimage.eu/) to analyse, visualize and correct the loudness.
194+
Ploud uses avTranscoder in [one of its application](https://github.com/mikrosimage/loudness_validator/tree/develop/app/mediaAnalyser) to give decoded data to the loudness analyser.

0 commit comments

Comments
 (0)