[Guide] How to convert FLVs to MP4 fast without re-encoding

Status
Not open for further replies.

dodgepong

Administrator
Community Helper
Please follow this guide instead: https://obsproject.com/forum/resources/how-to-convert-flvs-to-mp4-fast-without-re-encoding.78/

A lot of streamers like to save a local copy of the video they stream out in order to edit it later, upload it to YouTube, or just keep an archive. Usually, this means saving the video as an MP4 in your Broadcast settings. However, we know that OBS is beta software, and streaming is a complicated, resource-intensive process, and sometimes things crash. If you're recording an MP4, and OBS crashes before the MP4 can finish saving, it will be corrupted. FLVs, however, don't have this problem, because the container is designed to be started and stopped at any time. So if you are recording an FLV and OBS crashes, the FLV should not get corrupted.

FLVs and MP4s are actually very similar. They both are simply containers for an h.264/AVC video track and a AAC audio track. So the only difference is the container itself. Thus, you can very quickly and easily switch containers without needing to re-encode the video or audio!

Step 1: Download FFmpeg. You can get the latest Windows version from here. Extract it somewhere that you will remember.

Step 1a (Optional): Add the /bin folder where you extracted FFmpeg into your PATH environment variable to make it easy to access (Control Panel > System > Advanced System Settings > Advanced Tab > Environment Variables > System Variables > PATH > Edit, put a semicolon at the end and type the new path)

Step 2: Open a command prompt and navigate to where your video is stored.

Step 3: Run the following command (If ffmpeg.exe is not in your path, you will have to type out its full path):

ffmpeg -i input.flv -c copy -copyts output.mp4
Replace "input.flv" with the name of your source FLV file.
Replace "output.mp4" with what you want the name of your resulting MP4 should be.
The "-c copy" means it will just copy the audio and video tracks without re-encoding them.
The "-copyts" flag means it will copy timestamps, which should help with syncing audio and video.

Step 4: There is no step 4. You're done! That was fast.
 

Jack0r

The Helping Squad
Re: [Guide] How to convert FLVs to MP4 fast without re-encod

You can also save this commandline as a .bat file and replace input and output with %1. You could then drag a file onto the batch file to start the process.
ffmpeg -i %1 -c copy -copyts %1.mp4

PS: it might be necessary to either add ffmpeg to the Windows PATH info, or set the whole filepath in the batch file.
 

dehixem

Member
Re: [Guide] How to convert FLVs to MP4 fast without re-encod

Thanks for the great guide, had to to some editing using some twitch past broadcasts and had to convert flv to mp4 so that Premiere could edit those !
 

WayZHC

Member
Re: [Guide] How to convert FLVs to MP4 fast without re-encod

Batch: Converting from FLV to MP4 and moving the files automatically!

I made a batch to convert the file automatically and after the process it will move the files where you want them to be located. You can move both files (.flv and .mp4) after the conversion or just the .mp4 (or vice versa).

Example usage A: You have set a folder where you record the FLVs to. You want to convert the FLV to MP4 and you'd like to have the FLVs and MP4s in different folders to keep the folders more clear and finding the files afterwards is much easier.

Example usage B: You want to record to a fast HDD or SSD with very limited space so keeping the files there is not an option. You can make this convert the files and move them to another HDD/SSD or to an external storage. The whole process will take only few seconds to be done (depends of the size of the files and the speed of the HDD). So people recording locally can easily do this between the matches. Just leave the recording folder open on the background for fast access.

I added a lot of comments to the batch file telling what the commands will do and gave some tips to customize it for your needs.

Making the batch:
1. Open notepad
2. copy and paste the code (below) to the notepad
3. Click File > Save As...
4. Name it FLV to MP4.bat and change the save type from .txt to All Files
5. Save the batch to the recording folder
6. You are done

So here is the batch:
Code:
@echo off

:: Use this batch if you want the Files to be moved after the conversion.
:: You can set it to move both files or just the MP4 (or vice versa).

:: Place this batch to the folder you record to.

:: Just drag and drop the flv on the "FLV to MP4.bat" to start the process.

:: This is a fully customizable batch for your needs and i've added some comments
:: telling what the commands do.

:: You can contact me, WayZHC, via PM if you have any problems with this batch.
:: (I'm sorry for the possible typos and bad grammar in the comments)


ffmpeg -i %1 -c copy -copyts %1.mp4

:: ^^ Does the conversion from the original to MP4 and will place the .mp4
:: to the same folder.


timeout /T 3

:: ^^ this will make the batch wait for 3 (default) seconds before moving the files
:: just to make sure it wont rush to the next command too soon.


MOVE %1 ""

:: ^^ This will be the location for the FLV File.
:: [b][u]Add the location for the FLV files between the quotes.[/u][/b]
:: Example location: "H:\FLV library\"
:: Add two colons before the MOVE command if you don't want the FLV to be moved.



MOVE %1.mp4 ""

:: ^^ This will be the location for the MP4 File.
:: [b][u]Add the location for the MP4 files between the quotes.[/u][/b]
:: Example location: "H:\MP4 library\"
:: Add two colons before the MOVE command if you don't want the MP4 to be moved.


pause

:: ^^ You can see if the files were moved.
:: Will ask you to press any button to close.
:: Add two colons before the pause command if want it to close automatically.
:: Without this the window will close right after the batch got to it's
:: end without telling if the files actually got moved.
:: You can also use command "timeout /T *seconds here*" insted of "pause" if you wanted to.
 

dehixem

Member
Re: [Guide] How to convert FLVs to MP4 fast without re-encod

I noticed a small problem with this guide. Even though it works fine, I noticed it fucked up framerates pretty bad if it's trying to convert an .flv of a past broadcast where you lost frames.
As for me, I had a small section of the video where I dropped 2000 frames. The conversion did not work as planned, it slowed down most of the video and went into hyperspeed mode some segments. Wierd stuff. The audio was not affected but was desynched eventually.

Just thought it was worth saying :)
 

Boildown

Active Member
Re: [Guide] How to convert FLVs to MP4 fast without re-encod

jonnerkass said:
spam removed

Can you use Handbrake or VLC to do it without re-encoding though? I didn't think you could. Every time you re-encode, you lose quality, so it should be avoided if possible, thus this guide.
 

AlbertAviation

New Member
Hello... When I downloaded FFmpeg and used the batch WayZHC wrote, it said ffmpeg is not an internal or external command, do I need to modify the .bat file for the ffmpeg destination? If yes, where is it since I can find ffmpeg.c but not ffmpeg.exe. Thanks a lot :D
 
Status
Not open for further replies.
Top