Home > Software design >  How to log ffmpeg process to file using background terminal?
How to log ffmpeg process to file using background terminal?

Time:01-13

I'm facing a big misunderstanding with bash.

Executing line

ffmpeg -y -i "file.mp4" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy "file.mkv" 2> output.log

process is logged to the file.


But executing

xfce4-terminal -e "ffmpeg -y -i \"file.mp4\" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy \"file.mkv\"" 2> /home/$(whoami)/Desktop/output.log"

the logging to file doesn't work.


What could cause this issue?

CodePudding user response:

It can get tricky escaping things when passing a script to a terminal. I would recommend putting your ffmpeg command into a file (e.g. your-file.sh, making it executable (by running chmod x your-file.sh), then telling the terminal to run that file.

CodePudding user response:

Just try: 1>&file

1>&./output.log ffmpeg -y -i "file.mp4" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy "file.mkv"

1>&~/Desktop/output.log ffmpeg -i "file.mp4" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy "file.mkv"

xfce4-terminal -e "ffmpeg -i \"file.mp4\" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy \"file.mkv\" 1>&~/Desktop/output.log"

xfce4-terminal -e "ffmpeg -i \"file.mp4\" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy \"file.mkv\" 1>&/home/$(whoami)/Desktop/output.log"

Tested on Mac OS X:

# GNU bash, version 3.2.57(1)-release (x86_64-apple-darwin20)
# Copyright (C) 2007 Free Software Foundation, Inc.

1>&./output.log ffmpeg -y -i "file.mp4" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy "file.mkv"

1>&~/Desktop/output.log ffmpeg -i "file.mp4" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy "file.mkv"

1>&/Users/$(whoami)/Desktop/output.log ffmpeg -i "file.mp4" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy "file.mkv"

  •  Tags:  
  • Related