Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smaller binary size #208

Open
saoron opened this issue Feb 18, 2025 · 4 comments
Open

Smaller binary size #208

saoron opened this issue Feb 18, 2025 · 4 comments

Comments

@saoron
Copy link

saoron commented Feb 18, 2025

Hi, Thanks for this great project.

We want to use it on an embedded project with a small amount of free storage memory, We do have ffmpeg (5.1) in the system.

Can this be compiled in a way that will use significantly less disk space?

@anthwlock
Copy link
Owner

If the environment provides FFmpeg as shared libraries (.so files), it should be possible to link against those instead of statically compiling with FFmpeg. In the Makefile, this is the default behavior (FF_VER=shared)

@atanas-vladimirov
Copy link

atanas-vladimirov commented Feb 23, 2025

Hey @anthwlock,

Do you have any hints on how the untrunc can be build with an older gcc (older than 8)?

root@e83d76f57359:~/projects/untrunc# make
untrunc: v367-13cafed
ffmpeg: shared

g++ -MMD -MP -DUNTR_VERSION=\"v367-13cafed\" -isystem/usr/include/ffmpeg -std=c++17 -D_FILE_OFFSET_BITS=64 -g -o .build_shared/src/track.o -c src/track.cpp
In file included from src/codec.h:11:0,
                 from src/track.h:28,
                 from src/track.cpp:21:
src/common.h: In instantiation of 'void printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {unsigned int, unsigned int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]':
src/common.h:275:11:   required from 'void __dbgg(const string&, const string&, Args ...) [with Args = {unsigned int, unsigned int}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
src/track.h:163:4:   required from here
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {unsigned int, unsigned int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<first capture>' is uninitialized reference
   ([&](const auto& arg) {
    ^
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {unsigned int, unsigned int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<os capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {unsigned int, unsigned int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<names capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {unsigned int, unsigned int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<i capture>' is uninitialized reference
src/common.h: In instantiation of 'void printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]':
src/common.h:275:11:   required from 'void __dbgg(const string&, const string&, Args ...) [with Args = {int, int, bool}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
src/mp4.h:155:4:   required from here
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<first capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<os capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<names capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<i capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<first capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<os capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<names capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {int, int, bool}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<i capture>' is uninitialized reference
src/common.h:264:4: error: use of 'printArgs(std::ostream&, const string&, const string&, Args ...)::<lambda(const auto:1&)> [with auto:1 = bool; Args = {int, int, bool}]' before deduction of 'auto'
   ([&](const auto& arg) {
    ~~~~~~~~~~~~~~~~~~~~~~
    if (!first) {
    ~~~~~~~~~~~~~
     os << ", ";
     ~~~~~~~~~~~
    }
    ~
    first = false;
    ~~~~~~~~~~~~~~
    os << names[i++] << "=" << arg;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   }(args), ...);
   ~^~~~~~
src/common.h: In instantiation of 'void printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {long unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]':
src/common.h:275:11:   required from 'void __dbgg(const string&, const string&, Args ...) [with Args = {long unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
src/mp4.h:301:4:   required from here
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {long unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<first capture>' is uninitialized reference
   ([&](const auto& arg) {
    ^
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {long unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<os capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {long unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<names capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {long unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<i capture>' is uninitialized reference
src/common.h:264:4: error: use of 'printArgs(std::ostream&, const string&, const string&, Args ...)::<lambda(const auto:1&)> [with auto:1 = std::__cxx11::basic_string<char>; Args = {long unsigned int, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, int, int}]' before deduction of 'auto'
   ([&](const auto& arg) {
    ~~~~~~~~~~~~~~~~~~~~~~
    if (!first) {
    ~~~~~~~~~~~~~
     os << ", ";
     ~~~~~~~~~~~
    }
    ~
    first = false;
    ~~~~~~~~~~~~~~
    os << names[i++] << "=" << arg;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   }(args), ...);
   ~^~~~~~
src/common.h: In instantiation of 'void printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]':
src/common.h:292:11:   required from 'void __assertt(const char*, const char*, const char*, int, const string&, Args ...) [with Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long int}; std::__cxx11::string = std::__cxx11::basic_string<char>]'
src/track.cpp:519:2:   required from here
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<first capture>' is uninitialized reference
   ([&](const auto& arg) {
    ^
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<os capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<names capture>' is uninitialized reference
src/common.h:258:4: error: member 'printArgs(std::ostream&, const string&, const string&, Args ...) [with Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long int}; std::ostream = std::basic_ostream<char>; std::__cxx11::string = std::__cxx11::basic_string<char>]::<lambda(const auto:1&)>::<i capture>' is uninitialized reference
src/common.h:264:4: error: use of 'printArgs(std::ostream&, const string&, const string&, Args ...)::<lambda(const auto:1&)> [with auto:1 = long int; Args = {std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, long int}]' before deduction of 'auto'
   ([&](const auto& arg) {
    ~~~~~~~~~~~~~~~~~~~~~~
    if (!first) {
    ~~~~~~~~~~~~~
     os << ", ";
     ~~~~~~~~~~~
    }
    ~
    first = false;
    ~~~~~~~~~~~~~~
    os << names[i++] << "=" << arg;
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   }(args), ...);
   ~^~~~~~
Makefile:174: recipe for target '.build_shared/src/track.o' failed
make: *** [.build_shared/src/track.o] Error 1

#### make failed to build some targets (1 seconds) ####
root@e83d76f57359:~/projects/untrunc# gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~18.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

It's worth mentioning that I'm not good at programming :/.

Thanks for your time and best wishes,
Atanas

@anthwlock
Copy link
Owner

You could

  • Use an older commit (before 6ac9f9e)
  • Change the code to be compatible with the older compiler
  • Use a newer compiler

I recommend the last option, but I understand that sometimes it might not be easy to obtain a newer one. You could try to get a precompiled LLVM tool chain: https://releases.llvm.org/download.html

You could try to ask ChatGPT (or similar) about any of the previous steps, in case you need further help. Good luck

@atanas-vladimirov
Copy link

Thank you so much!

I was almost sure about commit 6ac9f9e :). I managed to build it against 60379a9

I'll see what can be done on the second point.

The third option seems too hard for me (almost imposible)

I wish you all the best!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants