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?
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.
Alright, I found one solution to my problem by adding nohup before ffmpeg like this:
xfce4-terminal -e "nohup ffmpeg -y -i \"file.mp4\" -map 0:v:0 -map 0:a:0 -c:v copy -c:a copy -c:s copy \"file.mkv\""
At least this stores me all terminal output data to /home/$(whoami)/nohup.out file.
Thanks anybody for trying to help me! :)
Related
I have two long audio files. I want to merge cut some part from each video
and merge both parts in one file.
In below command the problem there is no audio in the second audio part. It contain the first part and the second is empty.
What is the problem?
ffmpeg -f lavfi -i color=c=black
-ss 157.824 -t 99.818
-i "file1.mp4"
-ss 315.764 -t 50.308
-i "file2.mp4"
-s 854x480
-aspect 1.779167
-r 25
-c:v libx264
-b:v 800k
-c:a aac
-strict experimental
-b:a 128k
-f mp4
-t 150.126 -async 1
-y "output.mp4"
Currently, using ffmpeg, I am using two commands on my Terminal to:
1) create a video from a bunch of images:
ffmpeg -r 60 -f image2 -s 1920x1080 -i rotated-pano_frame%05d_color_corrected_gradblend.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4
2) stream the video to a udp address:
ffmpeg -re -i test.mp4 -c copy -f flv udp://127.0.0.1:48550
I am trying to combine both these instructions into one command line instruction, using &&, as suggested in the answer to a previous question of mine:
ffmpeg -r 60 -f image2 -s 1920x1080 -i rotated-pano_frame%05d_color_corrected_gradblend.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4 \
&& ffmpeg -re -i test.mp4 -c copy -f flv udp://127.0.0.1:48550
but am encountering an error which prevents streaming:
[flv # 0x7fa2ba800000] video stream discovered after head already parsed.
Thoughts on a different command line syntax to join the two instructions, different ffmpeg instruction (filters perhaps?), and why I am getting the error?
Currently, using ffmpeg, I am using two commands on my Terminal to:
1) create a video from a bunch of images:
ffmpeg -r 60 -f image2 -s 1920x1080 -i rotated-pano_frame%05d_color_corrected_gradblend.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4
2) stream the video to a udp address:
ffmpeg -re -i test.mp4 -c copy -f flv udp://127.0.0.1:48550
How can I combine these two commands, into one single ffmpeg command?
A concern I have is that it takes a couple of minutes to generate the video from the images. Therefore, these commands have to happen serially, whereby the second command waits a few minutes for the first command to be completed, before it ensues.
Just add && between the two commands. This will execute the second command if the first executes successfully.
ffmpeg -r 60 -f image2 -s 1920x1080 -i rotated-pano_frame%05d_color_corrected_gradblend.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p test.mp4 && ffmpeg -re -i test.mp4 -c copy -f flv udp://127.0.0.1:48550
Need to concat audio files and add background music in a single command.
Right now I use the following commands to do so,
To concat:
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4 -i 6.mp4 -i 7.mp4 -i 8.mp4 -i 9.mp4 -i 10.mp4 -filter_complex '[0:0][1:0]concat=n=10:v=0:a=1[out]' -map '[out]' -strict -2 -y 10_final.mp4
To add background music:
ffmpeg -i 10_final.mp4 -i music.mp4 -filter_complex "[0:a]volume=1dB[a0];[1:a]volume=0.5[a1];[a0][a1]amerge=inputs=2[a]" -map "[a]" -ac 1 -ab 32000 -ar 22050 -strict -2 -y 10_with_music.mp4
But his process is a quite time-consuming process as every time the file read/write happening to the output.
Is there a way I can merge these two above commands to a single so that the command should be optimized.
Use
ffmpeg -i 1.mp4 -i 2.mp4 -i 3.mp4 -i 4.mp4 -i 5.mp4
-i 6.mp4 -i 7.mp4 -i 8.mp4 -i 9.mp4 -i 10.mp4
-i music.mp4
-filter_complex '[0:0][1:0]...[9:0]concat=n=10:v=0:a=1,volume=1dB[a0];
[10]volume=0.5dB[a1];[a0][a1]amerge[a]'
-map '[a]' -strict -2 -y 10_with_music.mp4
I tried
ffmpeg -i rtsp://172.19.1.34/live.sdp -acodec copy -vcodec copy b.mp4 2>>log.txt 2>&1
to keep stderr output and also redirect it to file.
But it failed.
However, I can keep the stderr output by
ffmpeg -i rtsp://172.19.1.34/live.sdp -acodec copy -vcodec copy b.mp4 2>log.txt
You can redirect stderr to stdout with 2>&1, and then use tee command.
cmd 2>&1 | tee -a log
try this
ffmpeg -i rtsp://172.19.1.34/live.sdp -acodec copy -vcodec copy b.mp4 &> log.txt
or this
nohup ffmpeg -i rtsp://172.19.1.34/live.sdp -acodec copy -vcodec copy b.mp4
and look for nohup.out after the command returns.