File: encoder_example_ffmpeg

package info (click to toggle)
libtheora 1.2.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,544 kB
  • sloc: ansic: 35,055; sh: 4,550; asm: 3,039; makefile: 869; javascript: 279; perl: 252
file content (81 lines) | stat: -rwxr-xr-x 2,644 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/sh
####################################################################
#                                                                  #
# THIS FILE IS PART OF THE OggTheora SOFTWARE CODEC SOURCE CODE.   #
# USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     #
# GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE #
# IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       #
#                                                                  #
# THE Theora SOURCE CODE IS COPYRIGHT (C) 2009,2025                #
# by the Xiph.Org Foundation and contributors                      #
# https://www.xiph.org/                                            #
#                                                                  #
####################################################################

ffmpeg=ffmpeg
if ! command -v $ffmpeg 2>&1 >/dev/null ; then
        echo error: $ffmpeg executable not found!
        exit 1
fi
ffprobe=ffprobe
if ! command -v $ffprobe 2>&1 >/dev/null ; then
        echo error: $ffprobe executable not found!
        exit 1
fi


# TODO: get script dir, and call encoder_example from the same dir, to
#       support both system installed as well as local dir version

# check encoder_example as well as Debian named theora_encoder_example
if command -v encoder_example 2>&1 >/dev/null ; then
        encoder_example=encoder_example
elif command -v theora_encoder_example 2>&1 >/dev/null ; then
        encoder_example=theora_encoder_example
else
        echo error: encoder_example or theora_encoder_example executable \
not found!
        exit 1
fi

if [ -z "$2" ] ; then
        echo usage:
        echo $0 inputfile outputfile [$encoder_example encoder options]
        echo
        echo for $encoder_example encoder options run:
        echo $encoder_example -h
        exit
fi

inputfile=$1
outputfile=$2
shift 2

INPUT_AUDIO=0
# check if there is audio in the input file, then encoder_example
# needs a different syntax
$ffprobe -i $inputfile -show_streams -select_streams a -loglevel error | \
    grep -q audio && INPUT_AUDIO=1

video=$(mktemp -u)
mkfifo -m 600 $video

# TODO: merge the two separate ffmpeg commands to a single process
$ffmpeg -i $inputfile -y -hide_banner -loglevel error -an \
	-f yuv4mpegpipe $video &

if [ "$INPUT_AUDIO" = 1 ] ; then
        audio=$(mktemp -u)
        mkfifo -m 600 $audio

        $ffmpeg -i $inputfile -y -hide_banner -loglevel error -vn -f wav \
		-bitexact $audio &

        $encoder_example $@ $audio $video -o $outputfile

        rm -f $audio
else
        $encoder_example $@ $video -o $outputfile
fi

rm -f $video