CUTTING A VIDEO WITHOUT RE-ENCODING GETS AUDIO OUT OF SYNC

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

CUTTING A VIDEO WITHOUT RE-ENCODING GETS AUDIO OUT OF SYNC

Alejandro Escudero
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>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: CUTTING A VIDEO WITHOUT RE-ENCODING GETS AUDIO OUT OF SYNC

Carl Eugen Hoyos-2
Am Do., 29. Aug. 2019 um 23:41 Uhr schrieb Alejandro Escudero
<[hidden email]>:

> 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
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: CUTTING A VIDEO WITHOUT RE-ENCODING GETS AUDIO OUT OF SYNC

Alejandro Escudero
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 <[hidden email]> on behalf of Carl Eugen Hoyos <[hidden email]>
Sent: Thursday, August 29, 2019 11:16 PM
To: FFmpeg user questions <[hidden email]>
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
<[hidden email]>:

> 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
[hidden email]
https://nam02.safelinks.protection.outlook.com/?url=https%3A%2F%2Fffmpeg.org%2Fmailman%2Flistinfo%2Fffmpeg-user&amp;data=02%7C01%7C%7C3c949c4d02844ea4786708d72cd6fffd%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637027174249485357&amp;sdata=35n9Rpzr0mo1SEFUqIP8OfYHonEYQCtSsEyg9iOzatg%3D&amp;reserved=0

To unsubscribe, visit link above, or email
[hidden email] 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>
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: CUTTING A VIDEO WITHOUT RE-ENCODING GETS AUDIO OUT OF SYNC

Micael Silva
In reply to this post by Alejandro Escudero
On Thu, Aug 29, 2019 at 6:41 PM Alejandro Escudero <
[hidden email]> 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
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: CUTTING A VIDEO WITHOUT RE-ENCODING GETS AUDIO OUT OF SYNC

Erik Dobák
On Sun, 1 Sep 2019 at 01:04, Micael Silva <[hidden email]> wrote:

> On Thu, Aug 29, 2019 at 6:41 PM Alejandro Escudero <
> [hidden email]> 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
> [hidden email]
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] 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
_______________________________________________
ffmpeg-user mailing list
[hidden email]
https://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".