[FFmpeg-devel] [PATCHv2] ffmpeg: modify tty state when stderr is redirected

Ganesh Ajjanagadde gajjanagadde at gmail.com
Fri Jul 31 13:33:24 CEST 2015


On Fri, Jul 31, 2015 at 4:32 AM, Nicolas George <george at nsup.org> wrote:
> Le duodi 12 thermidor, an CCXXIII, Ganesh Ajjanagadde a écrit :
>>  ffmpeg(){
>> +    stty_opts="$(stty --save)"
>>      dec_opts="-hwaccel $hwaccel -threads $threads -thread_type $thread_type"
>>      ffmpeg_args="-nostats -cpuflags $cpuflags"
>>      for arg in $@; do
>> @@ -99,6 +100,7 @@ ffmpeg(){
>>          ffmpeg_args="${ffmpeg_args} ${arg}"
>>      done
>>      run ffmpeg ${ffmpeg_args}
>> +    stty "${stty_opts}"
>
> Does this work? With that change, the return code of the wrapper function is
> no longer the return code of "run ffmpeg" but the return code of stty,
> always success.

It does at least in Michael's example, but clobbers the exit code,
which is why I did not notice it.
Try a make fate-acodec-adpcm-ima_wav, after inserting an abort() in
wav_read_header().
With above patch,
make errors out:
TEST    acodec-adpcm-ima_wav
--- ./tests/ref/acodec/adpcm-ima_wav    2015-07-29 23:05:55.951506099 -0400
+++ tests/data/fate/acodec-adpcm-ima_wav    2015-07-31 07:25:24.029781733 -0400
@@ -1,4 +1,2 @@
 56b75c3a6dacedcf2ce7b0586aa33594 *tests/data/fate/acodec-adpcm-ima_wav.wav
 267324 tests/data/fate/acodec-adpcm-ima_wav.wav
-78a2af1c895792d0c221d127bdd48ece *tests/data/fate/acodec-adpcm-ima_wav.out.wav
-stddev:  903.51 PSNR: 37.21 MAXDIFF:34026 bytes:  1058400/  1061748
Test acodec-adpcm-ima_wav failed. Look at
tests/data/fate/acodec-adpcm-ima_wav.err for details.
tests/Makefile:203: recipe for target 'fate-acodec-adpcm-ima_wav' failed
make: *** [fate-acodec-adpcm-ima_wav] Error 1

without this patch to run-tests,
make errors out:
TEST    acodec-adpcm-ima_wav
--- ./tests/ref/acodec/adpcm-ima_wav    2015-07-29 23:05:55.951506099 -0400
+++ tests/data/fate/acodec-adpcm-ima_wav    2015-07-31 07:25:54.486446785 -0400
@@ -1,4 +0,0 @@
-56b75c3a6dacedcf2ce7b0586aa33594 *tests/data/fate/acodec-adpcm-ima_wav.wav
-267324 tests/data/fate/acodec-adpcm-ima_wav.wav
-78a2af1c895792d0c221d127bdd48ece *tests/data/fate/acodec-adpcm-ima_wav.out.wav
-stddev:  903.51 PSNR: 37.21 MAXDIFF:34026 bytes:  1058400/  1061748
Test acodec-adpcm-ima_wav failed. Look at
tests/data/fate/acodec-adpcm-ima_wav.err for details.
tests/Makefile:203: recipe for target 'fate-acodec-adpcm-ima_wav' failed
make: *** [fate-acodec-adpcm-ima_wav] Error 134

Nevertheless, echo $? invoked right after this yields 2 for both.
The reason this happens is the md5sum wrapper sees that the output
file has not been written,
and errors out there (see the .err files for precisely what I mean).
This is why I did not notice it.


>
> There is a much simpler fix: add -nostdin to ffmpeg_args, along with
> -nostats.

Seeing the above, I think just the change in ffmpeg.c along with
telling people of the workarounds for both bashrc and zshrc
should be enough, with no modification to run-tests.sh.

>
> Regards,
>
> --
>   Nicolas George


More information about the ffmpeg-devel mailing list