Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto-reload .ts file being live-streamed to #2230

Open
4 tasks done
alsab200 opened this issue Oct 31, 2024 · 7 comments
Open
4 tasks done

Auto-reload .ts file being live-streamed to #2230

alsab200 opened this issue Oct 31, 2024 · 7 comments

Comments

@alsab200
Copy link

The fewer issues I have to read, the more new features I will have time to implement, so I ask that you please try these things first

Description

Nice improvements since last time including FFmpeg-assisted playback. (allow external engine like mpv player sometime in the future, hopefully.) One more (a great one) LIVE EDIT would be great..

One of your stated use cases is dealing with Recording TV shows. It would be great to be able to play and edit WHILE its been recorded..
Sample workflow:
Use OBS to capture TV Broadcast in .TS muxer. (Hevc codec)
Currently using Potplayer to set chaptermarks-bookmarks while recording this .ts file. Unlike many other players, it keeps updating the data. Which enables to record and watch at the same time.
in LLC (ffmpeg assisted player), I can play and edit this .ts file while its been recorded.
Only problem is it doesnt update the new incoming data, so the file length-size stays same.

I dont know if these might help:
Watch multi-stream video file while being recorded by ffmpeg - Stack Overflow

tee - ffmpeg how to record and preview at the same time - Stack Overflow

Reading from a continuously written .ts file : r/ffmpeg

thanks for your time and help

@mifi
Copy link
Owner

mifi commented Oct 31, 2024

Nice improvements since last time including FFmpeg-assisted playback. (allow external engine like mpv player sometime in the future, hopefully.) One more (a great one) LIVE EDIT would be great..

You mean llc should send commands to a separate running MPV instance like seek, pause, play etc? Not sure what would be the benefit of that, and it could easily go out of sync.

Only problem is it doesnt update the new incoming data, so the file length-size stays same.

Have you tried the "Reload current media" shortcut?

@alsab200
Copy link
Author

MPV is a player 1) can play a video file .ts while being recorded
2) You can add bookmarks / chaptermarks AS WELL. (HEVC encoding)
Just like Potplayer! Which is why Potplayer can be the external engine instead of MPV.. or any other player!

BUT LLC Now can play HEVC .ts file thru ffmpeg assisted playback with acceptable clarity!
So NO NEED for external player..
Of course IF it can play .ts file LIVE..

Reload current media? No, its of course better than nothing but that wouldnt be practical..
Watching a game LIVE, setting chapter segments for highlights, and keep reloading the file.. While taking notes at the same time! No not practical..

Is it too difficult for you to adjust ffmeg assisted player accordingly to be still be able to play as the new data comes?
thanks.

@mifi
Copy link
Owner

mifi commented Nov 1, 2024

"Reload current media" action was added because it would be quite annoying if it auto-reloaded the file every second or so because it will cause the playback window to flash and the cursor time to be reset to 0, so I thought it's better to have control over it manually. For examply you can press the "Reload current media" button once every 30 seconds in order to load another 30 seconds of video into the player.

Not sure if I understand your use case fully. You want to edit a video while it's being recorded and then export segments as files while recording? what will you then do with these exported files (while recording)?

@alsab200
Copy link
Author

alsab200 commented Nov 1, 2024

First of all, this live editing is possible only on .ts files.
Mp4, mkv files it doesnt work.

No, I dont need to export segments while recording. I only need to create segments during a LIVE game.

Currently, while recording the game, I open this .ts file in Potplayer, and watch the live game in Potplayer.
and create bookmarks live, while watching..

after the game ends, I close Potplayer and it instantly writes these bookmarks info into our infamous ".pbf" file.Which I drag into LLC;
LLC deciphers this info into segments.
Finally I export LLC segments(merged).

Segments, is the highlights of the game.
This exported File, occasionally, is sent to f Davinci Resolve for further editing.

Why it would be much better to create edit segments in LLC?
Because LLC creates segments (also with differentiating colors) whereas in Potplayer, there is no such thing as a segments.
LLC:
LosslessCut - EL 4-3 2Y UL D3 UL D3 2024-10-23_C_36344

Potplayer:
There are only (many) dots on the timeline denoting bookmarks and you dont know instantly where a segment starts and ends, either.
EL 4-3 2Y UL D3  UL D3 2024-10-23_C_003245 010_36343

In Potplayer, YOU need to decipher start and endpoints to determine a segment.
In my case, the formula is simple:
the first dot in the timeline is start of segment 1; second dot is end of segment 1, and so on.

regarding this deciphering formula we had our discrepancies; that's why I still keep LLC v3.43.0, when I drag the .pbf file it deciphers the segments correctly)

Finally, in Potplayer, when I watch the game while its been recorded, while the new info is added to the EOF, there's no flashing!
The cursor-playhead is where it is and keep moving to the right.

Only, the timeline is re-adjusted according to the new file length I quess..

It looks like the cursor- playhead goes back a little then starts moving ahead again. If there's some flashing, It only happens on the timeline.

Thats why I guess I can watch whole game in Potplayer LIVE without any disruptions.
So, except the playhead in timeline, the playback is exactly the same as watching any (already recorded) video.

NOTE: During LIVE recording, I can stop and start playing from anywhere in timeline.

If you make this LIVE .ts playing-editing possible, it will be great. No need for .pbf No need for Potplayer.

Then, of course, I would be asking for one other improvement, which is related to this, but will make most of the LLC users if not all, in the way to perfection..

@mifi
Copy link
Owner

mifi commented Nov 1, 2024

ok thx for explaining. I agree that it's a cool feature to have.

First of all, this live editing is possible only on .ts files. Mp4, mkv files it doesnt work.

the original request for reloading the current file was for mkv #1674 but maybe he did something voodoo.

So I still think what I said earlier still stands for LosslessCut:

it would be quite annoying if it auto-reloaded the file every second or so because it will cause the playback window to flash and the cursor time to be reset to 0, so I thought it's better to have control over it manually. For examply you can press the "Reload current media" button once every 30 seconds in order to load another 30 seconds of video into the player.

meaning there are some things that would have to be solved before it would be possible to auto-reload file:

  1. find a way to reload a file:
  • without the video flashing
  • without losing playback state (e.g. going from playing to paused)
  • without timeline marker jumping back to 00:00:00
  1. find a way to also make this work with ffmpeg-assisted playback, because now when a .ts file is opened the first time, a dummy mkv file is generated with a duration equal to the .ts file's duration. this file is then loaded and used to determine the duration of the timeline. so even when reloading the .ts file in losslesscut, the same old dummy file will be loaded, so the old duration will be used. I think we have to rewrite the code to use the MediaSource api instead of generating a dummy file. then the duration could probably be specified programmatically based on the .ts file's duration.

once these issues have been solved, we could auto-reload the file whenever it changes.

Here's an ffmpeg command to generate a live stream into a .ts file for testing:

ffmpeg -hide_banner -re -f lavfi -i 'gradients=s=640x480:rate=30:n=3:type=linear,drawtext=text=%{localtime\\:%T}:fontcolor=white:fontsize=20:box=1:[email protected]:x=(w-text_w)/2:y=(h-text_h)/2,format=yuv420p' -pix_fmt yuv420p -an -vcodec libx264 -b:v 1M -preset ultrafast -f mpegts stream.ts

@mifi mifi changed the title FFmpeg-assisted playback - make it possible to play - edit file while recording Auto-reload .ts file being streamed to Nov 1, 2024
@mifi mifi changed the title Auto-reload .ts file being streamed to Auto-reload .ts file being live-streamed to Nov 1, 2024
@alsab200
Copy link
Author

alsab200 commented Nov 1, 2024

OK.
This i the behavior of Potplayer. Not exact numbers:
Live Recording starts; 3 mins later I start running PP. file length shows 3.00

In timeline File length continuously updates. The playhead moves normally... and updates

When playhead shows abt 3.40 file length is 3.50
The play head, when close to the very end of timeline,
continuously start to jump back very little and continue to move forward; no stopping no flashing on the view..

After a while play head time catches file length time like 4.01 to 4.00 ..
From then on play head time Exceeds file length! Strange!

when you stop and start playing again.. Both numbers update correctly!
Hope it helps.

@alsab200
Copy link
Author

alsab200 commented Nov 1, 2024

One more thing, mpv or mpv.net I believe both Open Source, there might be a clue there for you. They both play .ts files being recorded as well as PP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants