I want to learn how to use the CFFILE tag from ColdFusion to read the contents of a text file. In my case, that text file is a progress log that is generated by FFMpeg while it transcodes a media file. I want to write a ColdFusion script that will poll the progress log periodically, until the log indicates that FFMpeg has finished its transcoding operation. On the client side I can then use Ajax to hit that ColdFusion script and show the user a "percentage completed" while FFMpeg does its work.
I got FFMpeg to generate the log file by using a new "progress" flag that recent versions of FFMpeg now support. Below I'll show you the way to use this flag, and also the generated output within the log file.
Here's the FFMpeg command:
ffmpeg -i c:\my_original_file.ogg c:\my_converted_file.mp3 -progress c:\my_progress.txt
The above command will cause FFMpeg to generate a log file called my_progress.txt.
Here's what it generates in the log file:
total_size=206150
out_time_ms=51410044
out_time=00:00:51.410044
dup_frames=0
drop_frames=0
progress=continue
The above 6 lines are generated repeatedly in the log file, with increasing values.
total_size=206150
out_time_ms=51410044
out_time=00:00:51.410044
dup_frames=0
drop_frames=0
progress=continue
total_size=412413
out_time_ms=102975756
out_time=00:01:42.975756
dup_frames=0
drop_frames=0
progress=continue
total_size=618363
out_time_ms=154463111
out_time=00:02:34.463111
dup_frames=0
drop_frames=0
progress=continue
total_size=824939
out_time_ms=206107189
out_time=00:03:26.107189
dup_frames=0
drop_frames=0
progress=continue
Finally, when the job completes, the final block of 6 lines are the last ones in the log file. Notice the "progress=end" on the last line:
total_size=9725902
out_time_ms=2431348011
out_time=00:40:31.348011
dup_frames=0
drop_frames=0
progress=end
I want to write a Coldfusion script using the CFFILE tag to read only the last 6 lines of the file (no matter how large the file has become), and to do this each time the script is called, by the browser, via Ajax. Finally I need to parse the values on these lines into variables so I can return some data to the caller.
I've researched progress bars for FFMpeg but they're in PHP which is hard for me, and besides, they parse the older formatted versions of FFMpeg's log files, and I would like to use the above newer formatting. Can anyone please help?