Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
audiowmark
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Stefan Westerfeld
audiowmark
Commits
23bdc7f7
Commit
23bdc7f7
authored
Apr 04, 2020
by
Stefan Westerfeld
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
videowmark: check number of audio/video streams before actual processing
Signed-off-by:
Stefan Westerfeld
<
stefan@space.twc.de
>
parent
2b6a3aa3
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
1 deletion
+27
-1
TODO
src/TODO
+0
-1
videowmark
src/videowmark
+27
-0
No files found.
src/TODO
View file @
23bdc7f7
possible improvements:
- dynamic bit strength
plausibility checks
opus length ffprobe -show_format phil.mkv
src/videowmark
View file @
23bdc7f7
...
...
@@ -31,6 +31,19 @@ function audio_encode_options
}'
}
# count number of audio and video streams, typical output: "audio=1:video=1"
function
audio_video_stream_count
{
ffprobe
-v
error
-print_format
compact
-show_streams
"
$1
"
|
awk
-F
'|'
'
{
for (i = 1; i < NF; i++)
x[$i]++;
}
END {
printf "audio=%d:video=%d\n",x["codec_type=audio"],x["codec_type=video"]
}'
}
function
create_temp_files
{
local
fd
...
...
@@ -97,6 +110,13 @@ if [ "$1" == "add" ] && [ "$#" == 4 ]; then
ext_out
=
$(
extension
"
$3
"
)
[
"
$ext_in
"
==
"
$ext_out
"
]
||
die
"input/output extension must match ('
$ext_in
' vs. '
$ext_out
')"
# check audio/video stream count
stream_count
=
$(
audio_video_stream_count
"
$2
"
)
[
"
$stream_count
"
==
"audio=1:video=1"
]
||
{
\
echo
>
&2
"videowmark: detected input file stream count:
$stream_count
"
die
"input file must have one audio stream and one video stream"
}
# create tmpfiles
create_temp_files 3 4
orig_wav
=
/dev/fd/3
...
...
@@ -111,6 +131,13 @@ if [ "$1" == "add" ] && [ "$#" == 4 ]; then
ffmpeg
$FFMPEG_VERBOSE
-y
-i
"
$2
"
-i
"
$wm_wav
"
-c
:v copy
$(
audio_encode_options
"
$2
"
)
-map
0:v:0
-map
1:a:0
"
$3
"
||
\
die
"merging video and watermarked audio failed (ffmpeg)"
elif
[
"
$1
"
==
"get"
]
&&
[
"$#"
==
2
]
;
then
# check audio/video stream count
stream_count
=
$(
audio_video_stream_count
"
$2
"
)
[
"
$stream_count
"
==
"audio=1:video=1"
]
||
{
\
echo
>
&2
"videowmark: detected input file stream count:
$stream_count
"
die
"input file must have one audio stream and one video stream"
}
# create tmpfiles
create_temp_files 3
wav
=
/dev/fd/3
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment