Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lossless cut before next keyframe #91

Open
jxu opened this issue Nov 9, 2024 · 0 comments
Open

Lossless cut before next keyframe #91

jxu opened this issue Nov 9, 2024 · 0 comments

Comments

@jxu
Copy link

jxu commented Nov 9, 2024

I assume this app is a wrapper over ffmpeg. I tried the lossless cut and not surprisingly the starting frames before the next keyframe were lost. However using ffmpeg from termux, with -c:v copy it somehow managed to start on the exact right frame and without re-encoding the entire thing. I don't know if it just re-encoded the frames up to the next keyframe but this feature is desirable compared to losing up to a few seconds at the start of a clip.

Here's the output if it helps

$ ffmpeg -v 40 -ss 3:08 -to 4:04  -i 25-02.mp4 -c:v copy 25-02new.mp4
ffmpeg version 6.1 Copyright (c) 2000-2023 the FFmpeg developers
  built with Android (10552028, +pgo, +bolt, +lto, -mlgo, based on r487747d) clang version 17.0.2 (https://android.googlesource.com/toolchain/llvm-project d9f89f4d16663d5012e5c09495f3b30ece3d2362)
  configuration: --arch=aarch64 --as=aarch64-linux-android-clang --cc=aarch64-linux-android-clang --cxx=aarch64-linux-android-clang++ --nm=llvm-nm --pkg-config=/home/builder/.termux-build/_cache/android-r26b-api-24-v0/bin/pkg-config --strip=llvm-strip --cross-prefix=aarch64-linux-android- --disable-indevs --disable-outdevs --enable-indev=lavfi --disable-static --disable-symver --enable-cross-compile --enable-gnutls --enable-gpl --enable-version3 --enable-jni --enable-lcms2 --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgme --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenmpt --enable-libopus --enable-librav1e --enable-libsoxr --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libv4l2 --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-mediacodec --enable-opencl --enable-shared --prefix=/data/data/com.termux/files/usr --target-os=android --extra-libs=-landroid-glob --disable-vulkan --enable-neon --disable-libfdk-aac
  libavutil      58. 29.100 / 58. 29.100
  libavcodec     60. 31.102 / 60. 31.102
  libavformat    60. 16.100 / 60. 16.100
  libavdevice    60.  3.100 / 60.  3.100
  libavfilter     9. 12.100 /  9. 12.100
  libswscale      7.  5.100 /  7.  5.100
  libswresample   4. 12.100 /  4. 12.100
  libpostproc    57.  3.100 / 57.  3.100
[h264 @ 0xb400007824156510] Reinit context to 416x720, pix_fmt: yuv420p
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '25-02.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512                                   compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:08:25.70, start: 0.000000, bitrate: 1132 kb/s
  Stream #0:0[0x1](und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(progressive, left), 404x720 (416x720) [SAR 405:404 DAR 9:16], 1129 kb/s, 30 fps, 30 tbr, 15360 tbn (default)                            Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
[out#0/mp4 @ 0xb4000077c41520b0] No explicit maps, mapping streams automatically...
[vost#0:0/copy @ 0xb400007814150a50] Created video stream from input stream 0:0
Output #0, mp4, to '25-02new.mp4':
  Metadata:
    major_brand     : isom                                  minor_version   : 512
    compatible_brands: isomiso2avc1mp41                     encoder         : Lavf60.16.100                       Stream #0:0(und): Video: h264 (High), 1 reference frame (avc1 / 0x31637661), yuv420p(progressive, left), 404x720 (0x0) [SAR 405:404 DAR 9:16], q=2-31, 1129 kb/s, 30 fps, 30 tbr, 15360 tbn (default)
    Metadata:
      handler_name    : VideoHandler                          vendor_id       : [0][0][0][0]                    Stream mapping:                                           Stream #0:0 -> #0:0 (copy)
Press [q] to stop, [?] for help
size=       0kB time=-00:00:00.33 bitrate=  -0.0kbits/s No more output streams to write to, finishing.
[out#0/mp4 @ 0xb4000077c41520b0] All streams finished
[out#0/mp4 @ 0xb4000077c41520b0] Terminating muxer thread
[AVIOContext @ 0xb4000077e414bb90] Statistics: 7069406 bytes written, 2 seeks, 30 writeouts
[out#0/mp4 @ 0xb4000077c41520b0] Output file #0 (25-02new.mp4):
[out#0/mp4 @ 0xb4000077c41520b0]   Output stream #0:0 (video): 1690 packets muxed (7050140 bytes);
[out#0/mp4 @ 0xb4000077c41520b0]   Total: 1690 packets (7050140 bytes) muxed
[out#0/mp4 @ 0xb4000077c41520b0] video:6885kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.273214%
size=    6904kB time=00:00:55.96 bitrate=1010.5kbits/s speed=1.18e+03x
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0xb4000077d4157490] Terminating demuxer thread
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0xb4000077d4157490] Input file #0 (25-02.mp4):
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0xb4000077d4157490]   Input stream #0:0 (video): 1693 packets read (7053603 bytes);
[in#0/mov,mp4,m4a,3gp,3g2,mj2 @ 0xb4000077d4157490]   Total: 1693 packets (7053603 bytes) demuxed
[AVIOContext @ 0xb4000077e414cab0] Statistics: 7274496 bytes read, 1 seeks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant