Can you tell me how you invoke ffmpeg

Discussion related to "under the hood" OpenMV topics.
bogflap
Posts: 19
Joined: Mon Apr 16, 2018 10:03 am

Can you tell me how you invoke ffmpeg

Postby bogflap » Mon Jun 11, 2018 11:50 am

I have created a stream.bin file using the image_writer_1.py example.
I am now trying to convert this bin file to the mp4 format using the Tools->Video Tools->Convert Video File functionality in the IDE.
(IDE V1.9.0, firmware V2.9.0)
I have made a local copy of the bin file but when I try to convert it I get the error Failed to launch ffmpeg!
I am running under opensuse which I know is not one of your supported platforms.
However if you can tell me what parameters you use to invoke ffmpeg maybe I can run this from the command line and find out what the problem is.

Forgot to add the following
ffmpeg -version
ffmpeg version 3.3.4 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 4.8 (SUSE Linux)
configuration: --prefix=/usr --libdir=/usr/lib64 --shlibdir=/usr/lib64 --incdir=/usr/include/ffmpeg --extra-cflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g' --optflags='-fmessage-length=0 -grecord-gcc-switches -O2 -Wall -D_FORTIFY_SOURCE=2 -fstack-protector -funwind-tables -fasynchronous-unwind-tables -g' --disable-htmlpages --enable-pic --disable-stripping --enable-shared --disable-static --enable-gpl --disable-openssl --enable-avresample --enable-libcdio --enable-gnutls --enable-ladspa --enable-libass --enable-libbluray --enable-libcelt --enable-libcdio --enable-libdc1394 --enable-libfreetype --enable-libgsm --enable-libmp3lame --enable-libopenjpeg --enable-libopus --enable-libpulse --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvorbis --enable-libvpx --enable-libwebp --enable-netcdf --enable-vaapi --enable-vdpau --enable-libfdk_aac --enable-nonfree --enable-libx264 --enable-libx265 --enable-libxvid
libavutil 55. 58.100 / 55. 58.100
libavcodec 57. 89.100 / 57. 89.100
libavformat 57. 71.100 / 57. 71.100
libavdevice 57. 6.100 / 57. 6.100
libavfilter 6. 82.100 / 6. 82.100
libavresample 3. 5. 0 / 3. 5. 0
libswscale 4. 6.100 / 4. 6.100
libswresample 2. 7.100 / 2. 7.100
libpostproc 54. 5.100 / 54. 5.100
User avatar
kwagyeman
Posts: 2195
Joined: Sun May 24, 2015 2:10 pm

Re: Can you tell me how you invoke ffmpeg

Postby kwagyeman » Mon Jun 11, 2018 12:46 pm

Hi, here's the code:

https://github.com/openmv/qt-creator/bl ... s.cpp#L549

Please send me the command line you used to launch it and I can add the fix.
Nyamekye,
User avatar
kwagyeman
Posts: 2195
Joined: Sun May 24, 2015 2:10 pm

Re: Can you tell me how you invoke ffmpeg

Postby kwagyeman » Mon Jun 11, 2018 12:47 pm

Most likely the linux program just can't run due to a binary error and it just crashes silently. So, you may need to re-build.
Nyamekye,
bogflap
Posts: 19
Joined: Mon Apr 16, 2018 10:03 am

Re: Can you tell me how you invoke ffmpeg

Postby bogflap » Tue Jun 12, 2018 6:10 am

In order to run ffmpeg the IDE creates a shell script with file path /tmp/openmvide-ffmpeg.sh and with the following contents

#!/bin/sh

"/home/bogflap/bin/openmv-ide/build-qtcreator-Desktop_Qt_5_5_1_GCC_64bit-Debug/share/qtcreator/ffmpeg/linux-x86_64/ffmpeg" -hide_banner -i "/tmp/stream.mjpeg" "/home/bogflap/tmp/stream.mp4"

I am assuming the user name bogflap here and I compiled the IDE using QtCreator using QT5.5.1.

The shell script is then run as a detached program using the following command x-terminal-emulator -e /tmp/openmvide-ffmpeg.sh
Problem under opensuse is that the program x-terminal-emulator is not part of the opensuse package hierarchy i.e. not installable using yast.

Anyway the equivalent under opensuse is to use the program xterm in place of x-terminal-emulator.
Hence the command line xterm -e /tmp/openmvide-ffmpeg.sh sort of runs okay.
However there is one problem that I am unsure about. On my system ffmpeg prompts the user to overwrite if the output file already exists.
What happens if this occurs when running the program detached I suspect could be problematic.
My limited knowledge and memory here leads me to believe that problems exist when using stdin and stdout in a detached program.
Perhaps someone can help out here.
bogflap
Posts: 19
Joined: Mon Apr 16, 2018 10:03 am

Re: Can you tell me how you invoke ffmpeg

Postby bogflap » Tue Jun 12, 2018 6:44 am

This raises another question about ImageWriter and ImageReader.
The IDE creates an mjpeg type file which to my mind makes me think the file is lossily compressed.
If so then reading back a writer created set of images will have lost some quality due to the compression algorithms.
Also exiftool reports an image width x height of 160 x 120.
I have been looking at using the writer/reader combination for debugging purposes and am a little concerned.
Can you put my concerns to rest
User avatar
kwagyeman
Posts: 2195
Joined: Sun May 24, 2015 2:10 pm

Re: Can you tell me how you invoke ffmpeg

Postby kwagyeman » Tue Jun 12, 2018 11:44 am

Hi, I can change the emulator method to xterm on open suse. However, maybe the OS should define that program pointer so it would work normally?

Anyway, as for ImageWriter, yes, when converting it to a video I make an mjpeg image file with each frame and then run ffmpeg on that.

Similarly, when I write a converter for turning any video into an ImageReader video I will have to turn the video into an mjpeg file and then read each jpeg out of that file.

This functionality doesn't exist yet however. The IDE only converts files made by the camera (image writer) to any other video format. I will have to work on the code for the reverse direction.
Nyamekye,
bogflap
Posts: 19
Joined: Mon Apr 16, 2018 10:03 am

Re: Can you tell me how you invoke ffmpeg

Postby bogflap » Tue Jun 12, 2018 1:54 pm

Thank you for the prompt response.
There is no need to make opensuse a special case and creating a symbolic link named x-terminal-emulator to the xterm program is not a problem
There is also no need from my point of view to convert mp4 files back to ImageWriter format.
I want to use files generated solely by ImageWriter as debug input, using ImageReader, on the M7.
My only need to convert the bin files to mp4 is so that I can see what has been recorded in a convenient format.
My only concern was that ImageWriter was saving its bin file in a jpeg format which having examined the code more closely it is not.
So thank you for your response and I cannot see any need for you to alter anything. Opensuse is not that special

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests