CUTTING A VIDEO WITHOUT RE-ENCODING GETS AUDIO OUT OF SYNC
Hi! I am trying to cut a video file in to parts, without re-enconding the video, but i get a video file with non sync audio, how can I solve these with out re-encoding since I need a fast way to cut. I used this command: ffmpeg -i file.mp4 -ss 00:03:00 -t 00:05:00 -c copy part1.mp4 Thanks! Alejandro [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Am Do., 29. Aug. 2019 um 23:41 Uhr schrieb Alejandro Escudero <escuderoserrano@hotmail.com>:
I am trying to cut a video file in to parts, without re-enconding the video, but i get a video file with non sync audio, how can I solve these with out re-encoding since I need a fast way to cut.
I used this command:
ffmpeg -i file.mp4 -ss 00:03:00 -t 00:05:00 -c copy part1.mp4
Complete, uncut console output missing. Carl Eugen
Here is the console output of the previous test ( ffmpeg -i file.mp4 -ss 00:03:00 -t 00:05:00 -c copy part1.mp4) But i tried with this command (seconds before -i) and it worked (ffmpeg -ss 00:02:00 -i interview.mp4 -t 00:05:00 -c copy extract.mp4) C:\Users\User\Desktop\ejemplosffmpeg>ffmpeg -i interview.mp4 -ss 00:02:00 -t 00:05:00 -c copy extract.mp4 ffmpeg version N-94423-ga0c1970781 Copyright (c) 2000-2019 the FFmpeg developers built with gcc 9.1.1 (GCC) 20190716 configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --enable-libmfx --enable-amf --enable-ffnvcodec --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt libavutil 56. 32.100 / 56. 32.100 libavcodec 58. 55.100 / 58. 55.100 libavformat 58. 30.100 / 58. 30.100 libavdevice 58. 9.100 / 58. 9.100 libavfilter 7. 58.100 / 7. 58.100 libswscale 5. 6.100 / 5. 6.100 libswresample 3. 6.100 / 3. 6.100 libpostproc 55. 6.100 / 55. 6.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'interview.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2019-05-05T10:44:24.000000Z Duration: 00:20:56.34, start: 0.000000, bitrate: 341 kb/s Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], 209 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default) Metadata: creation_time : 2019-05-05T10:44:24.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 05/05/2019. Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: creation_time : 2019-05-05T10:44:24.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 05/05/2019. File 'extract.mp4' already exists. Overwrite ? [y/N] y Output #0, mp4, to 'extract.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 encoder : Lavf58.30.100 Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p(tv, bt709), 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 209 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 30k tbc (default) Metadata: creation_time : 2019-05-05T10:44:24.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 05/05/2019. Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 127 kb/s (default) Metadata: creation_time : 2019-05-05T10:44:24.000000Z handler_name : ISO Media file produced by Google Inc. Created on: 05/05/2019. Stream mapping: Stream #0:0 -> #0:0 (copy) Stream #0:1 -> #0:1 (copy) Press [q] to stop, [?] for help frame= 8949 fps=0.0 q=-1.0 Lsize= 12460kB time=00:04:59.98 bitrate= 340.2kbits/s speed=3.71e+03x video:7470kB audio:4688kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.482060% C:\Users\User\Desktop\ejemplosffmpeg> Thanks Alejandro ________________________________ From: ffmpeg-user <ffmpeg-user-bounces@ffmpeg.org> on behalf of Carl Eugen Hoyos <ceffmpeg@gmail.com> Sent: Thursday, August 29, 2019 11:16 PM To: FFmpeg user questions <ffmpeg-user@ffmpeg.org> Subject: Re: [FFmpeg-user] CUTTING A VIDEO WITHOUT RE-ENCODING GETS AUDIO OUT OF SYNC Am Do., 29. Aug. 2019 um 23:41 Uhr schrieb Alejandro Escudero <escuderoserrano@hotmail.com>:
I am trying to cut a video file in to parts, without re-enconding the video, but i get a video file with non sync audio, how can I solve these with out re-encoding since I need a fast way to cut.
I used this command:
ffmpeg -i file.mp4 -ss 00:03:00 -t 00:05:00 -c copy part1.mp4
Complete, uncut console output missing. Carl Eugen _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org... To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe". [https://ipmcdn.avast.com/images/icons/icon-envelope-tick-round-orange-animated-no-repeat-v1.gif]<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail> Libre de virus. www.avast.com<https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=webmail>
On Thu, Aug 29, 2019 at 6:41 PM Alejandro Escudero < escuderoserrano@hotmail.com> wrote:
Hi!
I am trying to cut a video file in to parts, without re-enconding the video, but i get a video file with non sync audio, how can I solve these with out re-encoding since I need a fast way to cut.
I used this command:
ffmpeg -i file.mp4 -ss 00:03:00 -t 00:05:00 -c copy part1.mp4
Thanks!
Alejandro
By my own experience I found that it usually happens because the cut falls somewhat distant of the next keyframe of the video. The player tries to play the video track but have to wait until the next keyframe but the audio start to play immediately, resulting in loss of sync. Try to cut closeset to the keyframe. Unfortunally I had no recipe for that, I fixed my cases on the try-and-error method.
On Sun, 1 Sep 2019 at 01:04, Micael Silva <micaelsilva@gmail.com> wrote:
On Thu, Aug 29, 2019 at 6:41 PM Alejandro Escudero < escuderoserrano@hotmail.com> wrote:
Hi!
I am trying to cut a video file in to parts, without re-enconding the video, but i get a video file with non sync audio, how can I solve these with out re-encoding since I need a fast way to cut.
I used this command:
ffmpeg -i file.mp4 -ss 00:03:00 -t 00:05:00 -c copy part1.mp4
Thanks!
Alejandro
By my own experience I found that it usually happens because the cut falls somewhat distant of the next keyframe of the video. The player tries to play the video track but have to wait until the next keyframe but the audio start to play immediately, resulting in loss of sync.
Try to cut closeset to the keyframe. Unfortunally I had no recipe for that, I fixed my cases on the try-and-error method. _______________________________________________ ffmpeg-user mailing list ffmpeg-user@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email ffmpeg-user-request@ffmpeg.org with subject "unsubscribe".
to get the times of the keyframes you can use this command: ffprobe -show_frames <video_file_name.avi>|grep -B 14 pict_type=I|grep pkt_pts_time=|awk -F'=' '{print $2}'|xargs -I{} date -d@"{}" -u +%H:%M:%S.%N E
participants (4)
-
Alejandro Escudero -
Carl Eugen Hoyos -
Erik Dobák -
Micael Silva