[FFmpeg-user] FFMPEG Use Questions

Larry Camilli larry.camilli at gmail.com
Wed Jan 3 01:49:14 EET 2018


I saw a post on a Facebook FFMPEG page saying that use questions are
welcome.
Here goes:
 
I'm trying to use FFMPEG to manipulate videos that are the output of a
(cheapo)
film-to-video device.  [Wolverine brand.]
 
I installed what seemed like a stable, recent version of FFPMEG on a Windows
8 laptop.
 
>ffmpeg -version
ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
built with gcc 7.2.0 (GCC)
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-bzlib
--ena
ble-fontconfig --enable-gnutls --enable-iconv --enable-libass
--enable-libbluray
 --enable-libfreetype --enable-libmp3lame --enable-libopenjpeg
--enable-libopus
--enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora
--enabl
e-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp
--enable-libx2
64 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma
--enable-zli
b --enable-gmp --enable-libvidstab --enable-libvorbis --enable-cuda
--enable-cuv
id --enable-d3d11va --enable-nvenc --enable-dxva2 --enable-avisynth
--enable-lib
mfx
libavutil      55. 78.100 / 55. 78.100
libavcodec     57.107.100 / 57.107.100
libavformat    57. 83.100 / 57. 83.100
libavdevice    57. 10.100 / 57. 10.100
libavfilter     6.107.100 /  6.107.100
libswscale      4.  8.100 /  4.  8.100
libswresample   2.  9.100 /  2.  9.100
libpostproc    54.  7.100 / 54.  7.100
 
 
 
The main problems (of the film-to-video transfers) that I'm trying to solve
with FFMPEG are:
 
1. The converter produces mp4 videos with a frame rate of 30fps, but it just
copies each film
frame (16fps for 8mm; 18fps for Super8) to a video frame, so the videos run
fast.
 
2. There is no editing capability to get, say, clean starts and stops.
 
3. The Instamatic films that I'm trying to convert are short, and whoever
shot
the movies left lots of shorts (say, of the same event) that should be
concatenated.
 
I found some examples of using FFMPEG to convert speed and tried it on
several segments
with good results.
("ffmpeg -i <input-filename>.mp4 -filter:v "setpts=1.667*PTS"
<output-filename>.mp4")
(1.667 for Super 8; 1.875 for 8mm)
 
But, I figured it's more efficient to trim and concatenate the segments
first and then change the speed.
(Changing the speed from 30fps to, say, 18fps results in lots of duplicate
frames, so there would be lots
of needless processing if I changed the speed first and then trimmed and
concatenated.)
 
 
I started out trimming segments with
"ffmpeg -ss 00:00:01.5 -i <input-filename>.mp4 -vcodec copy
<output-filename>.mp4"
but, when I tried to assemble the segments, I got a lot of the famous
"[mp4 @ 000000409675c940] Non-monotonous DTS in output stream 0:0; previous:
1803
4524, current: 11030533; changing to 18034525. This may result in incorrect
time
stamps in the output file." messages.
 
So, (...I googled and...) I switched to:
"ffmpeg -ss 00:00:01.5 -i <input-filename>.mp4 -filter:v
"setpts=PTS-STARTPTS" <output-filename>.mp4"
 
I trim the beginning and end (if necessary) one at a time:  First, using
FFMPEG to trim the beginning,
and, then, in a separate FFMPEG run, to trim the end.  [I use VLC to view
the video and get an idea of where
to trim the beginning, and then do a binary search of sorts for an edit
point that looks OK.  Then, I do the end.
Each time, I throw away the previous attempt.  So, each trimmed video was
trimmed at most once at the beginning
and once at the end).
 
I currently have 9 segments that I'd like to concatenate together into one
video.
 
If I trim some of them, I get many "Non-monotonous DTS" (monotonic?)
messages.
[In once instance more than the DOS-window limit of 9999 lines retained.]
 
More preplexing is that, when I include trimmed segments in a concatenation,
the
resultant video (according to VLC) has a frame rate of 15.359592, even
though each
of the segments is 30fps (according to VLC).
 
If I concatenate the original (untrimmed) segments with FFMPEG, the
resultant
video is 30fps, and there are no "Non-monotonous" DTS messages in the log.
 
What I'd like to do next is learn what the correct commands are for trimming
a video
segment (that won't result in screwed-up timestamps and the frame rate being
changed
by concatenation).
 
Then, I can try again.
 
Thanks,
-Larry Camilli
 
 
Here are details of what I described above:
 
#
#
#   Truncate video at beginning:
#
ffmpeg -ss 00:00:01.5 -i <input-filename>.mp4 -filter:v
"setpts=PTS-STARTPTS" <output-filename>.mp4
#






# ...or...






#
ffmpeg -ss 00:00:01.5 -i <input-filename>.mp4 -vcodec copy
<output-filename>.mp4
 
(Both seem to screw up the timestamps.  More later.)
 
#
#
#   Truncate video at end:
#
ffmpeg -t 00:01:59.5 -i <input-filename>.mp4 -vcodec copy
<output-filename>.mp4
 
 
#
#
#   Concatenate .mp4 videos (Needs separate file with list of source files):
#
ffmpeg -f concat -i Combine.txt -c copy <output-filename>.mp4
#
# Combine.txt:
file '<filename1>.mp4'
file '<filename2>.mp4'
file '<filename3>.mp4'
 
 
#
#
#   Convert speed from 30fps to 18fps (Super 8):
#
ffmpeg -i <input-filename>.mp4 -filter:v "setpts=1.667*PTS"
<output-filename>.mp4
#
#
#   Convert speed from 30fps to 16fps (8mm):
#
ffmpeg -i <input-filename>.mp4 -filter:v "setpts=1.875*PTS"
<output-filename>.mp4
 
 
What I've been trying to do is: 1. Trim each segment at the beginning (if
necessary).  2. Trim the results of that
at the end (if necessary).  3. Concatenate the segments into one video.  4.
Change the frame rate so that the
video runs at the original film speed (which seems to involve FFMPEG
duplicating frames so that the result is
a video that plays at 30fps, but uses frames from the original of 18fps or
so).
Here are the problems that I've run into.
 
1. Those Famous "Non-Monotonous DTS" Messages
 
When I concatenate the segments (with FFMPEG), I get those "Non-monotonous
DTS"
(monotonic?) messages.  I've gotten these with both methods of trimming a
segment
at the beginning.  [I haven't yet experimented to see which early FFMPEG
command(s) are causing the problem
that's detected by FFMPEG later.  I'd assume it's trimming at the
beginning.]  I started with the
"-ss <time-spec>" & "-vcodec copy" version of the FFMPEG trim command,
googled, and switched to the
"-ss <time-spec>" & '-filter:v "setpts=PTS-STARTPTS"' version.
 
[mp4 @ 000000409675c940] Non-monotonous DTS in output stream 0:0; previous:
1803
4524, current: 11030533; changing to 18034525. This may result in incorrect
time
stamps in the output file.
[mp4 @ 000000409675c940] Non-monotonous DTS in output stream 0:0; previous:
1803
4525, current: 11031045; changing to 18034526. This may result in incorrect
time
stamps in the output file.
[mp4 @ 000000409675c940] Non-monotonous DTS in output stream 0:0; previous:
1803
4526, current: 11031557; changing to 18034527. This may result in incorrect
time
stamps in the output file.
[mp4 @ 000000409675c940] Non-monotonous DTS in output stream 0:0; previous:
1803
4527, current: 11032069; changing to 18034528. This may result in incorrect
time
stamps in the output file.
[mp4 @ 000000409675c940] Non-monotonous DTS in output stream 0:0; previous:
1803
4528, current: 11032581; changing to 18034529. This may result in incorrect
time
stamps in the output file.
 
I couldn't find any identifier in the log (such as the file name of each
input file as it is processed) - to figure out which
input files were causing the DTS messages.  But, there were
"[mov,mp4,m4a,3gp,3g2,mj2 @ 0000009f4be46ee0] Auto-inserting
h264_mp4toannexb bitstream filter"
messages, which seem to correspond to source files.  So, I was able to count
the messages to figure out which input
files were the problem.  [Is it possible to set a log verbosity level
that'll get the input file names?]
 
 
2. Frame Rate Changed During Concatenation.
 
If I check the frame-rate of the (original) segments with VLC [Tools ->
Codec Information [Codec tab], it's 30fps.
If I check the frame-rate of the concatenated video (no intentional
frame-rate conversion), it's 15.359592.  Why?
 
 
 


More information about the ffmpeg-user mailing list