livestreamer
livestreamer copied to clipboard
File output issues.
When using livestreamer -o the produced file can't be seeked in and doesn't show the correct max videotime (it shows 0:00) in vlc. The problem lies with the file, I've tried to open the file in different players and even tried re-encoding it with ffmpeg which gives me a NO FRAME error.
I've tried different rtmpdumps/librtmp.so.0 ( from here http://www.mediafire.com/?x4cvp5hl4m9xr#x4cvp5hl4m9xr) but this doesn't fix the issue.
I'm running Ubuntu 12.04 with Livestreamer 1.7.0
On what stream URL does this happen?
It happens with twitch.tv URL's. If you want I can try uploading a file with the issue.
revival.flv http://www69.zippyshare.com/v/52052780/file.html byuntest.avi http://www69.zippyshare.com/v/89486407/file.html
Hmm, this is really strange.
I did some testing and it seems like if you use the rtmpdump command from --cmdline
manually, then the outputted file will have a duration. At first I thought it was some bug in pbs (a subprocess wrapper Livestreamer uses) but even when using a minimal test case (https://gist.github.com/chrippa/b4a9803da6df3dcd1f7a) it produces a file with no duration.
On 03/12/2013, Christopher Rosell [email protected] wrote:
even when using a minimal test case (https://gist.github.com/chrippa/b4a9803da6df3dcd1f7a) it produces a file with no duration.
I did a quick play around with your “rtmpdump” command line. Not 100% sure but it looks like “rtmpdump” might be doing some file cleanup when you interrupt it. If you are piping the output or kill it with SIGKILL I guess it does not get a chance to write the length to the file. Compare
rtmpdump [. . .] --flv - > file # Writing to a file descriptor so
presumably it can seek
rtmpdump [. . .] --flv - | cat > file # Forced to pipe to another
process so it cannot seek
“rtmpdump” might be doing some file cleanup when you interrupt it
Looking at the source that does not seem to be the case, I thought it would update the duration metadata in the header, but that is not the case as the duration field is set to 0.0 on both files.
I also tried to use librtmp directly to read the stream via python-librtmp and it produced a file with correct duration and there is no seeking involved there.
But there is something going on with the pipes I think, as when I tried to pipe it through cat as you suggested it produced a file without duration aswell.
My current theory is that the players are unable to figure out a duration if the file ends without a complete FLV tag. I think what happens is that RTMP_Read will always round off the data at a tag ending, but when we read from a pipe we can end up with tags broken up in pieces. Thus if the stream reading is interrupted before the stream is complete we may write a incomplete tag at the end of the file.
I don't think there is a simple fix for this, best option is probably to use python-librtmp for stream reading in the future. But I don't really consider that binding mature until cffi has reached 1.0 so I don't want to make it default just yet.
It's weird, because I don't have this issue on my Laptop running Ubuntu 13.04 recording the same streams. (livestreamer 1.7 too, but installed via getdeb this time). I also found a stream where recording does result in a file with max time, but the max time is incorrect (more than double of the actual time). I uploaded the file: http://www54.zippyshare.com/v/65797088/file.html
Are you able to reproduce this issue? If not I'm willing to test some stuff for you guys.
Are you able to reproduce this issue? If not I'm willing to test some stuff for you guys.
Yes, I was able to reproduce it. I'm pretty sure my theory is correct now, since I wrote a small script that verifies that all the tags are complete and discards any that aren't. This script fixed my test files, and it also fixed the incorrect duration on the file you just uploaded.
This issue should probably not happen unless you interrupt the stream though, if it reaches end naturally it should work as expected. A workaround is to make a small script that just grabs the rtmpdump command line from livestreamer --cmdline
and adds -o <filename>
to it to let rtmpdump handle the file output.
How do you use this script? When I run it, I get this error. I don't know know anything about python.
Traceback (most recent call last):
File "fixit.py", line 3, in
I have a file that I needed to end pre-maturely and wanted to see if this would fix it.
The script expects livestreamer to be installed, if you're on Windows you should be able to drop the script in the livestreamer directory and run it from there.
Yes, on Windows and I tried that. Used the command "c:\Python33\python fixit.py test.flv". I think I need an output file as well but I don't think that is not going to correct the error.
Looks like python eggs aren't picked up for some reason, try putting it in the sub folder named livestreamer-1.8.0-py2.7.egg
instead.
Yeah, that worked. Strange thing though. I recorded a stream but it did not end from one broadcast to another, normally it ends then starts another. So I had to stop it manually which gave the incorrect duration (00:00). Running the script works but appears to stop at the end of the first broadcast, the file is much smaller, and when I view it, the "fixed" file ends after the first broadcast. Besides not getting the whole file, it is the second broadcast I would need since the first was started somewhere in progress and the second was stopped after it ended, there may be a third or more in the file. Not asking for a fix or saying anything is wrong, just noting what it is doing.
Also tried script on large file. The duration of file was over 1:59:00 but it would only play about 10 minutes, to the end of the first broadcast. File size was much smaller as well.
As a side note: I used FLVExtact to extract the audio and video and then MP$Box to mux them back together and the resulting file, while perfectly viewable, is not the full length of the video in the file. Seems to be an issue with the files.
This may ultimately be an issue for me with the veetle plugin or stream. The stream never ends, meaning livestreamer will go on indefinitely. This may be that the actual stream switches to another broadcast (movie or other video) but doesn't actually end, or livestreamer does not pick it up. This seems consistent across all vettle streams. However, the output file will be truncated when viewing to the end of the first broadcast or earlier. The file will be of no duration, if fixed, the duration is much less than it should be. I can never play the file past that point. I used many programs to try and fix the file or get the full duration but all of them, including your script, truncate the file to the same length. I was able to inject a duration with Flvtool2, converted that file to an mp4 to see what would happen, and the duration was over two hours but it will still only show the first 9 minutes. When I run your script on the file, it only outputs the first 9 minutes, as do all other programs I've tried. This particular file was a movie and I started livestreamer at the beginning of it, ended it just before it ended. At 9:32 something happened to the flv file. It is over 880,000KB in size. Your script reduces it to almost 81,000KB, which makes sense because it is only 9:32 minutes long. For some reason, it put an end to the file, or something at 9:32. Normally it would do this at the end of the broadcast, but continue to output more, which I can never see. Very peculiar.
I've changed the veetle plugin (2027bd53007ffc28a379a0fcd87d095df6673505) to verify the FLV tags before writing them, this should probably fix the issue of multiple FLVs in a single stream.
For people who are having this issue use FLVExtract + MP4Box. Grab it from here.
http://www.videohelp.com/tools?toolsearch=FLVExtract&submit=Search&portable=&s=&orderby=Name&hits=50
IMPORTANT: Get FLV Extract 2.2.0 jofori89 (direct link) under "more downloads". This version will remux it losslessly (not trascoding) into an MP4 file in couple seconds. You can then do whatever you want with the file (edit in video editor, seek forward backwards etc.) It's a normal MP4 file. There is also an option to remux to .MKV if desired.
Im having a similar problem with a live youtube stream. Im using the latest version of livestreamer and have windows 10 with all patches applied. Im recording a live 2 hour stream and output to mpeg file. The file size looks correct but the file will not play on vlc (current version). This only happens on the live stream. Regular downloads work perfectly. Will this old python script help?
@phcaptjim have a look at https://github.com/streamlink/streamlink it appears to have more active development and is a fork of livestreamer.