<p>Keep FLV but trim using demuxer seek and duration.</p>

<pre><code>ffmpeg -ss 00:00:03.000 -t 00:00:01.000 -i output.flv -c copy output2.mp4
</code></pre>

<p>Also, skip <code>-ss</code> if it's <code>0</code> i.e. stream start.</p>

CC BY-SA 4.0
2018-05-23T12:29:27.207Z
Skipping -ss for the start is what fixed it for me. It seems like the file was really starting at 0.080. How would I know that if I were writing a script to trim a file?
seanr8
CC BY-SA 4.0
2018-05-23T05:20:13.420Z
2018-05-23T05:20:13.420Z
Gyan
<p>I am encoding a video with ffmpeg into H.264 stored in an FLV container. I would like to be able to trim segments of this video out as it is still encoding. The video contains no audio.</p>

<p>I am encoding the video like so:</p>

<pre><code>ffmpeg -i recording.mp4 -c libx264 output.flv
</code></pre>

<p>And I'm attempting to trim the video with:</p>

<pre><code>ffmpeg -i output.flv -ss 00:00:00.000 -t 00:00:01.000 -c copy output2.mp4
</code></pre>

<p>While the video is still encoding, I see this error when I try to trim:</p>

<pre><code>Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)
</code></pre>

<p>Also while encoding, using ffprobe, I get information like the following:</p>

<pre><code>Duration: 00:00:26.96, start: 0.080000, bitrate: 126 kb/s
  Stream #0:0: Video: h264 (High), yuv420p, 640x480, 25 fps, 25 tbr, 1k tbn, 50 tbc
</code></pre>

<p>How can I go about trimming this file while it's still encoding? I am willing to change container formats from flv to something else if needed. Ultimately, I need to be in mp4, but I don't mind doing some container shuffling to allow me to trim out portions while still encoding. </p>

CC BY-SA 4.0
2018-05-22T19:59:01.460Z
Works here. Which ffmpeg version?
Gyan
CC BY-SA 4.0
2018-05-22T20:02:20.490Z
2.8.14. From the official Ubuntu 16.04 repos
seanr8
CC BY-SA 4.0
2018-05-22T20:04:18.880Z
Get a binary from https://johnvansickle.com/ffmpeg/ and check.
Gyan
CC BY-SA 4.0
2018-05-22T20:13:15.090Z
I just did. However, now it trims without error, but the resulting file has a length of 0 and 0 frames are in it. I used the exact same command as above, but used the build you linked to. I tried both the release and the git builds. Are you using a publicly available sample video I could find somewhere and try myself?
seanr8
CC BY-SA 4.0
2018-05-22T21:22:13.500Z
Do you get the same behaviour if you cut a longer segment?
timonsku
CC BY-SA 4.0
2018-05-23T12:22:54.950Z
Yes, same behavior on a longer segment
seanr8
<ffmpeg><mp4><live><libx264><flash>
Trim a segment of live, still-encoding H.264/FLV with ffmpeg
seanr8
# Trim a segment of live, still-encoding H.264/FLV with ffmpeg

(Asked by: username_0 on 2018-05-22)

I am encoding a video with ffmpeg into H.264 stored in an FLV container. I would like to be able to trim segments of this video out as it is still encoding. The video contains no audio.
I am encoding the video like so:
ffmpeg -i recording.mp4 -c libx264 output.flv

And I'm attempting to trim the video with:
ffmpeg -i output.flv -ss 00:00:00.000 -t 00:00:01.000 -c copy output2.mp4

While the video is still encoding, I see this error when I try to trim:
Output file is empty, nothing was encoded (check -ss / -t / -frames parameters if used)

Also while encoding, using ffprobe, I get information like the following:
Duration: 00:00:26.96, start: 0.080000, bitrate: 126 kb/s
  Stream #0:0: Video: h264 (High), yuv420p, 640x480, 25 fps, 25 tbr, 1k tbn, 50 tbc

How can I go about trimming this file while it's still encoding? I am willing to change container formats from flv to something else if needed. Ultimately, I need to be in mp4, but I don't mind doing some container shuffling to allow me to trim out portions while still encoding.

**Tags:** ffmpeg, mp4, live, libx264, flash

> **Comments:**
> **username_1**: Works here. Which ffmpeg version?  
> **username_0**: 2.8.14. From the official Ubuntu 16.04 repos  
> **username_1**: Get a binary from https://johnvansickle.com/ffmpeg/ and check.  
> **username_0**: I just did. However, now it trims without error, but the resulting file has a length of 0 and 0 frames are in it. I used the exact same command as above, but used the build you linked to. I tried both the release and the git builds. Are you using a publicly available sample video I could find somewhere and try myself?  
> **username_2**: Do you get the same behaviour if you cut a longer segment?  
> **username_0**: Yes, same behavior on a longer segment  

---

## 1 answers

### Answer by username_1 on 2018-05-23. Score: 2 | Accepted answer

Keep FLV but trim using demuxer seek and duration.
ffmpeg -ss 00:00:03.000 -t 00:00:01.000 -i output.flv -c copy output2.mp4

Also, skip -ss if it's 0 i.e. stream start.

> **Comments:**
> **username_0**: Skipping -ss for the start is what fixed it for me. It seems like the file was really starting at 0.080. How would I know that if I were writing a script to trim a file?  

---

