[FFmpeg-user] framerate conversion with sync audio
Carles Vila
cvilad at gmail.com
Wed Oct 12 00:25:58 EEST 2016
Hi, I'm trying to perform framerate conversion of a video, from 24fps to
25fps to be precise.
The source is mov, ProRes with multichannel audio at 48kHz.
It is mandatory for my application to preserve the integrity of all frames,
i.e. no frame-interpolation or duplication should occur.
In other words, just the playback speed should be increased from 24 to 25,
resulting in a video of slightly shorter duration.
I've been partially successful so far using the command
ffmpeg -r 25 -i <inputfile24fps.mov> -r 25 -c:v prores -profile:v 3 -c:a
pcm_s24le <output_25fps.mov>
This comand produces a good video, shorter than the original, but the
problem is with audio. As you can imagine, the audio drifts out of sync
because it has no knowledge of the video framerate conversion.
My solution now is to process the audio externally, in an audio editor. I
must apply a sample rate conversion, first forcing the sample rate metadata
to 50.000 Hz (48.000 *(25/24)) and then resampling at 48.000 Hz
This shortens the audio by the same amount as the video and can be merged
to it.
Is there any way to perform this audio processing within ffmpeg?
Thanks!
ffmpeg -r 25 -i input.mov -r 25 -c:v prores -profile:v 3 -c:a pcm_s24le
output_25fps.mov
ffmpeg version 2.7.2 Copyright (c) 2000-2015 the FFmpeg developers
built with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
configuration: --prefix=/usr/local/Cellar/ffmpeg/2.7.2_1 --enable-shared
--enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables
--enable-avresample --cc=clang --host-cflags= --host-ldflags=
--enable-opencl --enable-libx264 --enable-libmp3lame --enable-libvo-aacenc
--enable-libxvid --enable-libfreetype --enable-libvorbis --enable-libvpx
--enable-libass --enable-ffplay --enable-libfdk-aac --enable-libopus
--enable-libquvi --enable-libx265 --enable-libopenjpeg
--extra-cflags='-I/usr/local/Cellar/openjpeg/1.5.2_1/include/openjpeg-1.5 '
--enable-nonfree --enable-vda
libavutil 54. 27.100 / 54. 27.100
libavcodec 56. 41.100 / 56. 41.100
libavformat 56. 36.100 / 56. 36.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 16.101 / 5. 16.101
libavresample 2. 1. 0 / 2. 1. 0
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 2.100 / 1. 2.100
libpostproc 53. 3.100 / 53. 3.100
Guessed Channel Layout for Input Stream #0.1 : mono
Guessed Channel Layout for Input Stream #0.2 : mono
Guessed Channel Layout for Input Stream #0.3 : mono
Guessed Channel Layout for Input Stream #0.4 : mono
Guessed Channel Layout for Input Stream #0.5 : mono
Guessed Channel Layout for Input Stream #0.6 : mono
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
creation_time : 2016-10-11 12:30:25
Duration: 00:01:49.04, start: 0.000000, bitrate: 150503 kb/s
Stream #0:0(eng): Video: prores (apch / 0x68637061),
yuv422p10le(bt709), 1920x1080, 143548 kb/s, SAR 1:1 DAR 16:9, 24 fps, 24
tbr, 24 tbn, 24 tbc (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
encoder : Apple ProRes 422 HQ
timecode : 00:00:00:00
Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1
channels, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
Stream #0:2(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1
channels, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
Stream #0:3(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1
channels, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
Stream #0:4(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1
channels, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
Stream #0:5(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1
channels, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
Stream #0:6(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, 1
channels, s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
Stream #0:7(eng): Data: none (tmcd / 0x64636D74) (default)
Metadata:
creation_time : 2016-10-11 12:32:09
handler_name : Apple Alias Data Handler
timecode : 00:00:00:00
File 'output_25fps.mov' already exists. Overwrite ? [y/N] y
Output #0, mov, to 'output_25fps.mov':
Metadata:
major_brand : qt
minor_version : 537199360
compatible_brands: qt
encoder : Lavf56.36.100
Stream #0:0(eng): Video: prores (apch) (apch / 0x68637061),
yuv422p10le, 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 25 fps, 12800
tbn, 25 tbc (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
timecode : 00:00:00:00
encoder : Lavc56.41.100 prores
Stream #0:1(eng): Audio: pcm_s24le (in24 / 0x34326E69), 48000 Hz, mono,
s32 (24 bit), 1152 kb/s (default)
Metadata:
creation_time : 2016-10-11 12:30:25
handler_name : Apple Alias Data Handler
encoder : Lavc56.41.100 pcm_s24le
Stream mapping:
Stream #0:0 -> #0:0 (prores (native) -> prores (native))
Stream #0:1 -> #0:1 (pcm_s24le (native) -> pcm_s24le (native))
Press [q] to stop, [?] for help
frame= 2617 fps= 51 q=0.0 Lsize= 2132252kB time=00:01:49.04
bitrate=160190.2kbits/s
video:2116877kB audio:15334kB subtitle:0kB other streams:0kB global
headers:0kB muxing overhead: 0.001927%
More information about the ffmpeg-user
mailing list