Opened 9 years ago

Closed 9 years ago

#4388 closed enhancement (invalid)

Audio filter which is set for a specific track is affecting all tracks

Reported by: Drag0nFly Owned by:
Priority: normal Component: undetermined
Version: 2.6 Keywords:
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

Summary of the problem:
================

First off, this might possibly be caused by incorrect usage, so apologies up front. However, after trying a plethora of different options and numerous web searches in an attempt to work around it I came up short. It might also fall into the category of 'unintended/unintuitive behaviour.' I am therefore setting the type to 'enhancement.'

Basically, what I want to accomplish is to re-encode the video of an MKV file while normalizing the audio on one track to 0dBFS (using the volume audio filter set to the correct audio level) at the same time; while leaving other audio tracks in the file untouched (i.e, streamcopying them)

Specifically, the file layout is as follows:

Track ID 0: video (MPEG-4p10/AVC/h.264) <- to be re-encoded with x264
Track ID 1: audio (FLAC) <- to be volumeadjusted by +6.4dB
Track ID 2: audio (DTS) <- to be streamcopied to new file
Track ID 3: audio (DTS) <- to be streamcopied to new file
Track ID 4: subtitles (HDMV PGS) <- to be streamcopied to new file
Chapters: 12 entries

How to reproduce:

Process an MKV with multiple audio tracks, applying a filter to one audio track (with -af:a:0 <filter>) while attempting to streamcopy the others. This is causing FFmpeg to abort with the error message 'Filtering and streamcopy cannot be used together.' as it interprets the filter as being valid for all audio tracks.

I've also tried to use '-filter_complex' (based on suggestions elsewhere), but to no avail.

Full commandline output:

time ffmpeg -i /data/video/work/fullq/King.of.New.York.\(1990\).mkv -map 0 -c:v libx264 -level 4.1 -vf crop=1920:1072:0:4 -x264opts deblock=-3,-3:trellis=2:ref=5:subme=10:bframes=8 -preset slow -crf 17 -c:a:0 flac -af:a:0 volume=+6.4dB -c:a:1 copy -c:a:2 copy -c:s copy /data/video/work/King.of.New.York.\(1990\)-crf17-slow-custom.mkv
ffmpeg version 2.6.1 Copyright (c) 2000-2015 the FFmpeg developers

built with Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.1 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc --enable-libxvid --enable-vda
libavutil 54. 20.100 / 54. 20.100
libavcodec 56. 26.100 / 56. 26.100
libavformat 56. 25.101 / 56. 25.101
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 11.102 / 5. 11.102
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100

[matroska,webm @ 0x7fd0e2826c00] Could not find codec parameters for stream 4 (Subtitle: hdmv_pgs_subtitle): unspecified size
Input #0, matroska,webm, from '/data/video/work/fullq/King.of.New.York.(1990).mkv':

Metadata:

title : King.of.New.York
encoder : libmakemkv v1.8.5 (1.2.0/1.1.0) darwin(x86-release)
creation_time : 2013-11-01 21:01:05

Duration: 01:43:09.31, start: 0.000000, bitrate: 36199 kb/s

Chapter #0:0: start 0.000000, end 502.585417
Metadata:

title : Chapter 01

Chapter #0:1: start 502.585417, end 1106.814042
Metadata:

title : Chapter 02

Chapter #0:2: start 1106.814042, end 1556.888667
Metadata:

title : Chapter 03

Chapter #0:3: start 1556.888667, end 2079.911167
Metadata:

title : Chapter 04

Chapter #0:4: start 2079.911167, end 2577.408167
Metadata:

title : Chapter 05

Chapter #0:5: start 2577.408167, end 3087.334250
Metadata:

title : Chapter 06

Chapter #0:6: start 3087.334250, end 3597.010083
Metadata:

title : Chapter 07

Chapter #0:7: start 3597.010083, end 4046.709333
Metadata:

title : Chapter 08

Chapter #0:8: start 4046.709333, end 4829.574750
Metadata:

title : Chapter 09

Chapter #0:9: start 4829.574750, end 5408.653250
Metadata:

title : Chapter 10

Chapter #0:10: start 5408.653250, end 5990.818167
Metadata:

title : Chapter 11

Chapter #0:11: start 5990.818167, end 6189.312000
Metadata:

title : Chapter 12

Stream #0:0(eng): Video: h264 (High), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc
Stream #0:1(eng): Audio: flac, 48000 Hz, stereo, s16 (default)
Metadata:

title : 2/0

Stream #0:2(eng): Audio: dts (DTS), 48000 Hz, stereo, fltp, 512 kb/s
Metadata:

title : 2/0

Stream #0:3(eng): Audio: dts (DTS), 48000 Hz, stereo, fltp, 512 kb/s
Metadata:

title : 2/0

Stream #0:4(eng): Subtitle: hdmv_pgs_subtitle

Filtergraph 'volume=+6.4dB' was defined for audio output stream 0:2 but codec copy was selected.
Filtering and streamcopy cannot be used together.

If more output (or a sample file) is needed–please let me know.

btw. FFmpeg is a terrific piece of software (which I use daily), so don't take this as undue criticism!

Change History (1)

comment:1 by llogan, 9 years ago

Keywords: audio filtergraph multiple tracks streamcopy removed
Resolution: invalid
Status: newclosed

Please note that this bug tracker is not a support forum, but I guess you weren't sure if you were experiencing a bug or not. Next time user questions should be asked on the ffmpeg-user mailing list or #ffmpeg IRC channel.

The problem is with your command. Do all complex filtering with one filtergraph and explicitly list your mappings. Something like this should work for you (although I don't think it's worth re-encoding to crop 8 pixels and raise volume of a stream...just do those upon playback with a non-retarded player):

ffmpeg -i input -filter_complex "[0:v]crop=iw:ih-8[v];[0:a:0]volume=+6.4dB[a]" -map "[v]" -map "[a]" -map 0:a:1 -map 0:a:2 -map 0:s -c:v libx264 -c:a:0 flac -c:a:1 copy -c:a:2 copy -c:s copy output

It can possibly be made shorter with negative mappings and/or with overriding broader -codec options by following them with more specific ones. I see no reason to use those -x264opts when your -preset will deal with all of that.

If you have any additional questions they should be directed to the mailing list or IRC channel.

Note: See TracTickets for help on using tickets.