[Libav-user] Compiling/linking on raspi fails to link to libav
Hello, I'm building a small tool to run on a Raspberry Pi while I shoot timelapses where I transfer the small JPG files shot besides my raw files and use them for exposure checking and correction. As I already have them on the raspi then I'd like to write a small preview movie clip from them. Therefore I'd like to use libav/ffmpeg with the omx plugin for hardware encoding giving it the images directly from ram as I already have those JPG files open for exposure analyzing. To start playing with libav I just build a small app opening a bunch of jpg files one after another and wanted to add libav encoding. For starters I copied the encode function from the "encode_video.c" example and tried to compile to check if includes and linking are working and always end up not being able to link. My example file (main.cpp), the CMakeLists.txt for building it and my compiler output is here: https://gist.github.com/irieger/f044f7920aec0b92dad29827b6fe7e79 (My files are in /home/pi/dev/test/ffmpeg-encode (build in separate directort /home/pi/dev/test/ffmpeg-encode/build) and ffmpeg is compiled and installed from source with omx support with PREFIX=/home/pi/bin/ffmpeg [./configure --prefix=/home/pi/bin/ffmpeg --enable-mmal --enable-omx --enable-omx-rpi --enable-shared --enable-pic]) I searched for a while but I can't find a clue what's going wrong here. Can anyone here hel me with this? Why will linking fail in this case? Same result with `g++ -std=c++11 -Wall -I /home/pi/bin/ffmpeg/include -o encode-test main.cpp -lOpenImageIO -L/home/pi/bin/ffmpeg/lib -lavformat -lavcodec -lavutil -lswresample -lswscale` -- Kind regards, Ingmar ___ Libav-user mailing list Libav-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user
Re: [Libav-user] Compiling/linking on raspi fails to link to libav
Just a follow up if someone finds this thread with the same problem: You have to put the includes into an extern "C" section like: extern "C" { #include #include #include #include } Haven't a case where I needed extern "C" for includes as most libraries seem to put headers that need to be handled with classic C ABI inside those sections so it took some time to find this problem. Regards, Ingmar On 23.02.2018 09:03, Ingmar Rieger wrote: Hello, I'm building a small tool to run on a Raspberry Pi while I shoot timelapses where I transfer the small JPG files shot besides my raw files and use them for exposure checking and correction. As I already have them on the raspi then I'd like to write a small preview movie clip from them. Therefore I'd like to use libav/ffmpeg with the omx plugin for hardware encoding giving it the images directly from ram as I already have those JPG files open for exposure analyzing. To start playing with libav I just build a small app opening a bunch of jpg files one after another and wanted to add libav encoding. For starters I copied the encode function from the "encode_video.c" example and tried to compile to check if includes and linking are working and always end up not being able to link. My example file (main.cpp), the CMakeLists.txt for building it and my compiler output is here: https://gist.github.com/irieger/f044f7920aec0b92dad29827b6fe7e79 (My files are in /home/pi/dev/test/ffmpeg-encode (build in separate directort /home/pi/dev/test/ffmpeg-encode/build) and ffmpeg is compiled and installed from source with omx support with PREFIX=/home/pi/bin/ffmpeg [./configure --prefix=/home/pi/bin/ffmpeg --enable-mmal --enable-omx --enable-omx-rpi --enable-shared --enable-pic]) I searched for a while but I can't find a clue what's going wrong here. Can anyone here hel me with this? Why will linking fail in this case? Same result with `g++ -std=c++11 -Wall -I /home/pi/bin/ffmpeg/include -o encode-test main.cpp -lOpenImageIO -L/home/pi/bin/ffmpeg/lib -lavformat -lavcodec -lavutil -lswresample -lswscale` -- Kind regards, Ingmar ___ Libav-user mailing list Libav-user@ffmpeg.org http://ffmpeg.org/mailman/listinfo/libav-user
[Libav-user] How to corretly setting container and stream information when using an external encoder and using libavformat to pack the movie container
Hello, I'm currently working on integrating Cineform file read and write into a small toy project for processing image sequences. Worked with exr sequences up until now but those are so storage heavy I decided to include a intermediate video format and with it being the only freely available one I decided to give cineform a go. Therefore I implemented a small file reader first using libavformat to open video containers and unpacking the stream while passing the frames to the Cineform-sdk for decompressing to have the reference decoder. Works fine so far. Now I'm trying the other way round and pack the frames with the cineform encoder and then create a movie container. I tried several approaches from several samples and ours of going through the Doxygen documentation and google searches etc. I'm able to write a file that works correct with my simple reader that will just extract package for package from the video stream and gets the number of frames right and the result looks fine. But there are still a few points I haven't managed to get to work correctly related to metadata of the container and the stream: 1. Set correct container and stream metadata. I copied the codec parameters I extracted from a read cineform example (exported from Blackmagic DaVinci Resolve) to begin with as I found no better solution for this use case yet. - Bit rate is just the value from one sample and depends very much on the input resolution, I think the value is from a 4K sample file. Does this really matter? The value reported from "ffmpeg -i testout.mov" is completely different anyway, I assume it is calculated when calling "av_write_trailer"? 2. Correct frame rate/time base settings. Tried several examples, tried replicating what I extracted from them and made of the documentation regarding libav I found about this topic but as the link below (ffmpeg -i output) shows, the framerate is always wrong. Had combinations of parameters where I had clips with 16k fps etc. 3. Setting start time code of the stream/clip like in the example. 4. Set stream metadata like encoder information. Can somebody give me a hint how to set those data to have valid, well formed files? I have the basic structure of calls I do to libav extracted from my framework and packed it in a gist for better readability: https://gist.github.com/irieger/604125fba000f76095626696f34ae619 Also there is the output of an "ffmpeg -i" call for each the reference file and the generated output in the file ffmpeg. Looking forward to some tips how to tackle this task. -- Kind regards, Ingmar ___ Libav-user mailing list Libav-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email libav-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [Libav-user] How to corretly setting container and stream information when using an external encoder and using libavformat to pack the movie container
Hey, On 26.10.19 10:59, Carl Eugen Hoyos wrote: That's at least a surprising argumentation given the number of encoders included in FFmpeg. Did I miss something? For me the relevant codecs I know for intermediate work are ProRes, DNxHR and Cineform with the later being seldomly used but the only open standard and as I recently found out supported in Resolve for some time now so as my main target is Resolve it seems worth giving it a try. ProRes and DNxHR are both proprietary with only reverse engineered codecs available. - Bit rate is just the value from one sample and depends very much on the input resolution, I think the value is from a 4K sample file. Does this really matter? The value reported from "ffmpeg -i testout.mov" is completely different anyway, I assume it is calculated when calling "av_write_trailer"? And is the written value correct? Looking at my example with just below 800 KB per frame and 5 frames written (at 120fps) and calculating it it makes sense. Also after retime without reencoding to 5 fps it matches the file size. Was just wondering if this is something one has to take care of or if it will be done by libav based on actual data? 2. Correct frame rate/time base settings. Tried several examples, tried replicating what I extracted from them and made of the documentation regarding libav I found about this topic but as the link below (ffmpeg -i output) shows, the framerate is always wrong. Had combinations of parameters where I had clips with 16k fps etc. You have to read back the actual timebase used by the muxer (can be different than the one you requested) and calculate the timestamps accordingly. Is there a good introduction how to correctly set time bases and calculate frame numbers/timecodes from it? Whatever I change I get different frame rates but never what I intend like in this example 24fps. (This shall be variable later on but would be nice to at least understand it) So basically I have an input like frame_rate (in integer for simplicity, don't care about the crazy 23.98 and other strange rates), a frame number from 0 to NUM_FRAMES-1 and ideally a start time input -> How to set the correct time base/rates and calculate the frame dts/pts? -- Kind regards, Ingmar ___ Libav-user mailing list Libav-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email libav-user-requ...@ffmpeg.org with subject "unsubscribe".
Re: [Libav-user] How to corretly setting container and stream information when using an external encoder and using libavformat to pack the movie container
On 26.10.19 14:37, Carl Eugen Hoyos wrote: Am Sa., 26. Okt. 2019 um 14:14 Uhr schrieb Ingmar Rieger : On 26.10.19 10:59, Carl Eugen Hoyos wrote: That's at least a surprising argumentation given the number of encoders included in FFmpeg. Did I miss something? For me the relevant codecs I know for intermediate work are ProRes, DNxHR and Cineform with the later being seldomly used but the only open standard and as I recently found out supported in Resolve for some time now so as my main target is Resolve it seems worth giving it a try. ProRes and DNxHR are both proprietary with only reverse engineered codecs available. Correct: FFmpeg contains encoders for both ProRes and DNxHR. (Note that Cineform being an open standard is a joke, it is exactly as proprietary as the others.) [...] Ok you are right. But still Apple is evil etc. (Blackmagic accidentially activated ProRes in a beta version showing everyone what is already known: There is quicktime support ready...) Still this discussion helps nothing regarding writing the correct container metadata. So basically I have an input like frame_rate (in integer for simplicity, don't care about the crazy 23.98 and other strange rates), a frame number from 0 to NUM_FRAMES-1 and ideally a start time input -> How to set the correct time base/rates and calculate the frame dts/pts? As said, you cannot set the time base (you can but you don't have to) but you have to read the time base used by the muxer, then calculate timestamps using this time base, should be possible with av_rescale_q(). Ok, so what do I set and what will be set automatically in general? As I said I found no documentation describing how to setup a stream manually, that is why I asked in the first place. Just used the remux example (which uses avcodec_parameters_copy) as the base and manually read information from an existing Cineform encoded by Blackmagic to set the parameters manually. With > out_avstream->avg_frame_rate = (AVRational){24, 1}; > out_avstream->r_frame_rate = out_avstream->avg_frame_rate; I now have to correct frame rate shown when av_dump_format is called but after writing some frames the frame rate seems to be reset. My current code that tries to set correct pts/dts values: > AVRational timebase_clip = out_avstream->time_base; > AVRational timebase_count = (AVRational){1, 24}; // also tried {24, 1} > pkg.pts = av_rescale_q(frame, timebase_count, timebase_clip); > pkg.dts = pkg.dts; This results in errors displayed by libav: > [mov @ 0x55b6572cfbc0] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 6 >= 6 So what is the right way to go from frame number to correct timebase conversion. Can someone just give a hint how to correctly call this conversions? From the outputs and everything I would say I seem to be near a solution. -- Kind regards, Ingmar ___ Libav-user mailing list Libav-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/libav-user To unsubscribe, visit link above, or email libav-user-requ...@ffmpeg.org with subject "unsubscribe".