Giter Club home page Giter Club logo

mp4fpsmod's Introduction

mp4fpsmod

What is this?

Tiny mp4 time code editor. You can use this for changing fps, delaying audio tracks, executing DTS compression, extracting time codes of mp4.

Example

Read foo.mp4, change fps to 25, and save to bar.mp4:

mp4fpsmod -r 0:25 -o bar.mp4 foo.mp4

Read foo.mp4, change fps of first 300 frames to 30000/1001, next 600 frames to 24000/1001, and rest of the movie to 30000/1001 (producing VFR movie):

mp4fpsmod -r 300:30000/1001 -r 600:24000/1001 -r 0:30000/1001 -o bar.mp4 foo.mp4

Edit timecodes of foo.mp4 with timecode_v2 described in timecode.txt, and save to bar.mp4:

mp4fpsmod -t timecode.txt foo.mp4 -o bar.mp4

Same as above example, with DTS compression enabled and timecodes optimization:

mp4fpsmod -t timecode.txt -x -c foo.mp4 -o bar.mp4

Read timecodes of foo.mp4 and save to timecode.txt:

mp4fpsmod -p timecode.txt foo.mp4

Execute DTS compression, and save to bar.mp4:

mp4fpsmod -c foo.mp4 -o bar.mp4

Delay audio by 100ms using edts/elst:

mp4fpsmod -d 100 foo.mp4 -o bar.mp4

Delay audio by -200ms using DTS/CTS shifting:

mp4fpsmod -d -200 -c foo.mp4 -o bar.mp4

Usage

::
-o <file> Specify MP4 output filename.
-p, --print <file>
 Output current timecodes into timecode-v2 format.
-t, --tcfile <file>
 Edit timecodes with timecode-v2 file.
-x, --optimize Optimize timecode
-r, --fps <nframes:fps>
 Edit timecodes with the spec. You can specify -r more than two times, to produce VFR movie. "nframes" is number of frames, which "fps" is aplied to. 0 as nframes means "rest of the movie" "fps" is a rational or integer. For example, 25 or 30000/1001.
-c, --compress-dts
 Enable DTS compression.
-d, --delay <n>
 Delay audio by n millisecond.

In any cases, the original mp4 is kept as it is (not touched). -o is required except when you specify -p. On the other hand, when you specify -p, other options are ignored.

-t and -r are exclusive, and cannot be set both at the same time. -c, -d, -x can be set standalone, or with -t or -r.

When you specify one of -t, -r, -x, -c, -d, timecode is edited/rewritten. Otherwise without -p, input is just copied with moov->mdat order, without timecode editing.

You should always set -c when you set -t, -r, -d, -x, if you want your output widely playable with video/audio in sync, especially with hardware players. Read about DTS compression for details.

Beware that mp4fpsmod ignores edts/elst of input, and when timecode is edited, edts/elst of video/audio tracks are deleted, and re-inserted as needed. Therefore, if the input has already some audio delays, you have to always specify it with -d.

About timecode optimization

Consider timecode file like this:

# timecode format v2
0
33
67
100
133
167
200
  :

This is the example of timecodes for 30000/1001 fps movie. In this case, each timeDelta of entries are 33, 34, 33, 33, 34, 33...

When -x option is given, and when timecodes are integer values, mp4fpsmod tries to divide timecodes into groups, whose entries have time delta very close to each other. Then, average each group's time delta into one floating point value.

mp4fpsmod also tries to do further optimization when -x option specified. If every timeDelta of frames looks like close enough to one of the well known NTSC or PAL rate, mp4fpsmod takes the latter, and do the exact math, instead of floating point calcuration.

You can control these behaviors by -x option. Without -x, literal values in the timecodes_v2 file will be used.

About DTS Compression

By default, mp4fpsmod produces rather straightforward DTS. For example, when you specify -r 300:30000/1001 -r400 24000/1001,

  • TimeScale is set to 120000, which is LCM of 30000 and 24000
  • DTS is like 0, 4004, 8008,... for first 300 frames. For next 400 frames, DTS delta is 5005.
  • CTS is like DTS, except that it is arranged in the composition order, instead of decoding/frame order.

In the mp4 container, stts box(which holds DTS delta) will look like this:

<TimeToSampleEntry SampleDelta="4004" SampleCount="300"/>
<TimeToSampleEntry SampleDelta="5005" SampleCount="400"/>

Timecodes of this movie will be something like this, if B-frame is used:

------------ --------
DTS          CTS
------------ --------
0            0(I)
4004         12012(P)
8008         4004(B)
12012        8008(B)
16016        24024(P)
20020        16016(B)
------------ --------

However, this doesn't satisfy DTS <= CTS, for some frames. Therefore, we have to shift(delay) CTS. Finally, we get:

------------ -----
DTS          CTS
------------ -----
0            4004
4004         16016
8008         8008
12012        12012
16016        28028
20020        20020
------------ -----

As you can see, CTS of first frame is non-zero value, therefore has delay of 4004, in timescale unit. This delay value is, by default, saved into edts/elst box. If your player handles edts/elst properly, this is fine. However, there's many players in the wild, which lacks edts support. If you are using them, you might find video/audio out of sync.

DTS compression comes for this reason. If you enable DTS compression with "-c" option, mp4fpsmod produces smaller DTS at beginning, and minimizes the CTS delay without the help of edts/elst box. With DTS compression, DTS and CTS will be something like this:

----------- -----
DTS          CTS
----------- -----
0           0
2002        12012
4004        4004
8008        8008
12012       24024
16016       16016
----------- -----

About audio delay

You can specify audio delay with -d option. Delay is in milliseconds, and both positive and negative values are valid.

When you don't enable DTS compression with -c, delay is just achieved with edts/elst setting. If positive, video track's edts is set. Otherwise, each audio track's edts is set.

When you enable DTS compression, DTS/CTS are directly shifted to reflect the delay. When delay is positive, smaller DTS/CTS are assigned for the beginning of movie, so that video plays faster and audio is delayed, until it reaches the specified delay time. Negative delay is achieved mostly like the positive case, except that bigger DTS/CTS are used, and video plays slower.

mp4fpsmod's People

Contributors

by321 avatar darealshinji avatar nu774 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

mp4fpsmod's Issues

Setting timescale

Hello. Could the ability to set the timescale when changing the frame rate or using a timecode be added to mp4fpsmod? Could it also read the timescale from the mdhd atom as it extracts the timecode?

Thank you.

Minimum timescale required when using DTS compression

When using DTS compression together with a small enough timescale, timecodes will overflow:

# create empty video with 0.5s duration
ffmpeg -t 0.5 -s 640x480 -f rawvideo -pix_fmt rgb24 -r 24 -i /dev/zero video.mp4

# this will produce a damaged video file that cant even be played with vlc
mp4fpsmod video.mp4 -T 30 -r 0:24 -c -o video_out.mp4

The timecodes of the video_out.mp4 will look like this:

# timecode format v2
0
33.3333333333333
100
133.333333333333
166.666666666667
143165576733.333
143165576800
143165576833.333
143165576866.667
143165576900
143165576966.667
143165577000

I created a table that shows the minimum timescale needed for a given number of fps. E.g. in the above example with 24 fps setting the timescale to 34 would work.

fps=1, ts=2
fps=2, ts=3
fps=3, ts=5
fps=4, ts=6
fps=5, ts=8
fps=6, ts=9
fps=7, ts=10
fps=8, ts=12
fps=9, ts=13
fps=10, ts=15
fps=11, ts=16
fps=12, ts=17
fps=13, ts=19
fps=14, ts=20
fps=15, ts=22
fps=16, ts=23
fps=17, ts=25
fps=18, ts=26
fps=19, ts=27
fps=20, ts=29
fps=21, ts=30
fps=22, ts=32
fps=23, ts=33
fps=24, ts=34
fps=25, ts=36
fps=26, ts=37
fps=27, ts=39
fps=28, ts=40
fps=29, ts=42
fps=30, ts=43
fps=31, ts=44
fps=32, ts=46
fps=33, ts=47
fps=34, ts=49
fps=35, ts=50
fps=36, ts=51
fps=37, ts=53
fps=38, ts=54
fps=39, ts=56
fps=40, ts=57
fps=41, ts=59
fps=42, ts=60
fps=43, ts=61
fps=44, ts=63
fps=45, ts=64
fps=46, ts=66
fps=47, ts=67
fps=48, ts=68
fps=49, ts=70
fps=50, ts=71
fps=51, ts=73
fps=52, ts=74
fps=53, ts=76
fps=54, ts=77
fps=55, ts=78
fps=56, ts=80
fps=57, ts=81
fps=58, ts=83
fps=59, ts=84

Cannot edit timestamp of first frame from timecode-v2 file

I'm using mp4fpsmod because I cannot find the ability to change mdhd/Timescale in timelineeditor of the L-SMASH Project, but when I edit MP4 timestamp using mp4fpsmod's -t option, the timestamp of the first frame is not reflected in the output, although L-SMASH's timelineeditor can edit the timestamp of the first frame.

mp4v2 bug in 0.25

mp4v2 files have corrupt playback in various media players (vlc, mpchc, potplayer etc...) with mp4fpsmod 0.25, but work ok with 0.24 . mp4v1 seems ok too in either

Background context is "fixing" VFR jitter from samples cut from avidemux . Original was CFR

Frame rate mode : Variable
Frame rate : 23.976 (23976/1000) FPS
Minimum frame rate : 23.000 FPS
Maximum frame rate : 23.981 FPS

Sample cut ~8.5Mb from YT trailer, in avidemux as mp4v2 output to reproduce issue
https://www.mediafire.com/file/e33mqr6rzse49oe/cut_mp4v2.mp4/file

command lines used
"D:\Utilities\mp4fpsmod_0.25\mp4fpsmod" --fps 0:24000/1001 cut_mp4v2.mp4 -o mp4fpsmod0.25.mp4
"D:\Utilities\mp4fpsmod_0.24\mp4fpsmod" --fps 0:24000/1001 cut_mp4v2.mp4 -o mp4fpsmod0.24.mp4

MP4Integer32Array::Delete: illegal array index: 1 of 1: errno: 34

I'm trying to remux a mkv file. (http://www.embedupload.com/?d=6YAUEWGZDS)

so I to the following things:

  1. extract the timecodes:
    mkvextract timecodes_v2 "D:\toRemux.mkv" 1:"H:\Temp\timeCode.txt"
  2. extract the audio:
    mkvextract tracks "D:\toRemux.mkv" 0:"H:\Temp\aid_0_lang_ger_DELAY_-27ms.mp3"
  3. extract the video:
    mkvextract tracks "D:\toRemux.mkv" 1:"H:\Temp\video.264"
  4. multiplex the video:
    MP4Box -par 1=64:45 -add "H:\Temp\video.264"#video:fps=23.438:delay=27 -brand avc1 -tmp "H:\Temp" -new "H:\Output\videoOnly.mp4"
  5. add the time stamps
    mp4fpsmod -t "H:\Temp\timeCode.txt" -x "H:\Output\videoOnly.mp4" -o "H:\Output\video_withTimeCodes.mp4"
    and end up with:

Reading MP4 stream...
Done reading
Divided into 2 groups
2 frames: time delta 80
1926 frames: time delta 40
libmp4v2: mp4v2::impl::MP4Integer32Array::Delete: illegal array index: 1 of 1: errno: 34 (c:\home\noboru\src\mp4fpsmod\mp4v2\src\mp4array.h,128)

error occured with: mp4fpsmod 0.22

Cu Selur

Ubuntu 10.04 compiling mp4fsmod v0.14

Hi i'm trying to compile the mp4fsmod on my ubuntu 10.04 lucid lynx
i was using instruction in the BUILD_Linux.txt
so thse are my stheps

  1. emaz@emaz-desktop ~/nu774-mp4fpsmod-92297e1/mp4v2 $ ./make_configure
    libtoolize: Consider adding AC_CONFIG_MACRO_DIR([m4])' to configure.ac and libtoolize: rerunning libtoolize, to keep the correct libtool macros in-tree. libtoolize: Consider adding-I m4' to ACLOCAL_AMFLAGS in Makefile.am.

  2. emaz@emaz-desktop ~/nu774-mp4fpsmod-92297e1/mp4v2 $ ./configure --enable-shared=no --disable-util
    configure:
    -->
    --> Configuring MP4v2 trunk-r465
    -->
    checking for a BSD-compatible install... /usr/bin/install -c
    checking whether build environment is sane... yes
    checking for a thread-safe mkdir -p... /bin/mkdir -p
    checking for gawk... gawk
    checking whether make sets $(MAKE)... yes
    checking build system type... i686-pc-linux-gnu
    checking host system type... i686-pc-linux-gnu
    checking for g++... g++
    checking whether the C++ compiler works... yes
    checking for C++ compiler default output file name... a.out
    checking for suffix of executables...
    checking whether we are cross compiling... no
    checking for suffix of object files... o
    checking whether we are using the GNU C++ compiler... yes
    checking whether g++ accepts -g... yes
    checking for style of include used by make... GNU
    checking dependency style of g++... none
    checking for gcc... gcc
    checking whether we are using the GNU C compiler... yes
    checking whether gcc accepts -g... yes
    checking for gcc option to accept ISO C89... none needed
    checking dependency style of gcc... none
    checking for a sed that does not truncate output... /bin/sed
    checking for grep that handles long lines and -e... /bin/grep
    checking for egrep... /bin/grep -E
    checking for fgrep... /bin/grep -F
    checking for ld used by gcc... /usr/bin/ld
    checking if the linker (/usr/bin/ld) is GNU ld... yes
    checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
    checking the name lister (/usr/bin/nm -B) interface... BSD nm
    checking whether ln -s works... yes
    checking the maximum length of command line arguments... 1572864
    checking whether the shell understands some XSI constructs... yes
    checking whether the shell understands "+="... yes
    checking for /usr/bin/ld option to reload object files... -r
    checking for objdump... objdump
    checking how to recognize dependent libraries... pass_all
    checking for ar... ar
    checking for strip... strip
    checking for ranlib... ranlib
    checking command to parse /usr/bin/nm -B output from gcc object... ok
    checking how to run the C preprocessor... gcc -E
    checking for ANSI C header files... yes
    checking for sys/types.h... yes
    checking for sys/stat.h... yes
    checking for stdlib.h... yes
    checking for string.h... yes
    checking for memory.h... yes
    checking for strings.h... yes
    checking for inttypes.h... yes
    checking for stdint.h... yes
    checking for unistd.h... yes
    checking for dlfcn.h... yes
    checking whether we are using the GNU C++ compiler... (cached) yes
    checking whether g++ accepts -g... (cached) yes
    checking dependency style of g++... (cached) none
    checking how to run the C++ preprocessor... g++ -E
    checking for objdir... .libs
    checking if gcc supports -fno-rtti -fno-exceptions... no
    checking for gcc option to produce PIC... -fPIC -DPIC
    checking if gcc PIC flag -fPIC -DPIC works... yes
    checking if gcc static flag -static works... yes
    checking if gcc supports -c -o file.o... yes
    checking if gcc supports -c -o file.o... (cached) yes
    checking whether the gcc linker (/usr/bin/ld) supports shared libraries... yes
    checking dynamic linker characteristics... GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking whether stripping libraries is possible... yes
    checking if libtool supports shared libraries... yes
    checking whether to build shared libraries... no
    checking whether to build static libraries... yes
    checking for ld used by g++... /usr/bin/ld
    checking if the linker (/usr/bin/ld) is GNU ld... yes
    checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
    checking for g++ option to produce PIC... -fPIC -DPIC
    checking if g++ PIC flag -fPIC -DPIC works... yes
    checking if g++ static flag -static works... yes
    checking if g++ supports -c -o file.o... yes
    checking if g++ supports -c -o file.o... (cached) yes
    checking whether the g++ linker (/usr/bin/ld) supports shared libraries... yes
    checking dynamic linker characteristics... GNU/Linux ld.so
    checking how to hardcode library paths into programs... immediate
    checking for help2man... yes
    checking MP4v2 platform portability... posix
    checking if g++ supports -fvisibility... yes
    checking if GCC precompiled-headers should be created... yes
    checking if LFS (large file support) is required... yes
    checking arch flags... none
    configure: creating ./config.status
    config.status: creating GNUmakefile
    config.status: creating include/mp4v2/project.h
    config.status: creating project/project.m4
    config.status: creating libplatform/config.h
    config.status: libplatform/config.h is unchanged
    config.status: executing depfiles commands
    config.status: executing libtool commands

  3. emaz@emaz-desktop ~/nu774-mp4fpsmod-92297e1/mp4v2 $ make
    /bin/bash ./libtool --tag=CXX --mode=compile g++ -DHAVE_CONFIG_H -I./include -I./include -I. -I. -Wall -Wformat -g -O2 -fvisibility=hidden -c -o src/3gp.lo src/3gp.cpp
    libtool: compile: g++ -DHAVE_CONFIG_H -I./include -I./include -I. -I. -Wall -Wformat -g -O2 -fvisibility=hidden -c src/3gp.cpp -o src/3gp.o
    In file included from /usr/include/bits/errno.h:25,
    from /usr/include/errno.h:36,
    from /usr/include/c++/4.4/cerrno:43,
    from ./libplatform/platform_base.h:20,
    from ./libplatform/platform_posix.h:31,
    from ./libplatform/platform.h:24,
    from ./src/src.h:6,
    from ./src/impl.h:6,
    from src/3gp.cpp:28:
    /usr/include/linux/errno.h:4:23: error: asm/errno.h: Nessun file o directory
    In file included from ./src/src.h:29,
    from ./src/impl.h:6,
    from src/3gp.cpp:28:
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Integer8Array::Insert(uint8_t, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:125: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Integer8Array::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:125: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘uint8_t& mp4v2::impl::MP4Integer8Array::operator’:
    ./src/mp4array.h:125: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Integer16Array::Insert(uint16_t, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:127: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Integer16Array::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:127: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘uint16_t& mp4v2::impl::MP4Integer16Array::operator’:
    ./src/mp4array.h:127: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Integer32Array::Insert(uint32_t, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:129: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Integer32Array::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:129: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘uint32_t& mp4v2::impl::MP4Integer32Array::operator’:
    ./src/mp4array.h:129: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Integer64Array::Insert(uint64_t, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:131: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Integer64Array::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:131: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘uint64_t& mp4v2::impl::MP4Integer64Array::operator’:
    ./src/mp4array.h:131: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Float32Array::Insert(float, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:133: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Float32Array::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:133: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘float& mp4v2::impl::MP4Float32Array::operator’:
    ./src/mp4array.h:133: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Float64Array::Insert(double, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:135: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4Float64Array::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:135: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘double& mp4v2::impl::MP4Float64Array::operator’:
    ./src/mp4array.h:135: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4StringArray::Insert(char_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:137: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4StringArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:137: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘char_& mp4v2::impl::MP4StringArray::operator’:
    ./src/mp4array.h:137: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4BytesArray::Insert(uint8_t_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:139: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘void mp4v2::impl::MP4BytesArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4array.h:139: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4array.h: In member function ‘uint8_t_& mp4v2::impl::MP4BytesArray::operator’:
    ./src/mp4array.h:139: error: ‘ERANGE’ was not declared in this scope
    In file included from ./src/src.h:30,
    from ./src/impl.h:6,
    from src/3gp.cpp:28:
    ./src/mp4track.h: In member function ‘void mp4v2::impl::MP4TrackArray::Insert(mp4v2::impl::MP4Track_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4track.h:288: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4track.h: In member function ‘void mp4v2::impl::MP4TrackArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4track.h:288: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4track.h: In member function ‘mp4v2::impl::MP4Track_& mp4v2::impl::MP4TrackArray::operator’:
    ./src/mp4track.h:288: error: ‘ERANGE’ was not declared in this scope
    In file included from ./src/src.h:32,
    from ./src/impl.h:6,
    from src/3gp.cpp:28:
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4DescriptorArray::Insert(mp4v2::impl::MP4Descriptor_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4property.h:33: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4DescriptorArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4property.h:33: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4property.h: In member function ‘mp4v2::impl::MP4Descriptor_& mp4v2::impl::MP4DescriptorArray::operator’:
    ./src/mp4property.h:33: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4PropertyArray::Insert(mp4v2::impl::MP4Property_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4property.h:107: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4PropertyArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4property.h:107: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4property.h: In member function ‘mp4v2::impl::MP4Property_& mp4v2::impl::MP4PropertyArray::operator’:
    ./src/mp4property.h:107: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4Integer8Property::SetValue(uint8_t, uint32_t)’:
    ./src/mp4property.h:202: error: ‘EACCES’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4Integer16Property::SetValue(uint16_t, uint32_t)’:
    ./src/mp4property.h:203: error: ‘EACCES’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4Integer24Property::SetValue(uint32_t, uint32_t)’:
    ./src/mp4property.h:204: error: ‘EACCES’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4Integer32Property::SetValue(uint32_t, uint32_t)’:
    ./src/mp4property.h:205: error: ‘EACCES’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4Integer64Property::SetValue(uint64_t, uint32_t)’:
    ./src/mp4property.h:206: error: ‘EACCES’ was not declared in this scope
    ./src/mp4property.h: In member function ‘void mp4v2::impl::MP4Float32Property::SetValue(float, uint32_t)’:
    ./src/mp4property.h:267: error: ‘EACCES’ was not declared in this scope
    In file included from ./src/src.h:35,
    from ./src/impl.h:6,
    from src/3gp.cpp:28:
    ./src/mp4atom.h: In member function ‘void mp4v2::impl::MP4AtomArray::Insert(mp4v2::impl::MP4Atom_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4atom.h:37: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4atom.h: In member function ‘void mp4v2::impl::MP4AtomArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4atom.h:37: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4atom.h: In member function ‘mp4v2::impl::MP4Atom_& mp4v2::impl::MP4AtomArray::operator’:
    ./src/mp4atom.h:37: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4atom.h: In member function ‘void mp4v2::impl::MP4AtomInfoArray::Insert(mp4v2::impl::MP4AtomInfo_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4atom.h:59: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4atom.h: In member function ‘void mp4v2::impl::MP4AtomInfoArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/mp4atom.h:59: error: ‘ERANGE’ was not declared in this scope
    ./src/mp4atom.h: In member function ‘mp4v2::impl::MP4AtomInfo_& mp4v2::impl::MP4AtomInfoArray::operator’:
    ./src/mp4atom.h:59: error: ‘ERANGE’ was not declared in this scope
    In file included from ./src/src.h:48,
    from ./src/impl.h:6,
    from src/3gp.cpp:28:
    ./src/rtphint.h: In member function ‘void mp4v2::impl::MP4RtpDataArray::Insert(mp4v2::impl::MP4RtpData_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/rtphint.h:56: error: ‘ERANGE’ was not declared in this scope
    ./src/rtphint.h: In member function ‘void mp4v2::impl::MP4RtpDataArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/rtphint.h:56: error: ‘ERANGE’ was not declared in this scope
    ./src/rtphint.h: In member function ‘mp4v2::impl::MP4RtpData_& mp4v2::impl::MP4RtpDataArray::operator’:
    ./src/rtphint.h:56: error: ‘ERANGE’ was not declared in this scope
    ./src/rtphint.h: In member function ‘void mp4v2::impl::MP4RtpPacketArray::Insert(mp4v2::impl::MP4RtpPacket_, mp4v2::impl::MP4ArrayIndex)’:
    ./src/rtphint.h:184: error: ‘ERANGE’ was not declared in this scope
    ./src/rtphint.h: In member function ‘void mp4v2::impl::MP4RtpPacketArray::Delete(mp4v2::impl::MP4ArrayIndex)’:
    ./src/rtphint.h:184: error: ‘ERANGE’ was not declared in this scope
    ./src/rtphint.h: In member function ‘mp4v2::impl::MP4RtpPacket_& mp4v2::impl::MP4RtpPacketArray::operator’:
    ./src/rtphint.h:184: error: ‘ERANGE’ was not declared in this scope
    make: *** [src/3gp.lo] Errore 1

i'm getting trouble after the configure command
i hope to get a solution
and made it usuable for someone other in my same situation

Compiling fails on macOS Sonoma 14.2.1 on a MacBook Pro M3 Max

Compiling fails on macOS Sonoma 14.2.1 on a MacBook Pro M3 Max. Specifically, in the mp4v2 subdirectory, it eventually tries to execute the following command:

/bin/sh ./libtool --tag=CXX --mode=link g++ -std=gnu++11 -Wall -Wformat -g -O2 -fvisibility=hidden -o libutil.la

which then prints

libtool: link: ar cr .libs/libutil.a 
ar: no archive members specified
usage:  ar -d [-TLsv] archive file ...
	ar -m [-TLsv] archive file ...
	ar -m [-abiTLsv] position archive file ...
	ar -p [-TLsv] archive [file ...]
	ar -q [-cTLsv] archive file ...
	ar -r [-cuTLsv] archive file ...
	ar -r [-abciuTLsv] position archive file ...
	ar -t [-TLsv] archive [file ...]
	ar -x [-ouTLsv] archive [file ...]

Feature Request: AAC track timecode extraction

It would be useful if mp4fpsmod could also extract the timecodes of an aac track. Currently I am remuxing video files to mkv and then use mkvextract just to delete the mkv file again.
mp4fpsmod looked promising, but it seems it extracts the h264 timecodes only, right?

Installation

I'm new to CLI programs and I have absolutely no idea how to get this installed. So can someone give an installation guide.

Compilation problem

Hi,

I'm maintaining the arch package…

While trying to build, I get this error:

marc@marco:~/mp4fpsmod$ make
make  all-recursive
make[1]: Entering directory '/home/marc/Downloads/developpement/aur/mp4fpsmod/src/mp4fpsmod'
Making all in mp4v2
make[2]: Entering directory '/home/marc/Downloads/developpement/aur/mp4fpsmod/src/mp4fpsmod/mp4v2'
/bin/sh ./libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H   -I./include -I./include -I. -I.  -Wall -Wformat -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fvisibility=hidden -c -o src/rtphint.lo src/rtphint.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I./include -I./include -I. -I. -Wall -Wformat -march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong -fno-plt -fvisibility=hidden -c src/rtphint.cpp -o src/rtphint.o
In file included from ./src/src.h:28:0,
                 from ./src/impl.h:6,
                 from src/rtphint.cpp:22:
./src/mp4util.h:36:33: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
             throw new Exception("assert failure: "LIBMPV42_STRINGIFY((expr)), __FILE__, __LINE__, __FUNCTION__ ); \
                                 ^
src/rtphint.cpp: In member function 'void mp4v2::impl::MP4RtpHintTrack::GetPayload(char**, uint8_t*, uint16_t*, char**)':
src/rtphint.cpp:342:35: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
                     if (pSlash != '\0') {
                                   ^~~~
make[2]: *** [GNUmakefile:1085: src/rtphint.lo] Error 1
make[2]: Leaving directory '/home/marc/Downloads/developpement/aur/mp4fpsmod/src/mp4fpsmod/mp4v2'
make[1]: *** [Makefile:566: all-recursive] Error 1
make[1]: Leaving directory '/home/marc/Downloads/developpement/aur/mp4fpsmod/src/mp4fpsmod'
make: *** [Makefile:367: all] Error 2

Changing pSlash != '\0' to *pSlash != '\0' makes it compile (it seemed logical to me, but I only gave it a very quick look).

Regards

Float timecodes get converted to integer timecodes

When I use the tool to transfer floating-point timecodes to an mp4 the resulting timecodes get converted to integers.

Input:

# timecode format v2
0
156.688888888889
190.011111111111
223.333333333333
256.655555555556
289.977777777778
323.3

Output:

# timecode format v2
0
157
190
224
257
290
324

This should be the code piece that does the cast:

DTS(i) = CTS(i) = static_cast<uint64_t>(timeCodes[i] + 0.5);

Is it possible to add support for floating-point timecodes, or is there a reason DTS and CTS are integers?

-p -x causes mp4fpsmod abort during timecode extraction

tested different mp4 files as soon as I use -p -x, e.g. : "\mp4fpsmod.exe" -p -x "d:\vlc-record-2012-12-19-17h59m25s-fd___0-_timecodes_v2_optimize.txt" "c:\Users\Selur\Desktop\Sample.mp4"

it mp4fpsmod aborts with:

Reading MP4 stream...
libmp4v2: mp4v2::impl::MP4File::Open: open(.....) failed (....\mp4v2\src\mp4file.cpp,398)

Write to a file which is already opened by another program on Windows.

Thanks for this great tool!

I do the following in Colab:

!git clone -qqq https://github.com/nu774/mp4fpsmod.git > /dev/null
!sudo apt-get update -y -qqq --fix-missing && apt-get install -y -qqq autoconf libtool > /dev/null
%cd mp4fpsmod
!./bootstrap.sh
!./configure

All the above commands were done successfully but when I run make I get into a loop:

!make

make  all-recursive
make[1]: Entering directory '/content/mp4fpsmod'
Making all in mp4v2
make[2]: Entering directory '/content/mp4fpsmod/mp4v2'
/bin/bash ./libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H   -I./include -I./include -I. -I.  -Wall -Wformat -g -O2 -fvisibility=hidden -c -o src/3gp.lo src/3gp.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I./include -I./include -I. -I. -Wall -Wformat -g -O2 -fvisibility=hidden -c src/3gp.cpp -o src/3gp.o
In file included from ./src/src.h:28:0,
                 from ./src/impl.h:6,
                 from src/3gp.cpp:28:
./src/mp4util.h:36:33: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
             throw new Exception("assert failure: "LIBMPV42_STRINGIFY((expr)), __FILE__, __LINE__, __FUNCTION__ ); \
                                 ^
/bin/bash ./libtool  --tag=CXX   --mode=compile g++ -DHAVE_CONFIG_H   -I./include -I./include -I. -I.  -Wall -Wformat -g -O2 -fvisibility=hidden -c -o src/atom_ac3.lo src/atom_ac3.cpp
libtool: compile:  g++ -DHAVE_CONFIG_H -I./include -I./include -I. -I. -Wall -Wformat -g -O2 -fvisibility=hidden -c src/atom_ac3.cpp -o src/atom_ac3.o
In file included from ./src/src.h:28:0,
                 from ./src/impl.h:6,
                 from src/atom_ac3.cpp:24:
./src/mp4util.h:36:33: warning: invalid suffix on literal; C++11 requires a space between literal and string macro [-Wliteral-suffix]
             throw new Exception("assert failure: "LIBMPV42_STRINGIFY((expr)), __FILE__, __LINE__, __FUNCTION__ ); \

How can I fix it?

And a small question. When I try to run it on Windows:

mp4fpsmod --fps 0:60 video.mp4 --inplace

and the video file is open in mpc-hc I see the error:

Reading MP4 stream...
libmp4v2: mp4v2::impl::MP4File::Open: open(C:\video.mp4) failed (..\..\mp4v2\src\mp4file.cpp,371)

How can I make mp4fpsmod work even when the video file is already open?

Make stops with error on ubuntu 11.04,...

Trying to build mp4fpsmod by following the steps in BUILD_Linux.txt I end up with:

g++ -O2 -Wall -DMP4V2_USE_STATIC_LIB -I mp4v2 -I mp4v2/include -I mp4v2/src -c -o main.o main.cpp
main.cpp: In function ‘void rescaleTimecode(Option&)’:
main.cpp:172:9: warning: unused variable ‘timeScale’
main.cpp: In function ‘void execute(Option&)’:
main.cpp:276:24: warning: unused variable ‘trackAtom’
main.cpp: At global scope:
main.cpp:347:16: error: ‘required_argument’ was not declared in this scope
main.cpp:348:14: error: ‘required_argument’ was not declared in this scope
main.cpp:349:17: error: ‘required_argument’ was not declared in this scope
main.cpp:350:16: error: ‘required_argument’ was not declared in this scope
main.cpp:351:19: error: ‘no_argument’ was not declared in this scope
main.cpp:352:23: error: ‘no_argument’ was not declared in this scope
main.cpp:354:1: error: elements of array ‘option long_options []’ have incomplete type
main.cpp:354:1: error: storage size of ‘long_options’ isn't known
main.cpp: In function ‘int main1(int, char*)’:
main.cpp:365:19: error: ‘getopt_long’ was not declared in this scope
make: *
* [main.o] Error 1

for more details what I did see: http://pastebin.com/cW6fJxpx

hope this can be fixed,...

timecode

is it possible to add timecode trak to mp4 with mp4fpsmod?

is there some sort of upper limit for the number of timestamps that can be added to a file?

I got a file that Mp4Box identifies as:

MP4Box.exe -info h:\Output\22_04_41_9210__04_mp4Temp.mp4

  • Movie Info *
    Timescale 600 - Duration 03:01:43.968
    1 track(s)
    Fragmented File: no
    File suitable for progressive download (moov before mdat)
    File Brand avc1 - version 0
    Created: GMT Fri Dec 21 21:04:54 2012

File has root IOD (9 bytes)
Scene PL 0xff - Graphics PL 0xff - OD PL 0xff
Visual PL: AVC/H264 Profile (0x15)
Audio PL: No audio capability required (0xff)
No streams included in root OD

Track # 1 Info - TrackID 1 - TimeScale 23149 - Media Duration 03:01:43.969
Media Info: Language "Undetermined" - Type "vide:avc1" - 252416 samples
Visual Track layout: x=0 y=0 width=768 height=576
MPEG-4 Config: Visual Stream - ObjectTypeIndication 0x21
AVC/H264 Video - Visual Size 720 x 576
AVC Info: 1 SPS - 1 PPS - Profile High @ Level 3
NAL Unit length bits: 32
Pixel Aspect Ratio 16:15 - Indicated track size 768 x 576
Chroma format 1 - Luma bit depth 8 - chroma bot depth 8
Self-synchronized

since the file has 252416 samples I tried adding a timecode_v2 file with 252417 lines (first line = # timecode format v2), so it has one timecode per sample, but when I call:

mp4fpsmod -t "H:\Temp\timecodeV2_22_04_41_9210.tc" -x "H:\Output\22_04
_41_9210__04_mp4Temp.mp4" -o "H:\Output\22_04_41_9210__06_withTimeCodes_0.mp4"

mp4fpsmod crashes after a while,...
uploaded the .tc file and the output to: http://www.embedupload.com/?d=9RNKGWL1LG

illegal array index,...

while trying to remux a file from mkv to mp4 I get, when I try to add the time codes to the mp4 file.

libmp4v2: mp4v2::impl::MP4Integer32Array::Delete: illegal array index: 1 of 1: errno: 34 (c:\home\noboru\src\mp4fpsmod\mp4v2\src\mp4array.h,128)

when I try to add this (http://www.embedupload.com/?d=5EBCIPCVEK) time code file.
Strange thing is, if the mp4 file does not contain any audio stream adding the time codes fine,... (doesn't matter if it's the original audio stream or a reencoded version of it)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.