Golang : ffmpeg with os/exec.Command() returns non-zero status
Problem:
You want to use ffmpeg
with os/exec.Command() and Run() to create your video files.
However, it keeps bombing out with the error message:
exit status 1
You are able to execute the command with the supplied parameters and flags just fine on your terminal.
What's going on? How to fix this?
Solution:
Golang's os/exec.Command()
function does not have the shell=true
feature like Python did. ffmpeg is very sensitive to white spaces when running from another program. To fix the problem, simply remove whitespaces by using ,
instead of +
to assemble the flags and parameters to ffmpeg.
For example,
cmd := exec.Command("ffmpeg", "-r "+recordedFPSstring+" -i "+videoFileName+" -r 6 temp_"+videoFileName)
to
cmd := exec.Command("ffmpeg", "-r", recordedFPSstring, "-i", videoFileName, "-r", "6", "temp_"+videoFileName)
See also : Golang : Merge video(OpenCV) and audio(PortAudio) into a mp4 file
By
IF you gain some knowledge or the information here solved your programming problem. Please consider donating to the less fortunate or some charities that you like. Apart from donation, planting trees, volunteering or reducing your carbon footprint will be great too.
Advertisement
Tutorials
+24k Golang : Find biggest/largest number in array
+6.1k Linux/Unix : Commands that you need to be careful about
+18.3k Golang : How to remove certain lines from a file
+6.5k Golang : How to validate ISBN?
+22.8k Golang : simulate tail -f or read last line from log file example
+9.9k Golang : Get escape characters \u form from unicode characters
+23.8k Golang : Fix type interface{} has no field or no methods and type assertions example
+23k Golang : Randomly pick an item from a slice/array example
+11k Golang : Fix go.exe is not compatible with the version of Windows you're running
+5k Swift : Convert (cast) Float to Int or Int32 value
+8.7k Android Studio : Image button and button example
+10.4k Golang : Generate 403 Forbidden to protect a page or prevent indexing by search engine