BtbN changed the topic of #ffmpeg to: Welcome to the FFmpeg USER support channel | Development channel: #ffmpeg-devel | Bug reports: https://ffmpeg.org/bugreports.html | Wiki: https://trac.ffmpeg.org/ | This channel is publically logged | FFmpeg 7.0 is released
<redeeman> it seems it doesnt
<redeeman> seems i had to add out_range=pc to the scale
rex has quit [Ping timeout: 248 seconds]
wziko has quit [Ping timeout: 265 seconds]
Marth64 has quit [Quit: Leaving]
Kei_N has joined #ffmpeg
wziko has joined #ffmpeg
wziko has quit [Max SendQ exceeded]
Kei_N_ has quit [Ping timeout: 272 seconds]
olndrxyz has quit [Quit: Quit]
lavaball has quit [Remote host closed the connection]
rex has joined #ffmpeg
sihloo_ has joined #ffmpeg
chandash has joined #ffmpeg
CruxOfTheB has quit [Ping timeout: 244 seconds]
CruxOfTheB has joined #ffmpeg
xx has quit [Ping timeout: 264 seconds]
j4n has quit [Quit: j4n]
j4n has joined #ffmpeg
j4n has quit [Client Quit]
j4n has joined #ffmpeg
CruxOfTheB has quit [Ping timeout: 265 seconds]
chandash has quit [Quit: WeeChat 4.4.2]
UltimateCodeWarr has joined #ffmpeg
<UltimateCodeWarr> Hello, is it possible to be reading from FFMPEG .MP4 while it's being written to at the same time. For instance, you have written 11 seconds of A/V to the file, and you want to read the first 10 seconds?
<Traneptora> UltimateCodeWarr: for mp4, this is not possible
<Traneptora> when writing to mp4, the last thing that the writer does is write the "moov" atom, which is the index. mp4 is not readable without it
<aaabbb> Traneptora: no, you can do faststart
<aaabbb> UltimateCodeWarr: add -movflags +faststart
<Traneptora> faststart moves the mov atom to the front with a second pass after it is written
<Traneptora> it does not work with streaming
<aaabbb> Traneptora: yeah but you can still play it while it's writing
<Traneptora> that should not work
<aaabbb> hm, let me test it, since i was sure it did for some reason
<aaabbb> oh you're right, i must have been thinking of matroska
<Traneptora> UltimateCodeWarr: what you are trying to accomplish is possible fi you use matroska
<aaabbb> yeah ^
<aaabbb> and at the end you can remux the matroska into mp4 if you really want to
<Traneptora> you can read from a matroska file that is being written to at the same time, and it should work. this is not possible with mp4 specifically because of the mp4 file format's limitations
<aaabbb> i thought that faststart would put a dummy moov at the beginning until it was ready to write the real moov
<aaabbb> maybe it just allocates space for a moov atom but doesn't actually put anything into it until thesecond pass
<Traneptora> the mp4 file format isn't readable until the file is finalized, which won't work mid process. it also means that if the writing process crashes the recording is corrupt, so it's not a good idea for live recordings either
<aaabbb> yeah you're right, i'm wrong there. just use mkv
<UltimateCodeWarr> Ok, good to get the experts reasoning on it.
<UltimateCodeWarr> Chat GPT thought it was possible
<UltimateCodeWarr> import subprocess
<UltimateCodeWarr> import socket
<UltimateCodeWarr> import time
<UltimateCodeWarr> # Set up socket connection to send video chunks
<UltimateCodeWarr> server_ip = '127.0.0.1' # IP of the receiving machine
<UltimateCodeWarr> server_port = 12345 # Port number
<UltimateCodeWarr> sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
<Traneptora> ChatGPT is not a good source for technically matters
<UltimateCodeWarr> sock.connect((server_ip, server_port))
<UltimateCodeWarr> # Function to read video and audio chunks using FFMPEG
<UltimateCodeWarr> def stream_video_chunks(input_file, chunk_duration=10, chunk_size=5):
<UltimateCodeWarr> # Start FFMPEG subprocess to read the file in real-time
<UltimateCodeWarr> ffmpeg_cmd = [
<UltimateCodeWarr> 'ffmpeg',
<Traneptora> holy moley spam
<UltimateCodeWarr> '-i', input_file, # Input video file
<UltimateCodeWarr> '-f', 'segment', # Use segment format for chunks
<UltimateCodeWarr> '-segment_time', str(chunk_duration), # Set chunk duration
<UltimateCodeWarr> '-c:v', 'libx264', # Video codec (you can change this if needed)
<UltimateCodeWarr> '-c:a', 'aac', # Audio codec (you can change this if needed)
<UltimateCodeWarr> '-segment_format', 'mp4', # Output format (in this case .mp4)
<UltimateCodeWarr> '-y', # Overwrite output files if needed
<aaabbb> put it in a paste site
<UltimateCodeWarr> 'pipe:1' # Send output to stdout (pipe)
<Traneptora> BtbN: help plz
<UltimateCodeWarr> ]
<UltimateCodeWarr> # Start FFMPEG subprocess
<UltimateCodeWarr> process = subprocess.Popen(ffmpeg_cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
<UltimateCodeWarr> while True:
<UltimateCodeWarr> # Read a chunk of data from stdout
<UltimateCodeWarr> chunk_data = process.stdout.read(chunk_size * 1024) # Read a fixed size chunk
<UltimateCodeWarr> if not chunk_data:
<aaabbb> Traneptora: his client is probably buffering the paste to avoid being killed
<UltimateCodeWarr> break # End of video stream
<UltimateCodeWarr> # Send the chunk over the socket to the other computer
<aaabbb> so he can't stop even if he wants to
<UltimateCodeWarr> sock.sendall(chunk_data)
<UltimateCodeWarr> time.sleep(chunk_duration) # Wait for the next chunk
<UltimateCodeWarr> # Start streaming video chunks from the file
<UltimateCodeWarr> input_file = 'input_video.mp4' # Path to the .mp4 file
<UltimateCodeWarr> stream_video_chunks(input_file)
<UltimateCodeWarr> sock.close() # Close the socket whe
<Traneptora> ye but someone can kick him
<Traneptora> oh good it ended
<aaabbb> i think it finished pasting anyway
<aaabbb> but yeah next time use a paste site lol
<UltimateCodeWarr> Sorry bout that
<aaabbb> unless pasting more than like 3 lines
<UltimateCodeWarr> HexChat is great
<Traneptora> unless you're pasting more than one line honestly use a paste site plz
<Traneptora> you can always quit the client if you pasted a paragraph you didn't mean to
<UltimateCodeWarr> Would like 512 bytes bring the system down?
<aaabbb> yeah, cuz something a lot of people don't realize is that if you paste a lot, it will appear all at once to you, but to everyone else it will be slowly sent one at a time, so it's never "too late" to close the client to stop it from sending
<aaabbb> 512 bytes of what?
<UltimateCodeWarr> A code block
<aaabbb> it's more that posting a lot of lines at once is distracting
<aaabbb> the system can handle it, although each irc line is limited to 512 bytes minus overhead for metadata
<UltimateCodeWarr> The ideal way to read from a FFMPEG would be to pass in a start / stop timestamp, it would adjust those values according to how close it could get to a keyframe that it could stitch the two chunks back together seamlessly.
<UltimateCodeWarr> Each chunk that it splits up should be playable by itself.
<aaabbb> so like dash?
<UltimateCodeWarr> But when re-assembling on the other side, it should get rid of any header junk
<aaabbb> mpeg-ts etc?
<Traneptora> UltimateCodeWarr: maybe you're looking for the segment muxer?
<UltimateCodeWarr> Always open to new ideas.
<Traneptora> it splits the output into several files of (almost) fixed duration
<Traneptora> all of which are playable
<Traneptora> it uses keyframes to split to ensure that is the case
<Traneptora> for ex: ffmpeg -i in.mkv -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
<UltimateCodeWarr> The problem I have is I have a raspberry pi that can write Cam data to a MP4. If I write 10 second segments so they can be processed by back end OpenCV, I have to start/stop the PiCamera's writing of the MP4 file so by the time the next one starts, I am missing action.
<UltimateCodeWarr> When I go to stitch them together, it looks jumpy.
<Traneptora> does it *have* to write to mp4?
<UltimateCodeWarr> No, but it was super convenient because it could write audio and video at the same time.
<Traneptora> if you can write a streamable format that's ideal
<UltimateCodeWarr> The .h264 is pretty good compression to boot
<aaabbb> h264 isn't limited to mp4
<aaabbb> mp4 is just a container. you can use mkv with the same exact h264 codec
<UltimateCodeWarr> Well, when I was trying to do my own capture audio/video to a file, the FFMPEG was a CPU hog, and there was audio drift
<UltimateCodeWarr> Seemed like Kung-Fu theater.
j4n has quit [Quit: j4n]
<Traneptora> UltimateCodeWarr: picamera docs mention split_recording() so maybe check that out?
j4n has joined #ffmpeg
Mister_Magister_ has joined #ffmpeg
Mister_Magister has quit [Ping timeout: 252 seconds]
Mister_Magister_ is now known as Mister_Magister
<UltimateCodeWarr> That split recording might just be the ticket.
cmc has quit [Ping timeout: 264 seconds]
cmc has joined #ffmpeg
\\Mr_C\\ has quit [Remote host closed the connection]
j4n has quit [Quit: j4n]
rvalue has quit [Read error: Connection reset by peer]
rvalue has joined #ffmpeg
sihloo_ has quit [Quit: ZNC 1.9.1 - https://znc.in]
sihloo has joined #ffmpeg
lusciouslover has quit [Ping timeout: 252 seconds]
wziko has joined #ffmpeg
wziko has quit [Max SendQ exceeded]
StephenLynx has quit [Quit: Leaving]
Icedream has quit [Quit: A lol made me boom.]
Icedream has joined #ffmpeg
sm1999 has joined #ffmpeg
rv1sr has joined #ffmpeg
rsx has joined #ffmpeg
neilt has quit [Quit: KVIrc 5.2.6 Quasar http://www.kvirc.net/]
wziko has joined #ffmpeg
wziko has quit [Ping timeout: 248 seconds]
wziko has joined #ffmpeg
wziko has quit [Max SendQ exceeded]
wziko has joined #ffmpeg
YuGiOhJCJ has joined #ffmpeg
martylake_ has joined #ffmpeg
martylake has quit [Ping timeout: 252 seconds]
martylake_ is now known as martylake
vincejv has quit [Remote host closed the connection]
vincejv has joined #ffmpeg
Sketch has quit [Remote host closed the connection]
Sketch has joined #ffmpeg
xx has joined #ffmpeg
kepstin has quit [Remote host closed the connection]
kepstin has joined #ffmpeg
kepstin has quit [Remote host closed the connection]
kepstin has joined #ffmpeg
coldfeet has joined #ffmpeg
alexherbo2 has joined #ffmpeg
HarshK23 has quit [Quit: Connection closed for inactivity]
lavaball has joined #ffmpeg
HarshK23 has joined #ffmpeg
alexherbo2 has quit [Remote host closed the connection]
CruxOfTheB has joined #ffmpeg
alexherbo2 has joined #ffmpeg
jemius has joined #ffmpeg
esu has left #ffmpeg [#ffmpeg]
System_Error has quit [Remote host closed the connection]
fling has quit [Remote host closed the connection]
fling has joined #ffmpeg
StephenLynx has joined #ffmpeg
System_Error has joined #ffmpeg
lemourin has quit [Quit: The Lounge - https://thelounge.chat]
lemourin has joined #ffmpeg
YuGiOhJCJ has quit [Quit: YuGiOhJCJ]
rex has quit [Read error: Connection reset by peer]
rex has joined #ffmpeg
alexherbo2 has quit [Remote host closed the connection]
lusciouslover has joined #ffmpeg
lusciouslover has quit [Ping timeout: 260 seconds]
manwithluck has joined #ffmpeg
jprjr has joined #ffmpeg