Can't read the last line from stdout pipe of FFmpeg

So I'm making an app that executes ffmpeg and I want to be able to get the last line of its output to get progress information.

When I run this function to print ffmpeg's output, it prints everything except the last line that i need:

async fn play_progress(stdout: tokio::process::ChildStderr) {
    let reader = FramedRead::new(stdout, LinesCodec::new());
    let mut stream = reader.map(|data| data.expect("Fail on output!"));

    loop {    
        while let Some(line) = stream.next().await {
            println!("Line: {}", line);
        }
        
        println!("End of looping through lines");
        sleep(Duration::from_secs(1)).await;
    }
}

App's Output while FFmpeg is running: (shortened)

Line:   Metadata:
Line:     major_brand     : isom
Line:     minor_version   : 512
Line:     compatible_brands: isomiso6iso2avc1mp41
Line:     title           : Labirhin - Fight Over (First Super Power) Animated Music Video
Line:     artist          : Labirhin
Line:     encoder         : Lavf61.1.100
Line:   Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x810 [SAR 1:1 DAR 64:27], q=2-31, 24 fps, 12288 tbn (default)
Line:       Metadata:
Line:         handler_name    : ISO Media file produced by Google Inc.
Line:         vendor_id       : [0][0][0][0]
Line:         encoder         : Lavc61.3.100 libx264
Line:       Side data:
Line:         cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Line:   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 64 kb/s (default)
Line:       Metadata:
Line:         handler_name    : ISO Media file produced by Google Inc.
Line:         vendor_id       : [0][0][0][0]
Line:         encoder         : Lavc61.3.100 aac

App's output when I kill FFmpeg: (now the last line gets shown for some reason)

Line: Output #0, mp4, to '/home/sypth/Downloads/youtube_GyJpbAgOWSw_1920x810_h264-output.mp4':
Line:   Metadata:
Line:     major_brand     : isom
Line:     minor_version   : 512
Line:     compatible_brands: isomiso6iso2avc1mp41
Line:     title           : Labirhin - Fight Over (First Super Power) Animated Music Video
Line:     artist          : Labirhin
Line:     encoder         : Lavf61.1.100
Line:   Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 1920x810 [SAR 1:1 DAR 64:27], q=2-31, 24 fps, 12288 tbn (default)
Line:       Metadata:
Line:         handler_name    : ISO Media file produced by Google Inc.
Line:         vendor_id       : [0][0][0][0]
Line:         encoder         : Lavc61.3.100 libx264
Line:       Side data:
Line:         cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
Line:   Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 64 kb/s (default)
Line:       Metadata:
Line:         handler_name    : ISO Media file produced by Google Inc.
Line:         vendor_id       : [0][0][0][0]
Line:         encoder         : Lavc61.3.100 aac
Killing PID: 35540 //here ffmpeg gets killed
Killing PID: 35541
frame=    1 fps=0.4 q=37.0 size=       0KiB time=-00:00:00.04 bitrate=N/A dup=1 drop=0 speed=N/A  

As you can see on the last output, the progress gets printed but i dont think it gets printed from the println!() command since it doesnt begin with "Line: " like the rest of the output does.


Does anyone know why this is happening??

Are you sure the frame= line isn't being written to stderr instead of stdout?

i am actually capturing stderr but i just call it stdout in my function signature