os:ubuntu18.0.4(ec2:g4.xlarge) Python:3.7.7 ffmpeg:4.3.1
Add the -nostdin
option when running ffmpeg in a background process.
cmd = f'ffmpeg -nostdin -y -i "{mv_input_path}" -vcodec h264_nvenc "{mv_ffmpeg_path}"'
subprocess.call(cmd, shell=True)
After processing the uploaded video with cv2, I created a program that converts and compresses it using `ffmpeg``` and saves it in s3. When I daemonized the program, I got a
Invalid data found when processing input``` error in ``
ffmpeg```.
Error while decoding stream #0:0: Invalid data found when processing input
[mpeg4 @ 0x55cec17c8780] header damaged
Error while decoding stream #0:0: Invalid data found when processing input
[mpeg4 @ 0x55cec17c5480] header damaged
...
...
...
[mpeg4 @ 0x55cec1855f80] header damaged
Error while decoding stream #0:0: Invalid data found when processing input
[mpeg4 @ 0x55cec1866e00] header damaged
Error while decoding stream #0:0: Invalid data found when processing input
Last message repeated 3 times
frame= 83 fps=0.0 q=14.0 Lsize= 1800kB time=00:00:06.30 bitrate=2337.4kbits/s dup=76 drop=0 speed=18.7x
video:1799kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.064613%
Conversion failed!
The conversion seems to be done, but the 76/83 frame is duplicated as in `dup = 76```. When I play the video, it seems to be a 1fps video. As a result of verification, it seems that this error occurs only when it is daemonized. As a result of all this and that, I managed to solve it by creating a Docker that only uses ffmpeg and converting it. However, as mentioned earlier, it could be solved simply by adding the
`-nostdin``` option. .. ..
I haven't found any similar articles and spent a tremendous amount of time just finding this option so I'll share it.
https://unix.stackexchange.com/questions/222847/how-to-stream-with-ffmpeg-in-a-separate-process
Recommended Posts