Beispiel #1
0
def get_probe_on_file():
    path = request.args.get('path')

    if path == None:
        abort(400)

    level = request.args.get('level', 'fast')

    analyse_gop_state = "disabled"
    if level == 'firstGop':
        analyse_gop_state = "enabled"

    app.logger.info('Analyse path: %s - GOP analysis: %s', path,
                    analyse_gop_state)
    av.preloadCodecsAndFormats()
    inputFile = av.InputFile(str(path))
    if level == 'firstGop':
        inputFile.analyse(av.NoDisplayProgress(), av.eAnalyseLevelFirstGop)
    data = inputFile.getProperties().allPropertiesAsJson()

    response = Response(data, mimetype='application/json')
    response.headers["Access-Control-Allow-Origin"] = "*"
    return response
Beispiel #2
0
def index():
    libs = av.getLibraries()
    libraries = []
    for library in av.getLibraries():
        libraries.append({
            'name': library.getName(),
            'version': library.getStringVersion(),
            'licence': library.getLicense(),
        })

    av.preloadCodecsAndFormats()
    inputExtensions = []
    for extension in av.getInputExtensions():
        inputExtensions.append(extension)
    outputExtensions = []
    for extension in av.getOutputExtensions():
        outputExtensions.append(extension)

    infos = {
        "libraries": libraries,
        "inputExtensions": inputExtensions,
        "outputExtensions": outputExtensions,
    }
    return jsonify(**infos)
Beispiel #3
0
import os

# Check if environment is setup to run the tests
if os.environ.get('AVTRANSCODER_TEST_AUDIO_WAVE_FILE') is None or os.environ.get('AVTRANSCODER_TEST_VIDEO_MP4_FILE') is None:
    from nose.plugins.skip import SkipTest
    raise SkipTest("Need to define environment variables AVTRANSCODER_TEST_AUDIO_WAVE_FILE / AVTRANSCODER_TEST_VIDEO_MP4_FILE")

from nose.tools import *

from pyAvTranscoder import avtranscoder as av

av.preloadCodecsAndFormats()
av.Logger.setLogLevel(av.AV_LOG_QUIET)


def testAddMetadataDate():
    """
    Add metadata 'date' to the outputFile.
    """
    outputFileName = "testAddMetadataDate.wav"

    ouputFile = av.OutputFile( outputFileName )
    transcoder = av.Transcoder( ouputFile )

    # rewrap a stream
    transcoder.add( os.environ['AVTRANSCODER_TEST_AUDIO_WAVE_FILE'], 0, "")

    # add one metadata
    metadata_to_check = ("date", "value")
    ouputFile.addMetadata( metadata_to_check[0], metadata_to_check[1] )
Beispiel #4
0
        "-o",
        "--outputFile",
        dest="outputFileName",
        type=str,
        default="output.mov",
        help="Set the output filename (output.mov by default).")
    # Parse command-line
    args = parser.parse_args()

except ImportError:
    print("pyconcat currently expects python2.7+")
    exit(1)

# setup avtranscoder
logger = av.Logger().setLogLevel(av.AV_LOG_QUIET)
av.preloadCodecsAndFormats()

streamTypeToConcat = Set()
codecToConcat = Set()
# get all input files
inputFiles = []
for input in args.inputs:
    inputFile = av.InputFile(input)
    streamTypeToConcat.add(
        inputFile.getStream(0).getProperties().getStreamType())
    codecToConcat.add(inputFile.getStream(0).getProperties().getCodecName())
    inputFiles.append(inputFile)

# Check type of streams to rewrap
if len(streamTypeToConcat) > 1:
    raise RuntimeError("Cannot concatenate streams of different type.")
Beispiel #5
0
def get_thumbnail_on_file():
    path = request.args.get('path')
    frame = float(request.args.get('frame', 0))

    if path == None:
        abort(400)

    analyse_gop = request.args.get('analyse_gop', False)

    analyse_gop_state = "disabled"
    if analyse_gop:
        analyse_gop_state = "enabled"

    app.logger.info('Analyse path: %s - GOP analysis: %s', path,
                    analyse_gop_state)
    av.preloadCodecsAndFormats()
    inputFile = av.InputFile(str(path))

    # inputFile.seekAtFrame(frame, av.AVSEEK_FLAG_FRAME)
    # inputFile.seekAtFrame(frame, av.AVSEEK_FLAG_ANY)
    # inputFile.seekAtFrame(frame, av.AVSEEK_FLAG_BACKWARD)

    tmpFilename = "/tmp/thumbnails.jpg"

    # create output file (need to set format profile of encoding to force output format to mjpeg)
    formatProfile = av.ProfileMap()
    formatProfile[av.avProfileIdentificator] = "thumbnailFormatPreset"
    formatProfile[av.avProfileIdentificatorHuman] = "Thumbnail format preset"
    formatProfile[av.avProfileType] = av.avProfileTypeFormat
    formatProfile[av.avProfileFormat] = "mjpeg"
    outputFile = av.OutputFile(tmpFilename)
    outputFile.setupWrapping(formatProfile)

    # create input stream
    videoProperties = inputFile.getProperties().getVideoProperties()[0]
    videoStreamIndex = videoProperties.getStreamIndex()
    videoWidth = videoProperties.getWidth()
    videoHeight = videoProperties.getHeight()
    videoFps = videoProperties.getFps()
    dar = videoProperties.getDar()

    # inputStream = av.InputStream(inputFile, videoStreamIndex)
    # inputStream.activate()

    inputStreamDesc = av.InputStreamDesc(str(path), videoStreamIndex)

    # create output stream
    videoProfile = av.ProfileMap()
    videoProfile[av.avProfileIdentificator] = "thumbnailVideoPreset"
    videoProfile[av.avProfileIdentificatorHuman] = "Thumbnail video preset"
    videoProfile[av.avProfileType] = av.avProfileTypeVideo
    videoProfile[av.avProfileCodec] = "mjpeg"
    # videoProfile[av.avProfilePixelFormat] = "yuvj420p"
    videoProfile[av.avProfilePixelFormat] = "yuvj422p"
    if 'width' in request.args:
        videoProfile[av.avProfileWidth] = str(request.args["width"])
        videoProfile[av.avProfileHeight] = str(
            videoHeight * int(request.args["width"]) / videoWidth)
    # if 'height' in request.args:
    #     videoProfile[av.avProfileHeight] = str(request.args["height"])

    # create transcoder
    transcoder = av.Transcoder(outputFile)
    transcoder.addStream(inputStreamDesc, videoProfile, -frame / 25)

    # launch process
    outputFile.beginWrap()
    transcoder.preProcessCodecLatency()
    transcoder.processFrame()
    outputFile.endWrap()

    return send_file(tmpFilename, mimetype='image/gif')