taengstagram / instagram-livestream-downloader

Instagram Live Stream Downloader
MIT License
119 stars 37 forks source link

The final file is corrupted? #8

Closed arieoo closed 7 years ago

arieoo commented 7 years ago

Please read the following instructions carefully


Before submitting an issue, make sure you have:

Purpose of your issue:

Describe your issue

I have successfully downloaded the livestream but seems like the .mp4 file is corrupted (the video sometimes turn into green or grey and distorted but the audio is okay), can i fix this by re-joining m4v & m4a fragments? how do i do that? Thank you.

taengstagram commented 7 years ago

Does this happen for every broadcast downloaded? Have you tried with another video player? VLC is what I recommend.

It is highly unlikely that reassembling the fragments will make any difference but if you kept the original fragments, meaning you ran the livestream_dl command with the -nocleanup option, you can try

livestream_as "path/to/broadcast_info.json" -o "path/to/downloaded_fragments_folder"

The greater likelihood is that you or the broadcaster had connection problems and the video output is simply the result of that.

dvingerh commented 7 years ago

I just want to pitch in and say I had this same thing happen to me yesterday. Using a different media player doesn't make a difference, its really the video file that got corrupted. I don't save the file fragments but it seemed to have been a problem with ffmpeg/livestream_dl itself as i recorded the same stream twice on different devices and the other one turned out just fine.

taengstagram commented 7 years ago

@notcammy No error logs or error messages in the console? Do the 2 files have different file sizes? Is the corruption peppered throughout the video or just at 1 or 2 points?

The only time I've had a corrupted video file was due to connection problems, so I'm inclined to attribute this to that.

dvingerh commented 7 years ago

I didn't get to check the console in time as i reviewed the files about an hour later and i have both running​ in a bash loop script (terminal history didnt go that far back). File sizes are nearly identical ~500kb difference. Only the first second of the corrupted video is intact, from there the whole video is just distorted with grey and green colors (skipping the first second and seeking to a different timestamp doesn't make any difference). Audio is fine though.

The only time I've had a corrupted video file was due to connection problems, so I'm inclined to attribute this to that.

Perhaps, but it would be kind of odd considering both files were recorded and assembled at the same time.

taengstagram commented 7 years ago

@notcammy If that's not a typo, 500kb sounds like pretty big difference to me. That's about the size of a few video fragments, and each fragment is typically equivalent to 1 sec of video time.

Run with the -log option in the future and you won't have to rely on terminal history.

dvingerh commented 7 years ago

Both scripts started recording at a slightly different moment so the non-corrupted one is about 5 seconds shorter. I'll be recording with the log parameter and save the fragments from now on since I'm not short on disk space anyway. I guess ffmpeg just crapped out on this particular stream because bad luck.

arieoo commented 7 years ago

@taengstagram

Does this happen for every broadcast downloaded? Have you tried with another video player? VLC is what I recommend.

No, it's only happened once. There are 2 broadcasts (1 same user, 1 different user) after that and the video output was fine. Tried all media player in my computer including VLC but the video still the same.

I've tried to reassemble the fragments but no luck, the final video still corrupted. Yeah it's very likely that me or the broadcaster had connection problems, but i'm not really sure since i was not at home when the broadcast happened.

nppht commented 7 years ago

I found this problem too the final file is .mp4 but it's can't open (I try to find program to fix it but it's not work I don't sure it's the fake program or because of my file)

or sometime the folder is still there and have many .m4v and .m4a file but not have .m4v.tmp (it's have -init.m4v / -init.m4a / .m4a.tmp / .m4v /.m4a) it's have the way to get it together again? I found http://developers-club.com/posts/204666/ but I don't sure it's the way to fix it or not (I don't know english too much)

maybe next time I should open 2 batch file in the same livestream account but save in other folder? It can help?

( sorry for my english and thank you : ) )

taengstagram commented 7 years ago

@arieoo If you still have the downloaded fragments folder, can you zip it up and make it available somewhere to download? I don't think it will help much but I can take a look. To save space, you can remove the 2 source*.tmp files because those are generated by the script.

@nppht If you have fragment .m4v / .m4a files but you did not use the -nocleanup option, it means that ffmpeg encountered an error trying to combine the files. You should see error messages in that case.

In any case, an error log is a must when reporting an issue like this. No one has provided any logs so far so we're getting nowhere with this.

If you encounter this issue regularly, submit a new issue with the necessary log info. Make sure you run the command with the -log option.

arieoo commented 7 years ago

@taengstagram here is the downloaded fragments https://cloudup.com/c9oKCTSDHNu

taengstagram commented 7 years ago

@arieoo That link doesn't work. It says that download is disabled for security reasons.

arieoo commented 7 years ago

@taengstagram oh sorry here is the new link https://www.dropbox.com/s/3d7n7151h689ltw/20170429_ron_sae_17878700425024890_downloads.zip?dl=0

taengstagram commented 7 years ago

I reviewed the fragments downloaded by @arieoo and it doesn't look like the corruption is due to network problems.

It appears to be something different/wrong with the fragments downloaded instead. Tried running ffmpeg with different options on the fragments but it didn't make a difference.

Extra puzzling because this apparently happens only some of the time and I haven't encountered it myself.

Re-opening this issue with the possibility that someone may have additional insight.

dvingerh commented 7 years ago

Got another case here, the streamer had a bad internet connection at the very start so that caused the initial problem but I have 3 people with the same corrupted output file so it's likely got something to do with the way livestream_dl handles (very) flaky/dropping connections from the stream without explicitly stopping and starting livestream_dl again.

Here's the fragments in case that might be of any help: https://millie.me/data/20170519_milliebobbybrown_17874686371071511-3.zip

taengstagram commented 7 years ago

Made a small change which may or may not help. You can update your install with

pip install git+https://git@github.com/taengstagram/instagram-livestream-downloader.git@0.3.2 --process-dependency-links --upgrade
dvingerh commented 7 years ago

Cool. I'll report back with results as soon as possible.

taengstagram commented 7 years ago

Please update your install to v0.3.3 v0.3.4 v0.3.5. Decent chance that this update will fix the corruption problem.

pip install git+https://git@github.com/taengstagram/instagram-livestream-downloader.git@0.3.5 --process-dependency-links --upgrade
dvingerh commented 7 years ago

I saw that you added --repair to the assembler command but when I try to use it the following error is thrown:

Command: livestream_as "20170519_milliebobbybrown_17874686371071511-3.json" -o "20170519_milliebobbybrown_17874686371071511_downloads-3" -f "output.mp4" --repair

Output:

Assembling video stream... 20170519_milliebobbybrown_17874686371071511_downloads-3/assembled_source_17874686371071511_mp4.tmp
Replacing 20170519_milliebobbybrown_17874686371071511_downloads-3/17874686371071511-init.m4v
Traceback (most recent call last):
  File "/usr/local/bin/livestream_as", line 11, in <module>
    load_entry_point('instagram-livestream-downloader==0.3.3', 'console_scripts', 'livestream_as')()
  File "/usr/local/lib/python2.7/dist-packages/livestream_dl/assemble.py", line 114, in main
    with open(f, 'rb') as readfile:
IOError: [Errno 2] No such file or directory: '/usr/local/lib/python2.7/dist-packages/livestream_dl/repair/init.m4v'
root@SYNOLOGY116:/home/default/downloaded#
taengstagram commented 7 years ago

@notcammy v0.3.4 should fix that.

pip install git+https://git@github.com/taengstagram/instagram-livestream-downloader.git@0.3.4 --process-dependency-links --upgrade

Caveat: The --repair option is not fully tested and may not work for you. It "tries" to fix the previously corrupted portion of the video but at the cost of corrupting the previously uncorrupted portion. In your case, the previously uncorrupted first 1 second of your video will be messed up, but the rest will now be okay. It's the best tradeoff I've managed to wrangle in for now.

If you want a truly complete file, you will have to manually splice and merge from 2 versions of the video, 1 assembled without the --repair option, and 1 assembled with.

dvingerh commented 7 years ago

I tried it again and it works! The first second did indeed get corrupted but I can just cut that part off into a seperate file beforehand and later merge it with the new, uncorrupted output file. I'll use this option should I get a new corrupted stream output again and report back if anything doesn't work out as intended.

taengstagram commented 7 years ago

@notcammy The assembler is a hacky workaround for downloader problems. Ideally, the downloader should now work as expected and you wouldn't need to manually assemble.

taengstagram commented 7 years ago

@ all,

Neglected to mention here with the new release, please update to v0.3.5.

pip install git+https://git@github.com/taengstagram/instagram-livestream-downloader.git@0.3.5 --process-dependency-links --upgrade
taengstagram commented 7 years ago

Closing this since it's been 2 months and there hasn't been any new reports. I assume this is now fixed.