aidandenlinger / SnapchatMemoriesCaptionAdder

Adds metadata (captions and timestamps) to your exported Snapchat memories.
MIT License
22 stars 3 forks source link

videos with captions aren't working with ffmpeg 7 #7

Open saabdo42 opened 5 months ago

saabdo42 commented 5 months ago

hey! so i'm trying to fix my snap memories, i downloaded all the requirements and ran the program and it worked beautifully for all my images. but then it gets to the videos and doesn't work? it just stops after like 10 videos, and i check the output and they're all videos that don't have captions (originally). so those are working, but the videos that are supposed to have captions don't. i redownloaded ffmpeg, and reran the python line to download requirements and it said "requirement is already satified." i'm not sure what i'm doing wrong, maybe i don't have enough ram or something?

aidandenlinger commented 5 months ago

Can you try running the program with the -v flag and paste the output once it gets to video conversion here? (Like python main.py -v.) The program will print out what it's doing, and having that info will make it easier to debug :)

If you want to save some time, you can force it to only process videos by opening main.py and deleting lines 48-60, so that way it only runs the video code: https://github.com/aidandenlinger/SnapchatMemoriesCaptionAdder/blob/a59f352ef877f201a7918ae772df2f3b68e2bd12/main.py#L48-L60

(I'll add an option in the future to only process images/videos instead of having to delete code to make debugging easier!)

And don't worry, if the images were processed correctly then I'm very confident you've done everything right and it's a bug in the program. Thanks for reaching out so the program can be better!

saabdo42 commented 5 months ago
DEBUG - Args(memories_history=WindowsPath('input/memories_history.json'), memories_folder=WindowsPath('input/memories'), output_folder=WindowsPath('output'), verbose=<VerboseLevel.PROGRAM: 2>)
INFO - E2298FEE-3F13-4F6C-ABFD-7DD225A847E8 has duplicates in memories_history.json but has same data, continuing...

And then it just has that INFO line again a bunch of times

Handling videos... (this will be slower than the pictures and will have hitches!)
  0%|                                                                                         | 0/2425 [00:00<?, ?it/s]DEBUG - base image name found: input\memories\2020-08-03_377c5b64-c6f0-ee4a-0773-105bd40c22ad-main.mp4
DEBUG - Overlay: input\memories\2020-08-03_377c5b64-c6f0-ee4a-0773-105bd40c22ad-overlay.png
DEBUG - output file: output\2020-08-03_17_30_2020-08-03_377c5b64-c6f0-ee4a-0773-105bd40c22ad.mp4
DEBUG - base image name found: input\memories\2019-11-21_1a46e15e-69ed-6212-cbcf-820090959abe-main.mp4
DEBUG - Overlay: input\memories\2019-11-21_1a46e15e-69ed-6212-cbcf-820090959abe-overlay.png
DEBUG - output file: output\2019-11-21_11_01_2019-11-21_1a46e15e-69ed-6212-cbcf-820090959abe.mp4
DEBUG - base image name found: input\memories\2022-03-14_63BA1008-2054-48DD-8BD3-080D38DBDD41-main.mp4
DEBUG - Overlay: input\memories\2022-03-14_63BA1008-2054-48DD-8BD3-080D38DBDD41-overlay.png
DEBUG - output file: output\2022-03-14_13_45_2022-03-14_63BA1008-2054-48DD-8BD3-080D38DBDD41.mp4
DEBUG - base image name found: input\memories\2018-08-02_D44BFDCB-F289-4FEC-96F7-FC612535A298-main.mp4
DEBUG - Overlay: input\memories\2018-08-02_D44BFDCB-F289-4FEC-96F7-FC612535A298-overlay.png
DEBUG - output file: output\2018-08-02_18_48_2018-08-02_D44BFDCB-F289-4FEC-96F7-FC612535A298.mp4
DEBUG - base image name found: input\memories\2021-03-08_57ae3c7d-b40a-be5e-e020-4a7d839eed77-main.mp4
DEBUG - Overlay: input\memories\2021-03-08_57ae3c7d-b40a-be5e-e020-4a7d839eed77-overlay.png
DEBUG - output file: output\2021-03-08_17_09_2021-03-08_57ae3c7d-b40a-be5e-e020-4a7d839eed77.mp4
DEBUG - base image name found: input\memories\2019-11-15_dac29496-2853-ef42-ce6b-cd69c1bd0f18-main.mp4
DEBUG - Overlay: None
DEBUG - output file: output\2019-11-15_15_37_2019-11-15_dac29496-2853-ef42-ce6b-cd69c1bd0f18.mp4
DEBUG - base image name found: input\memories\2019-11-09_e3f8d373-0cc0-e463-b4af-98776789b575-main.mp4
DEBUG - Overlay: None
DEBUG - output file: output\2019-11-08_22_08_2019-11-09_e3f8d373-0cc0-e463-b4af-98776789b575.mp4
  0%|▏                                                                                | 7/2425 [00:00<01:37, 24.79it/s]DEBUG - base image name found: input\memories\2022-02-17_4A5E70B2-E222-441C-8F5B-99FF7AF2EC9F-main.mp4
DEBUG - Overlay: input\memories\2022-02-17_4A5E70B2-E222-441C-8F5B-99FF7AF2EC9F-overlay.png
DEBUG - output file: output\2022-02-17_10_27_2022-02-17_4A5E70B2-E222-441C-8F5B-99FF7AF2EC9F.mp4
DEBUG - base image name found: input\memories\2021-09-13_6891cb9e-5409-ff3f-e46f-3e456fc6bce1-main.mp4
DEBUG - Overlay: input\memories\2021-09-13_6891cb9e-5409-ff3f-e46f-3e456fc6bce1-overlay.png
DEBUG - output file: output\2021-09-13_13_24_2021-09-13_6891cb9e-5409-ff3f-e46f-3e456fc6bce1.mp4
  0%|▏                                                                                | 7/2425 [00:20<01:37, 24.79it/s]

Thanks!!

aidandenlinger commented 5 months ago

Hey!

I updated the code with a few new flags:

So, python main.py --video-only --only-one will just convert one video, which will make debugging easier. You can download the new version of the code in the same way you did initially.

Second - it seems like the program is finding the captions. For example, the first debug output is:

DEBUG - base image name found: input\memories\2020-08-03_377c5b64-c6f0-ee4a-0773-105bd40c22ad-main.mp4
DEBUG - Overlay: input\memories\2020-08-03_377c5b64-c6f0-ee4a-0773-105bd40c22ad-overlay.png

Which means that it found a video 2020-08-03_377c5b64-c6f0-ee4a-0773-105bd40c22ad-main.mp4 with the caption input\memories\2020-08-03_377c5b64-c6f0-ee4a-0773-105bd40c22ad-overlay.png. So first, could you check those two files and make sure they're what you expect? Most importantly, let's make sure the overlay image actually has a caption. I want to make the caption is actually there and there isn't some bug on Snapchat's end :)

Assuming the caption doesn't have problems, then it seems like something is wrong with ffmpeg. If that's the case, can you run python main.py --video-only --only-one -vv? The -vv is an extra verbose mode - this will print out ffmpeg's output. ffmpeg is the one responsible for combining the video and the caption, so assuming that it's getting the correct files but the caption isn't coming out, then there's something wrong with ffmpeg and its output should let us know what's wrong. It will be a lot of output.

saabdo42 commented 5 months ago

Ok i just checked those files, they look fine, the video plays and has sound and the overlay is correct. I just ran the program with the new flags and here's the output

DEBUG:root:Args(memories_history=WindowsPath('input/memories_history.json'), memories_folder=WindowsPath('input/memories'), output_folder=WindowsPath('output'), verbose=<VerboseLevel.PROGRAM_AND_LIBRARIES: 3>, type_handled=<MediaToHandle.VIDEO: 3>, only_one=True)
INFO:__snap:E2298FEE-3F13-4F6C-ABFD-7DD225A847E8 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:B48EE506-AD97-4DA3-9284-8C38BB5096A1 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:7DB674B5-A933-4A95-9B36-F35A85A3094E has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:7DB674B5-A933-4A95-9B36-F35A85A3094E has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:5D1F68EB-E87E-4C80-A2DD-3CD57C5C20CC has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:5D1F68EB-E87E-4C80-A2DD-3CD57C5C20CC has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:364732B7-881F-44B1-A391-5F3848DC25E3 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:364732B7-881F-44B1-A391-5F3848DC25E3 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:41321CCD-4674-40CD-AC55-DCD692F5CE66 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:41321CCD-4674-40CD-AC55-DCD692F5CE66 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:512C2CF4-FD67-4B64-96AB-536CD964E717 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:512C2CF4-FD67-4B64-96AB-536CD964E717 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:B26E6B24-8475-4529-A329-7702A93B491B has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:B26E6B24-8475-4529-A329-7702A93B491B has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:9A2675AC-2D2F-4553-95BF-143CA6973EFA has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:9A2675AC-2D2F-4553-95BF-143CA6973EFA has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:3994F2D7-39C8-4846-A9AB-DCAB763F91A5 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:3994F2D7-39C8-4846-A9AB-DCAB763F91A5 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:CA9B4F36-A5AA-47ED-BC91-BAB8C2C27D63 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:CA9B4F36-A5AA-47ED-BC91-BAB8C2C27D63 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:048C7325-5F2C-4CAA-8978-9E46E46F132D has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:048C7325-5F2C-4CAA-8978-9E46E46F132D has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:2B6B9364-FD6F-49E4-8690-6696C8FCE3FC has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:2B6B9364-FD6F-49E4-8690-6696C8FCE3FC has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:ED0BDC49-2C57-4410-8DAD-90E0CB34B596 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:ED0BDC49-2C57-4410-8DAD-90E0CB34B596 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:2367536C-26BA-482D-B28B-B2846E379064 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:2367536C-26BA-482D-B28B-B2846E379064 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:B2B73200-7151-4EC7-AF55-147D4BF91439 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:B2B73200-7151-4EC7-AF55-147D4BF91439 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:935BBC9B-B1FA-46FF-B5A9-3355A8F32664 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:935BBC9B-B1FA-46FF-B5A9-3355A8F32664 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:D46D78B8-0160-4CFA-891D-03CED614CAA4 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:D46D78B8-0160-4CFA-891D-03CED614CAA4 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:00483D10-007C-4927-8C56-AFF1BF61C3E4 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:00483D10-007C-4927-8C56-AFF1BF61C3E4 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:78E7A109-F07A-467A-8F72-E9D30A7E11A4 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:78E7A109-F07A-467A-8F72-E9D30A7E11A4 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:7664623A-B13B-42DC-A27A-6605B279582F has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:7664623A-B13B-42DC-A27A-6605B279582F has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:77887E7D-17FC-4680-BFD2-84CA714360CA has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:77887E7D-17FC-4680-BFD2-84CA714360CA has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:72DB3339-7227-4D82-AEB2-3FDB9A825E6D has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:72DB3339-7227-4D82-AEB2-3FDB9A825E6D has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:9E32B26E-2441-476C-820B-92522954EF9A has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:9E32B26E-2441-476C-820B-92522954EF9A has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:3F9ABEE6-7A61-44CA-A623-AF8566583578 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:3F9ABEE6-7A61-44CA-A623-AF8566583578 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:C21A5DAC-5EB0-43C9-9809-039C7BF6EF22 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:C21A5DAC-5EB0-43C9-9809-039C7BF6EF22 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:89ED0FE8-7573-403C-83FF-C0DA0CD261D8 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:89ED0FE8-7573-403C-83FF-C0DA0CD261D8 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:57A6F092-3C7C-425C-A50F-EEC6E84AF442 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:57A6F092-3C7C-425C-A50F-EEC6E84AF442 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:5ae5b4e0-c10b-bf9d-d2fc-bdb26d6190c4 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:663604e7-5fc7-1d82-5448-6f84cadf4ed2 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:39347e8a-8a8d-3eee-69a4-26b8adf646f8 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:242aff13-8c32-3da1-b0c0-69c44f896536 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:a0907089-544b-3a40-c49d-9803f0387488 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:740D7BC7-20A6-4E7A-8410-61F0427DAEB0 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:B3DA4692-7581-4EE1-A2DD-03C11FA6923B has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:DEDF4FBF-123A-4256-A13D-58AB30B030C1 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:B31505B3-A68E-410D-8C5D-AE5D891BF013 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:0B3049F0-49C5-4A80-A1C7-D91BE6BCF16E has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:7701213B-3AB4-44F1-B5B4-9FB07F325FE7 has duplicates in memories_history.json but has same data, continuing...
INFO:__snap:0F357504-F814-4892-8ADE-FC650E91C0D2 has duplicates in memories_history.json but has same data, continuing...
Handling videos... (this will be slower than the pictures and will have hitches!)
  0%|                                                                            | 0/1 [00:00<?, ?it/s]DEBUG:__snap:base image name found: input\memories\2020-03-23_a16125e4-8eb5-2083-4e17-efe075279d6c-main.mp4
DEBUG:__snap:Overlay: input\memories\2020-03-23_a16125e4-8eb5-2083-4e17-efe075279d6c-overlay.png
DEBUG:__snap:output file: output\2020-03-23_16_52_2020-03-23_a16125e4-8eb5-2083-4e17-efe075279d6c.mp4
100%|███████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00, 288.74it/s]
Waiting for final videos...
  0%|                                                                            | 0/1 [00:00<?, ?it/s]ffmpeg version 7.0.1-full_build-www.gyan.dev Copyright (c) 2000-2024 the FFmpeg developers
  built with gcc 13.2.0 (Rev5, Built by MSYS2 project)
  configuration: --enable-gpl --enable-version3 --enable-static --disable-w32threads --disable-autodetect --enable-fontconfig --enable-iconv --enable-gnutls --enable-libxml2 --enable-gmp --enable-bzlib --enable-lzma --enable-libsnappy --enable-zlib --enable-librist --enable-libsrt --enable-libssh --enable-libzmq --enable-avisynth --enable-libbluray --enable-libcaca --enable-sdl2 --enable-libaribb24 --enable-libaribcaption --enable-libdav1d --enable-libdavs2 --enable-libuavs3d --enable-libxevd --enable-libzvbi --enable-librav1e --enable-libsvtav1 --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs2 --enable-libxeve --enable-libxvid --enable-libaom --enable-libjxl --enable-libopenjpeg --enable-libvpx --enable-mediafoundation --enable-libass --enable-frei0r --enable-libfreetype --enable-libfribidi --enable-libharfbuzz --enable-liblensfun --enable-libvidstab --enable-libvmaf --enable-libzimg --enable-amf --enable-cuda-llvm --enable-cuvid --enable-dxva2 --enable-d3d11va --enable-d3d12va --enable-ffnvcodec --enable-libvpl --enable-nvdec --enable-nvenc --enable-vaapi --enable-libshaderc --enable-vulkan --enable-libplacebo --enable-opencl --enable-libcdio --enable-libgme --enable-libmodplug --enable-libopenmpt --enable-libopencore-amrwb --enable-libmp3lame --enable-libshine --enable-libtheora --enable-libtwolame --enable-libvo-amrwbenc --enable-libcodec2 --enable-libilbc --enable-libgsm --enable-libopencore-amrnb --enable-libopus --enable-libspeex --enable-libvorbis --enable-ladspa --enable-libbs2b --enable-libflite --enable-libmysofa --enable-librubberband --enable-libsoxr --enable-chromaprint
  libavutil      59.  8.100 / 59.  8.100
  libavcodec     61.  3.100 / 61.  3.100
  libavformat    61.  1.100 / 61.  1.100
  libavdevice    61.  1.100 / 61.  1.100
  libavfilter    10.  1.100 / 10.  1.100
  libswscale      8.  1.100 /  8.  1.100
  libswresample   5.  1.100 /  5.  1.100
  libpostproc    58.  1.100 / 58.  1.100
Input #0, png_pipe, from 'input\memories\2020-03-23_a16125e4-8eb5-2083-4e17-efe075279d6c-overlay.png':
  Duration: N/A, bitrate: N/A
  Stream #0:0: Video: png, rgba(pc, gbr/bt709/iec61966-2-1), 1080x2088, 25 fps, 25 tbr, 25 tbn
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input\memories\2020-03-23_a16125e4-8eb5-2083-4e17-efe075279d6c-main.mp4':
  Metadata:
    major_brand     : mp42
    minor_version   : 0
    compatible_brands: isommp42
    creation_time   : 2020-03-23T21:52:50.000000Z
  Duration: 00:00:05.35, start: 0.000000, bitrate: 4123 kb/s
  Stream #1:0[0x100](eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 131 kb/s (default)
      Metadata:
        creation_time   : 2020-03-23T21:52:50.000000Z
        handler_name    : Snap Audio
        vendor_id       : [0][0][0][0]
  Stream #1:1[0x200](eng): Video: h264 (Baseline) (avc1 / 0x31637661), yuv420p(tv, progressive), 720x1392, 3986 kb/s, SAR 1:1 DAR 15:29, 24.11 fps, 14.99 tbr, 90k tbn (default)
      Metadata:
        creation_time   : 2020-03-23T21:52:50.000000Z
        handler_name    : Snap Video
        vendor_id       : [0][0][0][0]
Stream mapping:
  Stream #0:0 (png) -> scale2ref (graph 0)
  Stream #1:1 (h264) -> scale2ref (graph 0)
  overlay:default (graph 0) -> Stream #0:0 (libx264)
  Stream #1:0 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[vost#0:0/libx264 @ 00000222ed492780] No filtered frames for output stream, trying to initialize anyway.
[libx264 @ 00000222ed492b40] using SAR=1/1
[libx264 @ 00000222ed492b40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 00000222ed492b40] profile High, level 3.2, 4:2:0, 8-bit
[libx264 @ 00000222ed492b40] 264 - core 164 r3191 4613ac3 - H.264/MPEG-4 AVC codec - Copyleft 2003-2024 - http://www.videolan.org/x264.html - options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1 psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=14 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'output\2020-03-23_16_52_2020-03-23_a16125e4-8eb5-2083-4e17-efe075279d6c.mp4':
  Metadata:
    creation_time   : 2020-03-23T16:52:16-05:00
    location        : +36.2200-86.4951/
    location-eng    : +36.2200-86.4951/
    encoder         : Lavf61.1.100
  Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(progressive), 720x1392 [SAR 1:1 DAR 15:29], q=2-31, 14.99 fps, 90k tbn
      Metadata:
        encoder         : Lavc61.3.100 libx264
      Side data:
        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
  Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 69 kb/s (default)
      Metadata:
        creation_time   : 2020-03-23T21:52:50.000000Z
        handler_name    : Snap Audio
        vendor_id       : [0][0][0][0]
        encoder         : Lavc61.3.100 aac
[out#0/mp4 @ 00000222eccdcd80] video:0KiB audio:46KiB subtitle:0KiB other streams:0KiB global headers:0KiB muxing overhead: 3.798522%
frame=    0 fps=0.0 q=0.0 Lsize=      47KiB time=N/A bitrate=N/A speed=N/A
[aac @ 00000222ed59f480] Qavg: 2868.332
100%|████████████████████████████████████████████████████████████████████| 1/1 [00:00<00:00,  4.45it/s]
Done!

In the output folder it gave me an mp4 file that's 47kb, 5 seconds long like the original, with the audio, but there are no video frames.

aidandenlinger commented 5 months ago

Hey! I'm busier for the next few days but I'll try to get back to this soon!

Ffmpeg definitely isn't behaving as I'd expect, my plan of attack is

I'll get back to you with my findings when I have more time! Thanks for your patience :)

saabdo42 commented 5 months ago

Ya for sure take ur time!

On Tue, Jun 4, 2024 at 7:59 PM Aidan @.***> wrote:

Hey! I'm busier for the next few days but I'll try to get back to this soon!

Ffmpeg definitely isn't behaving as I'd expect, my plan of attack is

  • do the same on my computer and see if there's differences in our ffmpeg output, since mine is working and yours isn't. I'm on Linux so maybe there's something different abou Windows that I'm not accounting for?
  • finding out the actual ffmpeg command that's being run and seeing if you running that directly works - that would help narrow down if it's something with ffmpeg or ffmpeg-python (which is a middle layer between this program and python)

I'll get back to you with my findings when I have more time! Thanks for your patience :)

— Reply to this email directly, view it on GitHub https://github.com/aidandenlinger/SnapchatMemoriesCaptionAdder/issues/7#issuecomment-2148652976, or unsubscribe https://github.com/notifications/unsubscribe-auth/AWOHWTZCF522DLQ4QBKN4H3ZFZPF7AVCNFSM6AAAAABIXB2FT2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCNBYGY2TEOJXGY . You are receiving this because you authored the thread.Message ID: @.*** com>

aidandenlinger commented 4 months ago

I return! Thank you for your patience.

The filter I was using, scale2ref, has been depreciated recently by ffmpeg and using it results in broken video, as I discovered from this incredbly relevant SuperUser post. I haven't noticed this because my Linux distro is still shipping ffmpeg 6.1 where this isn't depreciated.

So the perfect solution is replacing scale2ref with the scale filter, which should result in everything working. I'll look into this, and assuming this filter also works in ffpmeg 6.1 then it shouldn't be that bad, but if I need to get ffmpeg 7 on my system this may take a bit longer.

However, the lazy solution that should immediately work is uninstalling ffmpeg 7 and installing ffmpeg 6 which should have a working scale2ref - to install this version you should be able to do winget install -e --id Gyan.FFmpeg --version 6.0.

If this works (or doesn't work) please let me know!

jxakellis commented 4 months ago

I can confirm that this works

With ffmpeg >= 7.0.0, it breaks certain conversions. If a video doesn't have an associated caption, it's correct in the output file. If a video contains an associated png file for a caption/overlay, it gets put into the output file with the correct metadata, but the video file only has audio and no frames/visuals

Your suggestion of forcibly downgrading ffmpeg to version 6 (in my case 6.1.1 was the latest of 6 that brew chose), resolved this issue. However, its performance slowed from about 30-45 seconds for my 1500 videos to about 5-8 minutes. I assume this might be from the fact that it has to process and stitch videos with captions now instead of skipping over them.

jxakellis commented 4 months ago

However, this has produced an unexpected bug.

With ffmpeg version 7, only about half the output videos have the correct timestamp in their metadata. With ffmpeg version 6, about 1/10 output videos have the correct timestamp. The rest of their videos have their creation/modification dates set to when they were created by the program

jxakellis commented 4 months ago

Adding onto that previous bug, I believe the metadata missing is dependent upon how much input data is added. When I added around 10-20 input videos (some with associated caption pngs), all of the outputs had the correct metadata (but some missing frames b/c ffmpeg 7). However, when I added my full 1500 input videos, only around half had the correct metadata.

I'll attach a screenshot of the command line with ffmpeg 7 & partial media, the input/output of that partial media, then the input/output of passing the full 1500 media

ffmpegv v7, full media, input:output ffmpegv v7, partial media, input:output ffmpegv v7, partial media, command line
jxakellis commented 4 months ago

I was able to isolate this bug. It depends upon a handful of bugged videos, around 3 out of 1500.

If the program encounters one of these videos when in the final stages of processing, all other videos saved to output before this encounter have the correct metadata however, any videos encountered after will have no metadata (e.g. timestamp set to present). Additionally, this bugged input video will not be saved to the output folder itself. My three encounters with videos like these seem to be clustered around mid-2020.

Here is the traceback:

Waiting for final videos... 100%|██| 1/1 [00:00<00:00, 8.73it/s] Traceback (most recent call last): File "/Users/jonathanxakellis/Documents/Snapchat/SnapchatMemoriesCaptionAdder/main.py", line 120, in main() File "/Users/jonathanxakellis/Documents/Snapchat/SnapchatMemoriesCaptionAdder/main.py", line 114, in main add_file_creation(path, metadata) File "/Users/jonathanxakellis/Documents/Snapchat/SnapchatMemoriesCaptionAdder/SnapchatMemoriesCaptionAdder/adder.py", line 105, in add_file_creation assert output.exists() AssertionError

aidandenlinger commented 4 months ago

@jxakellis Thanks for testing this! I added the information that ffmpeg 7 is not supported to the README and how to install ffmpeg 6. I'll leave this issue open until I fix the bug, which I plan on doing when my Linux distro provides ffmpeg 7.

I created a new issue to track your newly discovered bug, we can chat there (#9).