Fix flv files that stop early
Asked Answered
C

2

6

I downloaded some flv videos some time ago and when watching them they stop at a point. If I skip past that point they continue playing fine up until another point which I can then skip past again (and the cycle goes on until the end of the video)

I already tried

avconv -i input.flv -acodec copy -vcodec copy -g 1 output.flv

To my understanding from reading alot of mostly useless posts regarding this issue the there isn't any keyframes in my metadata and then stop when there is a bad frame.

I tried setting -g higher but output.flv stops at the same point as where the original file stops for the first time. Is there any tool that can fix this.

I can't remember where the original links are located and re-downloading isn't a option and as you can see my re-encoding attempts has failed.

I am using Linux Ubuntu, so I can't use the Windows tools that are available.

EDIT

After alot of struggle I still haven't been able to fix the file.

I was wrong in my assumption that the MetaData is the problem. After trying an array of tools I found that most of them stopped with End of File (In the middle of the file).

The Metadata is what it should be. (I successfully extracted it). It seems the streams is corrupt. I tried re-muxing,re-encoding injecting MetaData none of them worked they produced file that still stuck at same spot or simply the stream up until the bad spot.

My problem is the exactly the same as listed here : link

Any help would be greatly appreciated. I'll take any solution even if I have to hack out a bit of the file with a hex editor. (I tried removing what I though was the bad bit but that caused it to not play at all)

I have a Windows machine at my disposal now so running windows utilities isn't a problem any more.

Civil answered 19/10, 2012 at 13:18 Comment(7)
play with what ? how ? the flv is a proprietary container from Macromedia, now Adobe, and the main problem is not linux vs windows but the fact that it's a proprietary format. Use handbrake or similar tools, this is your best chance en.wikipedia.org/wiki/Flash_Video#FLV_convertersHat
I don't have enough bandwidth to download handbrake. I played them using the built in Movie Player. I also tried using VLC.Media player classic and Windows media player on my friends windows computer. I know flv is a container and that it's from Adobe. I don't see the Window vs Linux comparision I just can't run any of the Windows tools that there is on Linux.Civil
try with wine, the latest version from the PPA is a big bugfix release and can make many thing work.Hat
thanks. I can't test the it now, I'll hopefully have time over the weekend. I was hoping for a quick one line command line solution, but any solution is better than none.Civil
I tested a few tools on my friends windows machine. It looks like it's not the flv itself thats corrupt but the underlying stream. Thats why avconv and ffmpeg stops at a certain point. I looked at the metadata of the flv file and it's got all the keyframes nicely laid out. After running tools that supposedly fix flv files it chnages it to stop after the broken point. I ran FLVExtract.exe,flvmdi.exe and some other tool I can't remember. Is there any way to read the stream in a way that when it reaches a broken point instead of stopping it looks for the next working bit and continues from there?Civil
Did you try ffmpeg? If so, did you get an "Stream discovered after head already parsed" message?Lighterage
@Lighterage avconv is a fork a ffmpeg and I don't have to file anymore, but if I remember correctly it just stopped.Civil
C
3

I fixed it.

Not the solution I was hoping for, but I managed to split the file into different bit using avconv

avconv -ss "$TIME" -i "$IN" -vcodec copy -acodec copy "$OUT"."$PART".mkv

Putting ss before the input file caused it to use keyframes to jump to the correct location and then didn't run into the corrupt bit and crash. After each corrupt bit I repeated the previous step with the new $TIME.

Finally I added all the bits together with avconv concat option and now it works. When reaching a previous corrupt bit the videos jumps a bit forward, but that's fine.

Civil answered 14/1, 2013 at 13:52 Comment(3)
Could you clarify, how you got the right time/(next)keyframe info? You did it by manually checking a file, or using some tool. And did you make some script with it. Could you please share if you have. I am using FFMPEG to do same, and yes it worked, but I want more accuracy in it, as i have been selecting time manually. Thank you!Kassia
I got the keyframes from a tool (Can't remember which) and I used a python script (which I don't have anymore :( ) to interpret that and split it with ffmpeg with the keyframe info I got from the tool.Civil
@Xonar: ffmpeg, when trying to convert the FLV file, told me this: "New audio stream 0:2 at pos:4696739 and DTS:211.198s", so I got the exact time.Lighterage
C
1

I've got many old FLV files that ffmpeg stops just after start, I made it work properly using

ffmpeg -flv_ignore_prevtag 1 -i file.flv -c ...

Check out https://ffmpeg.org/ffmpeg-all.html#flv_002c-live_005fflv for more information

Cowie answered 28/6, 2020 at 16:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.