JakeWharton / mkvdts2ac3

Bash script to convert DTS audio to AC3 within a matroska file.
Apache License 2.0
321 stars 60 forks source link

ffmpeg snags stdin which prevents while loops from continuing #69

Open mattster98 opened 12 years ago

mattster98 commented 12 years ago

I was trying to use mkvdts2ac3 in a while loop to process all my mkv's that have DTS tracks, and it would always stop after processing one file. I searched around a bit and the cause appears to be that ffmpeg does that "Press [q] to stop encoding" and that somehow breaks the while loop.

The fix, from here: http://ubuntuforums.org/archive/index.php/t-1335037.html was to add < /dev/null to satisfy the stdin for ffmpeg. However, I can't make that work without eliminating the perl progress tracking for that step. It works great if I change that line to just run a basic ffmpeg command line instead.

Hopefully your bash-fu is stronger than mine and you can make this work, while still keeping the nifty progress tracking you've got.

Thanks for the awesome script!!

choekstr commented 12 years ago

Hmm. Are you just doing a: For i in $(ls moviefiles) do loop?

Let me know how you are calling it and any options you use so I can recreate and see if I can come up with an alternate solution.

mattster98 commented 12 years ago

It's a little more complicated, unfortunately.

find . | grep mkv$ | while read lines; do if mkvinfo "$lines" | grep A_DTS; then echo Starting $lines; mkvdts2ac3 -n -m "$lines"; echo $lines is done;fi; done

Not pretty, but gets the job done. The "echo" statements were mostly for troubleshooting.. not required. The mkvinfo is just to prevent your script from bombing over and over needlessly. -n is the only option I really need. I added -m because of a reference to being called from cron or something which I thought might help.

--Matt

On Fri, Feb 24, 2012 at 4:13 PM, Chris Hoekstra < reply@reply.github.com

wrote:

Hmm. Are you just doing a: For i in $(ls moviefiles) do loop?

Let me know how you are calling it and any options you use so I can recreate and see if I can come up with an alternate solution.


Reply to this email directly or view it on GitHub: https://github.com/JakeWharton/mkvdts2ac3/issues/69#issuecomment-4165277

JakeWharton commented 12 years ago

Just an FYI, you shouldn't need to grep for DTS. The script will ignore anything without a DTS track in it and anything that looks like its already had the conversion done.

jonuwz commented 7 years ago

last answer here : https://stackoverflow.com/questions/21634088/execute-ffmpeg-command-in-a-loop

passing -nostdin to ffmpeg is the right thing to do . Since we're masking the interactive dialog anyway, this should be in the default command