Audio/video stream recording forums (http://stream-recorder.com/forum/index.php)
-   rtmpdump (http://stream-recorder.com/forum/forumdisplay.php?f=54)
-   -  

FLV fixer script

(http://stream-recorder.com/forum/showthread.php?t=12722)

Mary Chris Smith 03-03-2013 11:42 AM

Re: FLV fixer script


 
Quote:

Originally Posted by Mary Chris Smith (Post 60250)
Ok, I'll try your version, thanks!

Mh. I tested your version and now I can't download it at all.
It always stops on:
Code:

ERROR: Closing connection: NetStream.Play.StreamNotFound
With the officlial rtmpdump version I can download the stream. Sometimes the file is fine, sometimes it is corrupt, but it works.

mehphishtopheles 07-23-2013 04:38 AM

Re: FLV fixer script


 
Quote:

Originally Posted by KSV (Post 60225)
@Mary Chris Smith

Well script isn't lying. rtmpdump actually saved the corrupt file. it's a known bug in official version which i fixed ages ago. you need to use my version of rtmpdump to save the proper file in such cases. if you wanna recover the already saved files you have to fix them first by hand.

KSV, can you describe the by-hand fix you mentioned above?

I have some live files I ripped 3 weeks ago with the outdated (2.4 original) version of rtmpdump. They do appear to be corrupt, as they crash every tool i throw at them.

I have no way to re-obtain another dump since it was a live concert webcast. An example of what I am working with for source material:
https://mega.co.nz/#!lxlSVKJD!XpjbrT...KoCkkHGe HSFE

mehphishtopheles 07-23-2013 05:07 AM

Re: FLV fixer script


 
This is the output I get when running your php script:

Code:

# php flvfixer.php --nometa --in 1a.flv --out fixed.flv --debug

                                KSV FLV Fixer

 Type    CurrentTS      PreviousTS      Size    Position       
Writing AVC sequence header
 VIDEO  0              -1              66      13             
Writing AAC sequence header
 AUDIO  0              -1              4      94             
 VIDEO  0              0              52212  113           
Fixing video timestamp
 VIDEO  0              0              89     
 VIDEO  8              0              89      52340         
Fixing video timestamp
 VIDEO  0              8              91     
 VIDEO  16              8              91      52444         
Fixing video timestamp
 VIDEO  0              16              92     
 VIDEO  24              16              92      52550         
Fixing video timestamp
 VIDEO  0              24              96     
 VIDEO  32              24              96      52657         
Fixing video timestamp
 VIDEO  0              32              98     
 VIDEO  40              32              98      52768         
Fixing video timestamp
 VIDEO  0              40              125   
 VIDEO  48              40              125    52881         
Fixing video timestamp
 VIDEO  0              48              247   
 VIDEO  56              48              247    53021         
Fixing video timestamp
 VIDEO  0              56              390   
 VIDEO  64              56              390    53283         
Fixing video timestamp
 VIDEO  0              64              765   
 VIDEO  72              64              765    53688         
Fixing video timestamp
 VIDEO  0              72              873   
 VIDEO  80              72              873    54468         
Fixing video timestamp
 VIDEO  0              80              2197   
 VIDEO  88              80              2197    55356         
Fixing video timestamp
 VIDEO  0              88              2313   
 VIDEO  96              88              2313    57568         
Fixing video timestamp
 VIDEO  0              96              3001   
 VIDEO  104            96              3001    59896         
Fixing video timestamp
 VIDEO  0              104            2810   
 VIDEO  112            104            2810    62912         
Fixing video timestamp
 VIDEO  0              112            3379   
 VIDEO  120            112            3379    65737         
Fixing video timestamp
 VIDEO  0              120            4011   
 VIDEO  128            120            4011    69131         
Fixing video timestamp
 VIDEO  0              128            4121   
 VIDEO  136            128            4121    73157         
Fixing video timestamp
 VIDEO  0              136            4063   
 VIDEO  144            136            4063    77293         
Fixing video timestamp
 VIDEO  0              144            4930   
 VIDEO  152            144            4930    81371         
Fixing video timestamp
 VIDEO  0              152            5275   
 VIDEO  160            152            5275    86316         
Fixing video timestamp
 VIDEO  0              160            5443   
 VIDEO  168            160            5443    91606         
Fixing video timestamp
 VIDEO  0              168            5492   
 VIDEO  176            168            5492    97064         
Fixing video timestamp
 VIDEO  0              176            5662   
 VIDEO  184            176            5662    102571         
Fixing video timestamp
 VIDEO  0              184            5826   
 VIDEO  192            184            5826    108248         
Fixing video timestamp
 VIDEO  0              192            5861   
 VIDEO  200            192            5861    114089         
Fixing video timestamp
 VIDEO  0              200            5996   
 VIDEO  208            200            5996    119965         
Fixing video timestamp
 VIDEO  0              208            5731   
 VIDEO  216            208            5731    125976         
Fixing video timestamp
 VIDEO  0              216            6348   
 VIDEO  224            216            6348    131722         
Fixing video timestamp
 VIDEO  0              224            5897   
 VIDEO  232            224            5897    138085         
Fixing video timestamp
 VIDEO  0              232            6402   
 VIDEO  240            232            6402    143997         
Timestamp gap detected: PacketTS=1870706200 LastTS=240 Timeshift=1870705960
Timestamp gap detected: PacketTS=26934631 LastTS=240 Timeshift=26934391
Timestamp gap detected: PacketTS=227358670 LastTS=240 Timeshift=227358430
Broken FLV tag encountered! Aborting further processing.
Processed input file in 2.57 seconds
Finished


KSV 07-23-2013 08:24 AM

Re: FLV fixer script


 
i am not gonna download 2 GB file just to explain the method. only upload first 10 MB of file.

mehphishtopheles 07-23-2013 08:53 AM

Re: FLV fixer script


 
Quote:

Originally Posted by KSV (Post 62972)
i am not gonna download 2 GB file just to explain the method. only upload first 10 MB of file.

Of course, my apologies.

Is there a windows shell command I can use to save just the first 10MB of the file into a new one? I'm not exactly sure how to do that.

Thank you for your patience and kindness. I am desperately in need of your help, as I have a number of files that have this exact problem. I know how to avoid it in the future now using your custom compiled version of rtmpdump, but would like to be able to get useable footage out of some of the stuff I already ripped with the old version.

KSV 07-23-2013 09:24 AM

Re: FLV fixer script


 
save the following script as trim.php and run the command line

Code:

php trim.php "input video.flv"
Code:

<?php
$handle = fopen($argv[1], 'rb');
$data  = fread($handle, 10 * 1024 * 1024);
file_put_contents("$argv[1]" . ".trim", $data);
?>


mehphishtopheles 07-23-2013 09:48 AM

Re: FLV fixer script


 
Thank you, KSV.

Here is the trimmed file:

https://mega.co.nz/#!l5V1WSZZ!RkortC...NL7hYsdQ Z2A8

KSV 07-23-2013 12:31 PM

Re: FLV fixer script


 
i have analyzed it. it doesn't seems like the original capture from rtmpdump. have you ran any other tools on this file? it seems messed up at many places. provide original unaltered rtmpdump trim.

ZeChico 04-30-2014 08:56 AM

Re: FLV fixer script


 
Hi!

I'm sorry to necro this thread, but I have been using this script for a long time to repair my MFC recordings. I always notice that the videos, specially the long ones had a slow motion after a while and the audio was not synchronized.

Only now that I paid attention to it. It seems the problem was in the "FLV fixer.php" itself, the default value of FRAMEFIX_STEP of 40 was too high.

After many tests I found that the value of 22 is ideal so I changed the line on the script to:
define('FRAMEFIX_STEP', 22);

With this the sound seems fine and so is the motion.

To further repair the files I also created a small bat script (ex: FLVfixer.bat) to repair any FLV in the same folder, it calls the "FLV fixer.php" and uses the "yamdi.exe" (search the net for it) to recreate the metadata, so it needs this 2 files in the same folder. It first repairs the flv into a temporary file and then the yamdi uses the temporary file to rewrite the original one.

This is the DOS BAT script if anyone wants this easier way of repairing many MFC FLV files in the same folder:
Code:

@ECHO OFF
FOR %%A IN (*.flv) DO (
IF NOT "%%A"=="temp.flv" CALL :FIX "%%A"
)
GOTO END

:FIX
ECHO -------------------------------------------------------
ECHO - Fixing %1...
php "FLV fixer.php" --nometa --fixwindow 1000 --in %1 --out "temp.flv"
ECHO Injecting MetaData with yamdi...
yamdi.exe -i "temp.flv" -k -o %1
ECHO Done!
ECHO:
GOTO :eof

:END
ECHO -------------------------------------------------------
ECHO Deleting temporary file...
DEL /Q "temp.flv"
ECHO:
ECHO All done!
ECHO ON
@PAUSE

If instead of rewrite the file you instead want it to save into other folder (ex: into folder "OK") you need to edit the following line:
yamdi.exe -i "temp.flv" -k -o .\OK\\%1

To repair old flv repaired by "FLV fixer.php" that got this slow motion problem, you need to edit the "FLV fixer.php" and after editing the line:
define('FRAMEFIX_STEP', 22);

You also need to change the line:
if ($timeShift > $fixWindow)
to
if ($timeShift == 40)

Thank you KSV for this script.

Regards!

CristianoA 09-22-2016 08:40 AM

Re: FLV fixer script


 
FLVFixer for Windows anyone ?


All times are GMT -6. The time now is 10:20 AM.