VideoHelp Forum




+ Reply to Thread
Results 1 to 11 of 11
  1. Member
    Join Date
    Nov 2007
    Location
    United States
    Search Comp PM
    I am trying to convert a bunch of FLV files to MP4. I've tried Handbrake, ffmpeg, and mencoder, and none can convert properly. The problem is that the resulting file time does not match up with the known length of the video, so the video is way out of sync

    Here's an example from one of the files:
    Known length: 3:56
    Audio stream: 3:56
    Video stream: 7:52
    In this case, the video stream is much too long. I believe this is because of a variable framerate of the video inside the FLV file. FFmpeg sees the source FLV file like this:
    Duration: 00:03:56.33, start: 0.000000, bitrate: 223 kb/s
    Stream #0:0: Video: vp6f, yuv420p, 800x600, 15 tbr, 1k tbn, 1k tbc
    Stream #0:1: Audio: mp3, 44100 Hz, mono, s16p, 64 kb/s

    I used FLV_extract to split the video and audio streams into avi and mp3 files, and ffmpeg sees them like this:
    Input #0, avi, from 'Section 1.avi':
    Duration: 00:07:52.67, start: 0.000000, bitrate: 77 kb/s
    Stream #0:0: Video: vp6f (VP6F / 0x46365056), yuv420p, 800x608, 7.50 tbr, 7.50 tbn, 7.50 tbc
    Input #0, mp3, from 'Section 1.mp3':
    Duration: 00:03:56.85, start: 0.000000, bitrate: 64 kb/s
    Stream #0:0: Audio: mp3, 44100 Hz, mono, s16p, 64 kb/s

    One thing I notice is that the tbr, tbn, and tbc are different for the video stream depending on if it's within the FLV file or separate.

    I'm not really sure where to go from here. Does anyone have any suggestions on handling this?
    Quote Quote  
  2. The time is half, and 7.5 fps is half of 15 fps. So force the frame rate to 15 and it should be the same length and in sync

    Look at the timecodes when you used flv extract - are they variable ? MP4 supports VFR so if source was truly VFR, you can use mp4fpsmod to make the VFR MP4 with the same timecodes . FFmpeg should actually convert a VFR FLV to VFR MP4, keeping VFR, but you said it didn't work...post the command line used
    Quote Quote  
  3. I had problems with VFR in the past, but the latest & greatest win bin of FFMPEG appears to do a good job of taking VFR and putting it to CFR.

    I suggest simply defining the desired frame rate will induce CFR in the output video and video/audio length should "match", if that makes sense...

    Let us know...

    Andrew
    Quote Quote  
  4. Member
    Join Date
    Nov 2007
    Location
    United States
    Search Comp PM
    Here's the command line I am now using:
    ffmpeg -i ^
    "Section 1.flv" ^
    -acodec aac -ac 2 -strict experimental -ab 128k ^
    -vcodec libx264 ^
    -preset slow -profile:v baseline -level 30 ^
    -filter:v "setpts=0.4*PTS" ^
    -maxrate 10000000 -bufsize 10000000 ^
    -b:v 1200k ^
    -f mp4 -threads 0 ^
    "Section 1.mp4"

    I am using the iPad3 profile from this site: https://develop.participatoryculture.org/index.php/ConversionMatrix

    However, I tried forcing the framerate with "-r 15", but it did not seem to have an effect. I did have success by adding a filter though:
    -filter:v "setpts=0.4*PTS"
    as I have included in the above command line. I tried using 0.5 as the speed value, but for some reason that didn't slow the video down enough, but 0.4 hits exactly the right length. I'm sure there's something I'm not understanding there, but it's mostly working.

    I say "mostly" because ffmpeg is now crashing towards the end of the file. The result is that the audio continues but the video stops. The crash seems to generally line up with the spot the video stop, just near the end.

    Edit: I'm using the most recent Windows build of ffmpeg, Feb 17 2013 02:37:45
    Quote Quote  
  5. can you upload your smallest clip that exhibits the problem ?
    Quote Quote  
  6. Member bat999's Avatar
    Join Date
    Feb 2008
    Location
    United Kingdom
    Search Comp PM
    Hi
    Try using -vsync 1 instead of your filter.

    ffmpeg -i ^
    "Section 1.flv" ^
    -acodec aac -ac 2 -strict experimental -ab 128k ^
    -vcodec libx264 ^
    -preset slow -profile:v baseline -level 30 ^
    -vsync 1 -r 25 ^
    -maxrate 10000000 -bufsize 10000000 ^
    -b:v 1200k ^
    -f mp4 -threads 0 ^
    "Section 1.mp4"
    Quote Quote  
  7. Member
    Join Date
    Nov 2007
    Location
    United States
    Search Comp PM
    Here is a link to the file (6.5MB): https://dl.dropbox.com/u/8634176/Section%201.flv

    @bat999: I tried that but it did not help. Thanks for the suggestion.
    Quote Quote  
  8. I think bat99 had a typo, he probably meant -r 15 , not -r 25 -- did you test that?

    This is actually a CFR file , and it works ok if you route it through avisynth's directshowsource (with lav filters splitter, ffdshow decoding) , or ffms2 if you force the framerate to 15 (using AssumeFPS(15) ) . You can still use ffmpeg to encode , or whatever encoder . This suggests it's a decoding issue with ffmpeg (ffms2 is derived from ffmpeg libraries and exhibts similar framerate issues , but forcing it to 15 works ok)

    Where was the crash that you mentioned? There is a small decoding glitch near the very end (the last few frames), but it doesn't affect linear playback unless you seek directly to that area

    eg. ffms2 , ffmpeg to encode

    EDIT: attachment removed by request
    Last edited by poisondeathray; 4th Mar 2013 at 08:29.
    Quote Quote  
  9. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    There seems to be a number of spots in the video that, while most players will play through, FFmpeg will not like. They are areas of incomplete or corrupted areas of 00 00 00 00 00 before an incorrect audio or video start segment.

    If you run FLVCheck and FFmpeg to copy audio and video you get:
    Click image for larger version

Name:	ScreenHunter_469 Feb. 24 01.54.jpg
Views:	4416
Size:	27.6 KB
ID:	16448

    and if you attempt to do a copy:
    Click image for larger version

Name:	ScreenHunter_469 Feb. 24 01.55.jpg
Views:	4098
Size:	37.8 KB
ID:	16449

    You get this result with FLVCheck:
    Click image for larger version

Name:	ScreenHunter_470 Feb. 24 01.55.jpg
Views:	4344
Size:	31.3 KB
ID:	16450

    If you copy it a gain you will get a correct check but the video will only be the first 21 seconds of the film( where the first bad area is):

    Click image for larger version

Name:	ScreenHunter_472 Feb. 24 01.58.jpg
Views:	3062
Size:	143.0 KB
ID:	16452

    I've had this problem my self and its caused by the invalid areas in the video. It can be corrected with a HxD editor but its time consuming and you need a good knowledge of FLV file format.
    Quote Quote  
  10. Member
    Join Date
    Nov 2007
    Location
    United States
    Search Comp PM
    Thanks for all of your input, I really appreciate it. I finally cracked it using flv extractor and ffmpeg. This is what I did:
    1. Extract audio and video into separate files from FLV file with FLV Extractor
    2. Analyze extracted video files (saved as AVI). The video files had a bunch of different frame rates. Some had 15 fps, others 7.5, and one had 5 fps
    3. Converted video files using ffmpeg and the setpts filter to adjust video speed and force framerate to 15fps for each file. Unlike my previous attempt with setfps, the multipliers were exactly correct, so the audio stream in the previous file must have been affecting the calculation. Ffmpeg crashed at the end of processing each of these files, but the resulting mp4 video file seems to be correct (well, it plays back OK at least).
    4. Muxxed video and audio, while converting audio from mp3 to aac, into a final mp4 file.
    5. Resulting mp4 files play correctly and video is synced as much as needed for these files (some video and audio files were slightly longer or shorter in total duration by a second or so), but not enough to make a difference here.
    Quote Quote  
  11. Member Budman1's Avatar
    Join Date
    Jul 2012
    Location
    NORTHWEST ILLINOIS, USA
    Search Comp PM
    Just to add an additional method... I used the Section 1.FLV file and loaded into Virtualdub and used compression of AVC codec and set frame rate to make audio and video same length (14.967). I saved to both avi and to mp4 formats with virtualdub and they were as identical as i could determine with a duration of 3m 56s each and the audio now played through the complete video.
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!