Tutorial: Reclaim your audio from MFC/Chaturbate recordings

whyamibeer

New member
Problem:
These sites use speex as the audio codec, but this isn't supported by most video players. You need to re-encode the audio in order for it to play through VLC. VirtualDub/Handbrake don't detect the audio, so you'll need to use ffmpeg to make the audio audible.

Overview:
This script is written with powershell. It will process an entire folders worth of recordings so you don't need to do each file, one at a time. Just drop your FLV files with the SPEEX codex into its input folder, run the script, and it will re-encode the videos for you. This method will copy the video stream, not reencode it, so there will be 0 quality or disk space loss. This tutorial is for how to do it on Windows.

The script is probably the exact same thing as tubedigger's convert screen's "Fix FLV" option, but this will handle as many files as you put in the input folder (instead of 1 at a time). Just like the fix FLV option, you can't have the audio muted in tubedigger. It seems if it's muted in tubedigger, the audio will cut out when you mute it. The way around this is to mute the audio for tubedigger with windows (click sound, then go to the mixer. mute all running tubdigger programs there and make sure the audio isnt muted in MFC in tubedigger).

Software required:
Powershell - This should be installed on windows 7 by default, but executing scripts with it is disabled by default. My powershell script will temporally enable it, then set it back to its original state when it's finished. Unfortunately this requires you to run powershell as an admin. It's a fairly simple script so you should be able to tell it doesn't have any viruses in it.
FFMPEG - It's an open source video/audio tool that allows you compress/decompress/transcode videos. I got mine from here: http://ffmpeg.zeranoe.com/builds/win32/static/ffmpeg-20140712-git-ca671be-win32-static.7z Grab the 32bit static version from that site.
A brain - I've simplified this quite a bit, but you'll need to be computer literate to execute these steps.

Hardware requirements: Windows. Only tested on windows 7, but it will probably work on any version of windows which has powershell installed.

Steps:
  1. First off, create a new folder. Name it whatever you want. Mine is called "reencode".
  2. Download FFMPEG from the link above. Extract it and copy/paste the "ffmpeg.exe" file from the bin folder to your reencode folder.
  3. Create a new file called "script.ps1". Make sure the extension is actually ps1, not txt
  4. Open the .ps1 file in notepad and copy/paste the following into it:
    Code:
    function Get-ScriptDirectory
    {
        $Invocation = (Get-Variable MyInvocation -Scope 1).Value;
        if($Invocation.PSScriptRoot)
        {
            $Invocation.PSScriptRoot;
        }
        Elseif($Invocation.MyCommand.Path)
        {
            Split-Path $Invocation.MyCommand.Path
        }
        else
        {
            $Invocation.InvocationName.Substring(0,$Invocation.InvocationName.LastIndexOf("\"));
        }
    }
    #enable powershell
    $origPolicy = Get-ExecutionPolicy
    $policyChanged = 0
    if($origPolicy -ne "Unrestricted")
    {
        #not running as unrestricted... if we are not an admin, we can't set it to unrestricted so the script can run.
        If (-NOT ([Security.Principal.WindowsPrincipal][Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole] "Administrator"))
        {   
            #User is not running as admin, request admin rights from the user.  if they accept, pass the current arguments into a new powershell process 
            $arguments = "& '" + $myinvocation.mycommand.definition + "'"
            Start-Process powershell -Verb runAs -ArgumentList $arguments
            #break quits the program
            Break
        }
        Set-ExecutionPolicy Unrestricted
        #set this to 1 so we know we need to put it back to its original value.
        $policyChanged=1
    }
    
    #get the base directory
    $baseDir = Get-ScriptDirectory 
    #input directory
    $inputDir = $baseDir + "\input"
    #output directory
    $outputDir = $baseDir + "\output"
    #make the output directory if it does not exist
    New-Item -ItemType Directory -Force -Path $outputDir
    #get the flv files in the input directory.
    $files =  Get-ChildItem $inputDir -Filter *.flv
    ForEach($file in $files)
    {
        #make command line string to reencode the audio in the video
        $strToExecute = """" + $baseDir + "\ffmpeg.exe" + """" + " -i " + """" + $inputDir + "\" + $file + """" + " -vcodec copy " + """" + $outputDir + "\" + $file.Name.Split(".")[0] + ".mp4" + """"
        #write it to the screen
        Write-Host $strToExecute
        #kick it off
        Invoke-Expression  "& $strToExecute"
    }
    
    #if we changed the execution policy, put it back to what it was before.
    if($policyChanged -eq 1)
    {
        Set-ExecutionPolicy $origPolicy
    }
  5. Note: if you quit in the middle of this, it will leave your execution policy to unrestricted. that would allow any powershell script to run on your pc whenever they want (bad..) You can reset it to restricted by opening powershell as an admin and typing Set-ExecutionPolicy Restricted. If you're on a 64bit machine you'll need to do this once for the 64bit powershell and another time for the 32bit powershell.
  6. Create a .bat file to kick off the powershell script with the following in it:
    Code:
    powershell.exe -command "& .\script.ps1"
    pause
  7. Create a folder named "input" in your reencode folder.
  8. Drop the broken flv files into the input folder.
  9. To run the script, you should only have to click the .bat file you made.
  10. You should see a massive amount of text start scrolling by from the ffmpeg.exe's output.
  11. The fixed files should be in the new output directory.

If the script doesn't work for you, you can do this one file at a time with ffmpeg. To do this, drop the file you want to fix into the bin folder. Click the ff-prompt.bat file in the bin folder's parent directory. It brings up its own version of a command prompt. You can type the following to fix 1 file: ffmpeg.exe -i [filename] -vcodec copy [filename with mp4 extension]

Example:
ffmpeg -i mfc_101786698.flv -vcodec copy mfc_101786698.mp4

This has worked for most of my recordings, but I've only been using the script for a few hours now.

Known issues:
For one of my recordings, the source file tubedigger saved was messed up more than usual (unfixable). For this file, it ended up leaving a 174kb video file (original was about a gig) in the output folder... Take this warning to heart. Don't blindly replace your original files with what was in the output directory. Check their file sizes first and test anything that looks too small.

Also, if tubedigger randomly kills itself like it always seems to do for me, the file might be messed up. Check it carefully after running it through the script.
 

Yugioh626

New member
Ok, I've tried, but I keep getting an error. It says script.ps1 is not recognized as the name of a cmdlet, function, scriptfile or operable program. Check the spelling of the name or if the path was included, verify that the path is correct and try again.

Can I ask a few silly questions. I created the "reencode" folder. I downloaded ffmpeg and extracted the contents to that same folder ( I tried it with the ffmpeg extraction in the "reencode" folder and in a completely different folder on my computer).

I copy/pasted (not cut) the ffmpeg.exe file to the main "reencode" folder. I created the input folder in the "reencode" folder. I made the .bat and .ps1 files by starting with a txt file for each , pasting your script into them and changing the file extension and saving. I put a chaturbateflv file in the input folder. I have windows 7 64. I ran the .bat file by clicking on it and selecting run as administrator.

I've cocked something up I'm sure. I use handbrake, but it kills Chaturbate audio when it renecodes ( I discovered after I converted over 100 vids and checked for video quality, but not audio quality and deleted the originals, argh). ANy clarification would be appreciated.
 

Yugioh626

New member
In this case, ffmpeg needs a little help from you to specify the audio codec to be used. From the script you copied, find and specify libvo-aacenc as your audio codec, which the ffmpeg you use has to be compiled with. So instead of , try instead.
Thank You, even though I ended up using this post here instead. It makes the files MP4 (unfortunately making them all larger) and corrects the sound.
Appreciation.
 
Last edited by a moderator:
Top