UBports Robot Logo UBports Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

    Fixing corrupted videos recorded with Google Pixel 3A + UBPorts OTA23

    Scheduled Pinned Locked Moved Support
    1 Posts 1 Posters 329 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P Offline
      ptrkrysik
      last edited by ptrkrysik

      I was looking for a solution how to fix videos corrupted during recording with Google Pixel 3A + UBPorts OTA23 (16.04). There was an issue described for example here:

      Re: Video recording not working on Google Pixel 3a XL

      which resulted with videos that had absurdly wrong FPS. I had videos that were 3 minutes long but appeared as 15 hours long. Sound was ok, but the video part was viewable about one hour later.

      As the phone was used as daily driver (and still is but currently with Focal) I had some important videos recorded with it that I was very motivated to repair. I didn't find anything on the internet so here is a bash script that I created with help of chatgpt, that does the job (I wouldn't know about existence of MP4Box without chatgpt, obtaining a good result was much easier with that program than with ffmpeg):

      #!/bin/bash
      # Target FPS setting
      FPS=29.97
      
      # Create a directory for the fixed files
      mkdir -p fixed
      
      # Loop through all .mp4 files in the current directory
      for file in *.mp4; do
          echo "Processing: $file"
      
          # Base name without extension
          base="${file%.*}"
      
          # Demux (extract) video and audio streams
          MP4Box -raw 1 "$file" -out "${base}_track1.h264"
          MP4Box -raw 2 "$file" -out "${base}_track2.aac"
      
          # Re-mux into a new MP4 with corrected FPS
          MP4Box -add "${base}_track1.h264:fps=$FPS" -add "${base}_track2.aac" -new "fixed/${base}_fixed.mp4"
      
          # Clean up temporary files
          rm -f "${base}_track1.h264" "${base}_track2.aac"
      
          echo "Done: ${base}_fixed.mp4"
      done
      
      echo "All files have been processed and saved in the 'fixed/' directory."
      

      The synchronization of voice and picture is not ideal but for short videos it's ok.

      1 Reply Last reply Reply Quote 0
      • P ptrkrysik referenced this topic on
      • P ptrkrysik marked this topic as a regular topic on

      Hello! It looks like you're interested in this conversation, but you don't have an account yet.

      Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

      With your input, this post could be even better 💗

      Register Login
      • First post
        Last post