Why do I get debug logs when I run ffmpeg from inside a loop in bash script?

Viewed 432

I have the folling script with a loop:

#!/bin/bash

set -x

find . -type f -name '*265*.mkv' -print0 | while IFS= read -r -d '' file; do
  orig_file=${file}
  new_file=${file#"./"}
  new_file="${new_file/x265/264}"
  echo ${new_file}
  ffmpeg -hide_banner -loglevel warning -y -hwaccel nvdec \
    -i "${orig_file}" -c:v h264_nvenc -pix_fmt yuv420p -c:a copy "${new_file}"
done

I can observe the commands are correct

ffmpeg -hide_banner -loglevel warning -y -hwaccel nvdec -i './Something (2018) - S01E01 - (1080p WEB-DL x265 ImE).mkv' -c:v h264_nvenc -pix_fmt yuv420p -c:a copy 'Something (2018) - S01E01 - (1080p WEB-DL 264 ImE).mkv'

but they produce this gigantic debug output with debug=1

debug=1
cur_dts is invalid st:2 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[hevc @ 0x55f5dc354b40] nal_unit_type: 0(TRAIL_N), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55f5dc354b40] Output frame with POC 28.
Clipping frame in rate conversion by 0.003990
cur_dts is invalid st:2 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
    Last message repeated 8 times
[hevc @ 0x55f5dc365480] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55f5dc365480] Output frame with POC 29.
cur_dts is invalid st:2 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[hevc @ 0x55f5dc375dc0] nal_unit_type: 1(TRAIL_R), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55f5dc375dc0] Output frame with POC 30.
cur_dts is invalid st:2 (0) [init:1 i_done:0 finish:0] (this is harmless if it occurs once at the start per stream)
[hevc @ 0x55f5dc386700] nal_unit_type: 0(TRAIL_N), nuh_layer_id: 0, temporal_id: 0
[hevc @ 0x55f5dc386700] Output frame with POC 31.
...

and then it stops at:

stream #0:
  keyframe=0
  duration=0.041
  dts=73.156  pts=73.407
  size=47859
stream #0:
  keyframe=0
  duration=0.041
  dts=73.198  pts=73.323
  size=14585

Enter command: <target>|all <time>|-1 <command>[ <argument>]

But when I run this from a terminal or without a loop it all works well.

What's wrong here?

0 Answers
Related